[Solved] Blynk app stuck on older value

Hello everyone,

I’ve encountered a strange problem in the Blynk app: some values in widget are stuck on older value, some are 10 hours older and some are 7 days older.
Here are some screenshot to clarify the situation

Here the widget read 23.06°C, but the real value is 1.44°C (Read from the http api), the history graph is correct, also the firmware version is wrong I’m currently on 0.3.5 and the widget read 0.3.0.
All widget are set as ‘PUSH’ reading frequency but set them to fixed time (250ms or 1s) doesn’t seem to change anything.

I’m using http api to write the value on the local server (version 0.21.4), I’m also using the latest app version (2.5.0).

Here’s the code that run on an Esp-8266

#define myName "/ext/file.bin"
#define version "0.3.5"

//pin da collegare
//EN 5V
//GPIO0 5V
//GPIO15 0V

#define numL 200

#include <Arduino.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SimpleTimer.h>

//--**ADC
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads;  /* Use this for the 16-bit version */
/*
static const uint8_t D0   = 16;
static const uint8_t D1   = 5;
static const uint8_t D2   = 4;
static const uint8_t D3   = 0;
static const uint8_t D4   = 2;
static const uint8_t D5   = 14;
static const uint8_t D6   = 12;
static const uint8_t D7   = 13;
static const uint8_t D8   = 15;
static const uint8_t D9   = 3;
static const uint8_t D10  = 1;*/
//--**ADC

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>

int ONE_WIRE_BUS = 12;

//int sda = 13;
//int scl = 15;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

SimpleTimer timer;


char ssid[] = SSID_PREP;
char pass[] = PASS_PREP;
char auth[] = AUTH_PREP;
const char server_upd[] = SERVER_UPD_PREP;
const char server_blynk[] = SERVER_BLYNK_PREP;
const int port_upd = PORT_UPD_PREP;
const int port_blynk = PORT_BLYNK_PREP;
const int port_telegram = PORT_TELEGRAM_PREP;

const double Kc = 0.183105487805;

int sendData(float, String);
int sendData(int, String);
int sendVersion(String);
double readVin();
void sendlowbat();

void spedisciDati();
void aggiornaDormi();

int flag = 0;

long t1 = 0;
long t2 = 0;

const long deltat = 1000*15;
const long deltat2 = 1000*2;

const long tsleep = 1000*1000*60*5;

long timedmax = 0;
long timedmin = 99999;

int sleepState = 0;

void setup(){

  Serial.begin(115200);
  Serial.setDebugOutput(true);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);

  while (WiFi.status() != WL_CONNECTED)  {
    delay(100);
    Serial.println(WiFi.status());
  }

  sensors.begin();

  timer.setInterval(deltat2, spedisciDati);
  timer.setInterval(deltat, aggiornaDormi);

  //--**ADC
  ads.begin(D2, D1);
  ads.setGain(GAIN_ONE);//+-4.096V
  //--**ADC

  if(readVin() < 3.5) {
    sendlowbat();
  }

}

int sended = 0;

void loop() {

  timer.run();

}

int sendData(float value, String pin){
  HTTPClient http;
  String payload = String("[\n") + value + String("\n]");
  Serial.println("\nstart:");
  Serial.println(http.begin(server_blynk, port_blynk, String("/") + auth + String("/pin/") + pin));
  http.addHeader("Content-Type", "application/json");//String("/") + auth + String("/pin/") + pin
  int codice_ritorno = http.sendRequest("PUT",(uint8_t *) payload.c_str(), payload.length());
  Serial.println(codice_ritorno);
  Serial.println(http.writeToStream(&Serial));
  http.end();
  Serial.println();
  return codice_ritorno;
}

int sendData(int value, String pin){
  HTTPClient http;
  String payload = String("[\n") + value + String("\n]");
  Serial.println("\nstart:");
  Serial.println(http.begin(server_blynk, port_blynk, String("/") + auth + String("/pin/") + pin));
  http.addHeader("Content-Type", "application/json");//String("/") + auth + String("/pin/") + pin
  int codice_ritorno = http.sendRequest("PUT",(uint8_t *) payload.c_str(), payload.length());
  Serial.println(codice_ritorno);
  Serial.println(http.writeToStream(&Serial));
  http.end();
  return codice_ritorno;
}

int sendVersion(String pin){
  HTTPClient http;
  String payload = String("[\n\"") + String(version) + String("\"\n]");
  Serial.println("\nstart:");
  Serial.println(http.begin(server_blynk, port_blynk, String("/") + auth + String("/pin/") + pin));
  http.addHeader("Content-Type", "application/json");//String("/") + auth + String("/pin/") + pin
  Serial.println(http.sendRequest("PUT",(uint8_t *) payload.c_str(), payload.length()));
  Serial.println(http.writeToStream(&Serial));
  http.end();
}

void sendlowbat(){
  HTTPClient http;
  Serial.println("\nstart:");
  Serial.println(http.begin(server_blynk, port_telegram, String("/lowbat") ));
  int codice_ritorno = http.GET();
  Serial.println(codice_ritorno);
  Serial.println(http.writeToStream(&Serial));
  http.end();
}

