Hi everyone,
I’m still learning my way around the Blynk product. I have a Maker account with one device reporting three attributes - weight, temperature, and humidity. I’ve been watching it for a few days through the serial console and Blynk Dashboard. I noticed a strange behavior this evening with the data. I have the serial console side by side with my Blynk dashboard and I noticed that my weight reading was absolutely wrong for a time (0 - .5kg instead of the 1.85 kg or so it is actually reading). It corrected after about 45 minutes and then went back to a displaying a value that was not being reported by my code. I only have one device, and as far as I can tell it’s only this one value from a virtual pin acting like this. Can anyone think of a reason for this? Data is reported every minute. Any help is appreciated.
I have the same issue with gauge, the value isn’t updated until I refreshed my browser.
Add a label next to the gauge, you can see the difference.
Unfortunately, this is a logged value in Blynk, not missing values or values that haven’t updated yet.
I think you’ve misunderstood what @Blynk_Coeur was saying.
Refresh your web browser to see if this makes the gauge widgets show the correct readings.
Pete.
1 Like
Refreshing the page does ensure the latest values are shown in the widgets, but sometimes they’re wrong. Last night they were wrong for a period of 45 minutes. The histogram and widgets reveal incorrect values, but just for this one sensor as far as I can tell. My weight sensor, as shown in the photos, consistently reads 1.85 or so. However, the values in the hisogram shows a history of zeros and other values, like .56 that were not the values reported by the device.
Hello @whughesiii @Blynk_Coeur. Not reproduced for me. Gauge widget has support updating value in real time.
Please provide more details. Datastream settings, gauge widget settings.
Values not updating immediately? Or after some time spent on the device dashboard?
1 Like
Here are screenshots of back to back “bad” readings. We’re not just talking about the widget, but the data that is actually logged. Since the platform is structured such that I can’t see the payload without a top tier account, I can’t tell what’s actually coming across the wire to see if it’s something in my code or something in Blynk.
On the left you’ll see my serial console with the “Weight:” value taken and reported. On the right you’ll see the histogram values and live data widget. One is zero and the other is .56. Neither of those values were taken or reported. I was careful to use the last two events as of the time I took these screenshots to show the weirdness.
I do not use the loop() function, everything is ran in the setup section because I use deep sleep.
setup {....
float weight = getWeight();
Serial.print("Weight: ");
Serial.println(weight);
sendDataToBlynk();
delay(2000);
BlynkEdgent.run();
Blynk.disconnect();
Serial.println("Disconnecting Blynk...");
WiFi.disconnect();
Serial.println("Disconnecting WiFi...");
// Go to deep sleep after readings are done
Serial.println("Going to deep sleep");
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
esp_deep_sleep_start();
}
This code is declared in the global section of the main ino:
void sendDataToBlynk() {
float weight = getWeight();
Serial.println("Sending data to Blynk");
Blynk.virtualWrite(WEIGHT_VPIN, weight);
if (temperature != 0.0 && humidity != 0.0) {
Blynk.virtualWrite(TEMPERATURE_VPIN, temperature);
Blynk.virtualWrite(HUMIDITY_VPIN, humidity);
}
}
I have all my scale functions in a header file. This is an HX711 using the latest library from Rob Tillart. Here is the relevant code:
HX711 myScale;
...
float getWeight() {
return myScale.get_units(10); //takes ten consecutive readings to ensure stable value
}
Further data:
global variable for weight pin code:
#define WEIGHT_VPIN V0
The values update immediately or after a page refresh, but they’re not what the device is reporting.
Also, the issue started around 8pm Eastern last night. Before that everything has been solid and consistent for about a week. My last code revision (which made no changes to the weight reading portion) was at 3:25pm yesterday.
@whughesiii Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
Copy and paste these if you can’t find the correct symbol on your keyboard.
Pete.
1 Like
Done - thanks for pointing that out!
@whughesiii Thanks. We need to investigate this case.
1 Like
I don’t think your values are actually getting sent to Blynk before your device goes to sleep.
First of all, starting with the Edgent example isn’t the choice I’d make.
Secondly, the 2 second delay after calling sendDataToBlynk()
doesn’t achieve anything. What you should be doing is executing Blynk.run()
, or in your case BlynkEdgent.run()
, several times before going to sleep.
Pete.
So why would a datapoint be sent at all? If the data isn’t being sent I’d expect the last value shipped to be displayed, not a zero or completely incorrect number not sent.
Also, two other values are being sent after this value, and they make it through just fine as far as I can tell.
The delay of 2 seconds is to give time to send the data before disconnecting. Are you saying that the Blynkedgent.run will hold the thread open until it completes? If so, I can remove that delay and that would make me happy.
All the 2 second delay does is stop all processor execution for 2 seconds. Instead you should be triggering the Blynk library to talk to the server, by executing BlynkEdgent.run()
If you don’t like my advice then feel free to ignore it.
Pete.
//If you don’t like my advice then feel free to ignore it.//
That came across kind of brusque. I’m happy to take advice, and as I said, I’m happy to remove that delay provided the BlynkEdgent.run() function is able to complete synchronously before moving on to the rest of the code.
In my code above, weight gets sent first, then temperature and humidity. These screenshots show the values in my serial console vs the values in my dashboard. You’ll see the temperature and humidity values are perfectly in sync, while the weight values is completely incorrect.
That’s because I gave you some advice, and instead of explaining why you’d chosen the Edgent route and undertaking to try my suggestion, you seem to dismiss the advice.
That’s fine by me, I’m just trying to be of assistance, but if you don’t want to take my suggestions onboard you’re free to ignore them.
Pete.
You just said what you wouldn’t do, not what I should do. Unfortunately, I don’t have the coding chops to strip it down. And again, I’m more than happy and eager to accept advice for being more efficient in my coding.
That being said, I still have a question in need of an answer - and that is why two of the three values come through perfectly fine, but the third value doesn’t? And was there a change made last night around 8pm on the Blynk side that might possibly be involved? If I could see my payloads, I could easily troubleshoot this myself, but I’m in the dark.
I’d suggest you re-read what I said.
You need far more “coding chops” as you call it to get deep sleep working well with Edgent than you do withy a basic non-Edgent static provisioning sketch (of which there are many in the library examples).
I think if you move to a better structured solution (maybe taking-onboard the advice I gave you earlier) the question will answer itself.
Pete.