[SOLVED] Android app shows "updating token..."

I am having an issue on the android app where it states “Getting data from server failed. Try again later”. Also on occasion “sorry, server can’t talk now, try later.”

When i open the app settings I also see it says “Updating Token” and it never seems to update. I tried generating a new token and changed my app to match, this didn’t seem to help. i also removed the app and reinstalled, same behavior.

i rapidly pushed a button to activate a relay (to generate the error so I could screen cap it). I noticed the app talked to the arduino and the relay latched and unlatched…So it just seems like the data coming out from the hardware is not being reflected on the app.

i tried wifi hotspot, cellular 4G and a very well connected MPLS network, nothing seemed to help.

This is an app I have been using for some time, with very little issue.
arduino mega 2560, esp8266 and samsung sph-l720(galaxy S4) android 5.0.1

any ideas?

Brian

Please tell me your account.

PM sent to your account

Hm… Could you just log out and login back? Did you change password recently?

no, i have not changed my password at all since registration. I did remove the app, and reinstalled, which would have caused me to login again. I will do it now

So you are able to login and than get this error? Or you don’t get it anymore?

i logged back in and fired up my hotspot and arduino… serial monitor shows data going out of hardware to blynk, android app immediately says “sorry, server can’t talk right now, try later” if you wait a couple minutes, it gets at least 1 update, then back to not communicating… I can tell because the top left widget shows humidity … when it works, the diamond with a question mark in it changes to a % sign, which is what is in my code. for some reason when it can’t talk that changes to the ? and diamond…

@bpthomas could you please post your arduino code?

By the way - you using cloud server? Or local?

Have the app worked normally before, or not? Seems something happening with reading data from the server. Are you using blynk server and local one?

the app has been working very well for probably a couple months. I was sorting out a wifi drop out issue and got it working by updating my blynk libraries. Now i am having this issue. code coming in a minute. just blynk in the cloud, no local server.

sorry if the code isn’t up to par, this is my first time programming an arduino, and has been a huge learning experience.
Thanks for helping!

also note that I am writing special characters back to blynk, specifically the % sign and degree symbol ° .

//#define BLYNK_DEBUG // Optional, this enables lots of prints
//#define BLYNK_PRINT Serial //this causes buffer overflow as it competes with the console serial out

#include <BlynkSimpleShieldEsp8266_HardSer.h>
#include <DHT.h>
#define DHTTYPE DHT11
#define DHTPIN 11
#include <SimpleTimer.h>
#include <EEPROM.h>
#include <ESP8266_HardSer.h>
#include <SPI.h>
#include <Wire.h>
float hum;
float t;
float f;
float hif;
int photocellPin = 1;
int FanRelayPin = 9;
int LightRelayPin = 8;
int photocellReading;
int luxdifference;
int addressTempHum = 0;
int addressLightThresh = 1;
int addressLightOff = 2;
long LightThresholdValue; 
long LightOffValue;
long HeatThresholdValue;
int HeatDifference;
int LightOffDifference;
int ManualMode;
int ManualLights;
int ManualFan;
int LiteLEDStatus;
int FanLEDStatus;
int ManualModeStatus; 
int lastButtonStateLiteLed;
int lastButtonStateFanLed;
int lastButtonStateManualMode;

const char* ssid = "xxx";
const char* password = "xxxxx";
WidgetLED led1(30); //LightLED in blynk app
WidgetLED led2(31);//FanLED in blynk app
WidgetLED led3(10);//wifi connection light
WidgetLED led4(28);//manual led for light side
//WidgetLCD lcd(9);
unsigned long previousMillis; 
unsigned long waitTime = 3000;

DHT dht(DHTPIN, DHTTYPE); 
//float humidity, temp_f; 
int BH1750_address = 0x23; 
byte buff[2];

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxx";
// Set ESP8266 Serial object
#define EspSerial Serial
ESP8266 wifi(EspSerial);
SimpleTimer timer;

void setup()
{
timer.setInterval(2000, LiteLed);
timer.setInterval(2000, FanLed); 
timer.setInterval (2000, SendTempHumidity); 
timer.setInterval (2000, SendDataLight); //get light sensor data
timer.setInterval (2000, LightDelta); //get delta between current and threshold settings
timer.setInterval (2000, HeatDelta); //get delta between heat index and threshold settings
timer.setInterval (2000, LightOffDelta);
timer.setInterval (2000, ManualModeLed);
ManualModeStatus = 0; 
lastButtonStateLiteLed = 0;
lastButtonStateFanLed = 0;
lastButtonStateManualMode = 0;

// Set ESP8266 baud rate
EspSerial.begin(115200);
//EspSerial.begin(38400);
Serial.begin(115200);
//Serial.begin(38400);
Wire.begin();
//EEPROM.read(0); 
Serial.print("LightThresholdValueFromEEPROM: ");
//Readind and sending first long.
LightThresholdValue = EEPROMReadlong(0);
Serial.println(LightThresholdValue);

//EEPROM.read(1); 
Serial.print("LightOffValueFromEEPROM: ");
LightOffValue = EEPROMReadlong(4);
//Readind and sending first long.
Serial.println(LightOffValue);
      
//EEPROM.read(2); 
Serial.print("HeatThresholdValueFromEEPROM: ");
HeatThresholdValue = EEPROMReadlong(8);
//Reading and sending first long.
Serial.println(HeatThresholdValue);
dht.begin();// initialize temperature sensor
      
Blynk.begin(auth, wifi, ssid, password);
//wait for blynk connection
while (Blynk.connect() == false) {
// Wait until connected
}
pinMode(8, OUTPUT);      // sets the digital pin as output
digitalWrite(8,HIGH); //turn off light pin on init
pinMode(9, OUTPUT);      // sets the digital pin as output
digitalWrite(9, HIGH); //turn off fan pin on init
pinMode(13, OUTPUT);      // sets the digital pin as output
digitalWrite(13, LOW); 
led1.off();
led2.off();
led3.off();
led4.off();
}//end setup()

