That function typically only runs when the slider is changed. If your slider is moved when the device is asleep it will be missed. What you wan to do is, when the device wakes up, and is connected to BLYNK, use a Blynk.syncVirtual(V20); to trigger the associated BLYNK_WRITE(V20) function.
You need to call Blynk.syncVirtual(V20) to get the 'BLYNK_WRITE(V20)callback function to 'fire'. This needs to be done after you have established a connection to Blynk, and probably needs to be followed by aBlynk.run()` command.
i think you made my day. slowly i get there where i want to be. So after adding the syncVirtual and Blynk.run code. i get the serial output correctly with the value of the slider. Great! So i put the code before my calculation function. But the Sync runs after my calculation function and after sending the “wrong” data to Blynk. Like you say i need to establish a connection to Blynk (before i calculate and update blynk). how can i do this? (sorry if its a stupid question, iam an absolut beginner)
You could try restructuring your code. Add the BLYNK_CONNECTED function to call the Blynk.syncVirtual(20) command, and call your calculation function at the end of the BLYNK_WRITE(V20)
SensorHoehe = param.asInt();
Serial.print("V20 Slider value is: ");
calculationFunction(); //except use your functions name
So that’s what establishes your Blynk connection, and your code wont progress beyond that point until you have a connection to your WiFi and the Blynk server. If you are calculating the wrong values then the problem is with your code structure. @Toro_Blanco’s recommendation is a good one.
However, using Blynk.begin is a bad move for projects that use deep sleep, especially if your device is battery powered.
If you device can’t connect to either WiFi or the Blynk server - for whatever reason - then the code execution will stop at Blynk.begin and your device will never go back to sleep; flattening the battery in the process.
thank you for your answers.
i think restructuring the code is a good idea. Iam doing that right know. Iam not really familiar of this kind of programming. i know only a bit scripting.
I keep u updated the next days!