double readVin(){
  long sum = 0;
  for(int i = 0; i < numL;i++){
    int val = analogRead(A0);
    sum += val;
  }
  double avg = (double) sum / numL;
  double vin = (double) avg / (Kc * 1024.0f);
  return vin;
}

void aggiornaDormi(){
  if((WiFi.status() == WL_CONNECTED)) {    // wait for WiFi connection
    t_httpUpdate_return ret = ESPhttpUpdate.update(server_upd, port_upd, myName, version);

    switch(ret) {
      case HTTP_UPDATE_FAILED:
        Serial.printf("HTTP_UPDATE_FAILD Error (%d): %s\n", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
        break;

      case HTTP_UPDATE_NO_UPDATES:
        Serial.println("HTTP_UPDATE_NO_UPDATES\n");
        break;

      case HTTP_UPDATE_OK:
        Serial.println("HTTP_UPDATE_OK\n");
        break;
    }
  }
  ESP.deepSleep(tsleep);
}

void spedisciDati(){
  sensors.requestTemperatures();

  double vin = readVin();
  float temp = sensors.getTempCByIndex(0);
  Serial.println(temp);

  sendData(int(millis()/1000), "V1");
  sendData(float(vin), "V0");
  sendVersion("V3");
  sendData(flag, "V4");

  int16_t adc0, adc1, adc2, adc3;
  float Voltage0,Voltage1,Voltage2,Voltage3;

  adc0 = ads.readADC_SingleEnded(0);
  Voltage0 = (adc0 * 0.125)/1000;
  delay(20);

  adc1 = ads.readADC_SingleEnded(1);
  Voltage1 = (adc1 * 0.125)/1000;
  delay(20);

  adc2 = ads.readADC_SingleEnded(2);
  Voltage2 = (adc2 * 0.125)/1000;
  delay(20);

  adc3 = ads.readADC_SingleEnded(3);
  Voltage3 = (adc3 * 0.125)/1000;
  delay(20);

  adc0 = ads.readADC_SingleEnded(0);
  Voltage0 = (adc0 * 0.125)/1000;
  delay(20);

  adc1 = ads.readADC_SingleEnded(1);
  Voltage1 = (adc1 * 0.125)/1000;
  delay(20);

  adc2 = ads.readADC_SingleEnded(2);
  Voltage2 = (adc2 * 0.125)/1000;
  delay(20);

  adc3 = ads.readADC_SingleEnded(3);
  Voltage3 = (adc3 * 0.125)/1000;
  delay(20);

  Voltage2 *= 5.31969;

  Serial.print("(V Solare) AIN0: "); Serial.print(adc0);Serial.print("\tVin0: "); Serial.println(Voltage0);
  Serial.print("(V in) AIN0: "); Serial.print(adc2);Serial.print("\tVin0: "); Serial.println(Voltage2);
  Serial.print("(V LM35) AIN0: "); Serial.print(adc3);Serial.print("\tVin0: "); Serial.println(Voltage3);

  sendData(Voltage0, "V5");

  sendData(Voltage1, "V8");

  sendData(Voltage2, "V6");

  sendData(Voltage3, "V7");

  if(temp > -120){
    int send_code = sendData(temp, "V2");
    if(send_code == 200){
      sended = 1;
      aggiornaDormi();
    }
  }

  Serial.printf("Connection status: %d\n", WiFi.status());
}

Am I doing somethings wrong?

Thanks to everyone, bye bye
Andrea.

Hello. Could you please change value from browser? Does it update state of widget?

Hello, if the app is closed the widget is not updated, but if the app is opened the widget will be updated.
When I close the the app and reopen it the value fall back to the old value, example:

The widget that keep the version number has the value 0.3.0 -> I update the value via browser using http://ip:port/auth/update/v3?value=1234 -> I open the app and the version is 0.3.0 -> I update another time the value via browser and this time the widget change to the test value (1234) -> I close and reopen the app and the value return 0.3.0

Thank for the help.
Andrea

@hkbristol please try this build - https://github.com/blynkkk/blynk-server/releases/download/v0.21.4/server-0.22.0-SNAPSHOT.jar does that help?

I have seen that also and it was a signal strenght problem in my case… graph has a correct value but labeled displays not. I just change the nodeMCU near to the router and voila! It works!

Try it…

@Dmitriy I’ve installed the 0.22.0-snapshot but the problem stay.
@darkmoon I’ve many Esp-8266 and a nodeMcu but all have the same problem.

Thnaks you all.
Andrea.

@hkbristol Do you use multiple devices?

@Dmitriy Yes i use multiple devices, but the problem showed up some month ago in old build.

Andrea.

@hkbristol ok, one more suggestion - https://github.com/blynkkk/blynk-server/releases/download/v0.21.4/server-0.22.0-SNAPSHOT_2.jar

@Dmitriy Yay, now works perfectly, thank you guys, keep works on this beautiful project.

Andrea.

@hkbristol I made quick release with this fix - https://github.com/blynkkk/blynk-server/releases/download/v0.21.5/server-0.21.5.jar. Please confirm everything is fine there too.

@Dmitriy Server 0.21.5 works great

Andrea.

1 Like