//int eeprom_address = 0; //We will start writing at the first memory address
long address=0;//Starting at the first byte on the eeprom.

void SendTempHumidity() { 
hum = dht.readHumidity();
t = dht.readTemperature(); 
f = dht.readTemperature(true); 
hif = dht.computeHeatIndex(f, hum);
int value1=hum*10;
String str1;
char result1[5];
result1[0]=(value1/100)+'0'; 
result1[1]=((value1/10)%10)+'0';
result1[2]='.';
result1[3]=(value1%10)+'0';
result1[4]='\0';
str1 +=result1;
str1 +="%";
//char buf[str.length()+1];
char buf1[8];
str1.toCharArray(buf1,sizeof(buf1));

Blynk.virtualWrite(1, buf1);//write humidity with percent sign to virtual pin 1 
Blynk.virtualWrite(11, hum);//write humidity without percent sign to virtual pin 1 
int value2=f*10;
String str2;
char result2[5];
result2[0]=(value2/100)+'0'; 
result2[1]=((value2/10)%10)+'0';
result2[2]='.';
result2[3]=(value2%10)+'0';
result2[4]='\0';
str2 +=result2;
str2 +="°F";
//char buf[str.length()+1];
char buf2[8];
str2.toCharArray(buf2,sizeof(buf2));
Blynk.virtualWrite(3, buf2);  //write temp with degree sign to virtual pin 3
Blynk.virtualWrite(13, f);  //write temp without degree sign to virtual pin 3
int value3=hif*10;
String str3;
char result3[5];
result3[0]=(value3/100)+'0'; 
result3[1]=((value3/10)%10)+'0';
result3[2]='.';
result3[3]=(value3%10)+'0';
result3[4]='\0';
str3 +=result3;
str3 +="°F";
//char buf[str.length()+1];
char buf3[8];
str3.toCharArray(buf3,sizeof(buf3));

Blynk.virtualWrite(4, buf3); //write fahrenheit heat index with degree sign to virtual pin 4
Blynk.virtualWrite(14, hif); //write fahrenheit heat index without degree sign to virtual pin 4

if (hif >=HeatThresholdValue && ManualModeStatus != 1){
digitalWrite(FanRelayPin, LOW); 
}else if (ManualModeStatus != 1) {
digitalWrite (FanRelayPin, HIGH); 
}
}
void SendDataLight(){
photocellReading = analogRead(photocellPin); 
Blynk.virtualWrite(2, photocellReading); 
Blynk.virtualWrite(12, photocellReading);

if (photocellReading <= LightThresholdValue && photocellReading >= LightOffValue  && ManualModeStatus != 1){
digitalWrite(LightRelayPin, LOW); 
}else if (ManualModeStatus != 1){
digitalWrite(LightRelayPin,HIGH); 
}
}
BLYNK_WRITE(V5) { //working 2/23/16
LightThresholdValue = param.asInt();
address=0;
EEPROMWritelong(address, LightThresholdValue);
Blynk.virtualWrite (16, EEPROMReadlong(0)); 
}


BLYNK_WRITE(V6) {
LightOffValue = param.asInt();// + 10;
address=4;
EEPROMWritelong(address, LightOffValue);//Writing first long.
Blynk.virtualWrite (17, EEPROMReadlong(4)); /
}

BLYNK_WRITE(V7) {
HeatThresholdValue = param.asInt();// + 10;
address=8;
EEPROMWritelong(address, HeatThresholdValue);//Writing first long.
Blynk.virtualWrite(15, EEPROMReadlong(8)); 
}

void loop()
{
Blynk.run();
timer.run();

}//end loop

void ManualModeLed(){
ManualModeStatus = digitalRead(13);
if (ManualModeStatus != lastButtonStateManualMode) {
if (ManualModeStatus == 1){
led3.on();

} else
led3.off();

}
lastButtonStateManualMode = ManualModeStatus;
}
/*void ManualModeLed2(){
ManualModeStatus = digitalRead(13);
Serial.println(" ");
Serial.print("ManualMode: ");
Serial.println(ManualModeStatus);
if (ManualModeStatus != lastButtonStateManualMode) {
if (ManualModeStatus == 1){
led4.on();
} else
led4.off();
}
lastButtonStateManualMode = ManualModeStatus;
}

BLYNK_WRITE(8) //light
{
  if (param.asInt()) {
    digitalWrite(8, LOW);
  } else {
    digitalWrite(8, HIGH);
  }
}

BLYNK_WRITE(9) //fan
{
  if (param.asInt()) {
    digitalWrite(9, LOW);
  } else {
    digitalWrite(9, HIGH);
  }
}



void FanLed(){
FanLEDStatus = digitalRead(9);
if (FanLEDStatus != lastButtonStateFanLed) {
if (FanLEDStatus == 1){
led2.off();
}  else
led2.on();
}
lastButtonStateFanLed = FanLEDStatus;
}
void LiteLed(){
LiteLEDStatus = digitalRead(8);
if (LiteLEDStatus != lastButtonStateLiteLed) {
if (LiteLEDStatus == 1){
led1.off();
}  else
led1.on();  
}
lastButtonStateLiteLed = LiteLEDStatus;
}

//This function will write a 4 byte (32bit) long to the eeprom at 
//the specified address to address + 3....no decimals
void EEPROMWritelong(int address, long value)
      {
      //Decomposition from a long to 4 bytes by using bitshift.
      //One = Most significant -> Four = Least significant byte
      byte four = (value & 0xFF);
      byte three = ((value >> 8) & 0xFF);
      byte two = ((value >> 16) & 0xFF);
      byte one = ((value >> 24) & 0xFF);

      //Write the 4 bytes into the eeprom memory.
      EEPROM.write(address, four);
      EEPROM.write(address + 1, three);
      EEPROM.write(address + 2, two);
      EEPROM.write(address + 3, one);
      }

//This function will return a 4 byte (32bit) long from the eeprom
//at the specified address to address + 3.
long EEPROMReadlong(long address)
      {
      //Read the 4 bytes from the eeprom memory.
      long four = EEPROM.read(address);
      long three = EEPROM.read(address + 1);
      long two = EEPROM.read(address + 2);
      long one = EEPROM.read(address + 3);

      //Return the recomposed long by using bitshift.
      return ((four << 0) & 0xFF) + ((three << 8) & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF);
      }
void LightDelta(){
if (LightThresholdValue <= photocellReading){
luxdifference = photocellReading - LightThresholdValue;
}else {
luxdifference = LightThresholdValue - photocellReading;  
}
Blynk.virtualWrite (19, luxdifference);
}

void HeatDelta(){
if (hif>=HeatThresholdValue){
  HeatDifference = hif - HeatThresholdValue;
}else{
  HeatDifference = HeatThresholdValue - hif;
}
Blynk.virtualWrite (18, HeatDifference);
}

void LightOffDelta(){
if (photocellReading>=LightOffValue){
LightOffDifference = photocellReading - LightOffValue;
}else{
LightOffDifference = LightOffValue - photocellReading;  
}
Blynk.virtualWrite (20, LightOffDifference);
}

ok, when i’ll have time i’ll prepare for you some logging build, which will prepare some log of the app’s networking, from which we could understand what’s going wrong

excellent, thanks again for your time! you guys are awesome. :wink:

1 Like

@bpthomas Thank you! One suggestion. Could you please comment in your sketch all virtualWrites where you write buffers. Like :

Blynk.virtualWrite(1, buf1);
Blynk.virtualWrite(3, buf2); 

etc., just to verify it doesn’t brake app.

1 Like

not sure I understand what you are asking, like this?:

Blynk.virtualWrite(1, buf1); //write humidity with percent sign to virtual pin 1 
Blynk.virtualWrite(3, buf2); //write temp with degree sign to virtual pin 3
Blynk.virtualWrite(4, buf3); //write fahrenheit heat index with degree sign to virtual pin 4

just FYI, this is where the special characters are written to blynk, and this has been working very well for maybe a couple months or so.

Yeah. Just comment those lines.

//Blynk.virtualWrite(1, buf1);

ok, i think I misunderstood. I will comment them out and test the app in a couple hours. I have tested the removal of just the % sign, see the screenshot above where I removed it, but didn’t think to remove the degree symbols too…

thanks!

commenting out those lines seems to make it connect OK now. I will do some more \ longer testing. just FYI, It seems that sending special characters is causing issues in this new update. I was previously sending this same data OK.

Let me know if you need any more info, and thanks again for helping!

Ok. Good we was able to narrow down the problem. @BlynkAndroidDev did we changed something there?

@bpthomas I understand that it is was working and believe you :slightly_smiling:. The thing is - blynk is evolving very quickly and becomes more and more complex. So it is hard to say where exactly problem is. We will dig more.

1 Like

no problem, i completely understand. I wasn’t complaining, just giving you information to help narrow it down. Thanks for all your help, your service has been excellent! Would it help if I narrowed it down a bit more? I can test the symbols individually see if 1 or the other causes the issue. I don’t mind digging in a bit.