I create another project about sensor MQ2 connected to Blynk
Details :
• My hardware: esp8266
• Samsung A14 (Android 13, One UI Core 5)
• Indonesia
• Blynk at version 1.3.2
This is my program:
You shouldn’t be using delays in your void loop, or have Blynk.virtualWrite in your void loop.
Instead, you should be using BlynkTimer to call a separate function once every second.
Read this for more info…
Implement this change and post your updated code, then I’ll show you how to overcome your virtual LED issue.
You clearly didn’t understand the “keep your void loop clean” tutorial, and you seem to have grabbed some random code from another sketch which has nothing to do with what you’re trying to achieve.
Revert to your original code then follow the “keep your void loop clean” tutorial properly.
So that you invert the signal by sending the logical opposite of the value that is read from the sensor. This is done using the logical NOT operator, which is an exclamation mark (!).
Your new code would look like this…
Blynk.virtualWrite(V1, !data); // sending inverted sensor value to Blynk app
Option 2 is to change the V1 datastream in the Blynk console so that instead of having a min/max value of 0/1 you invert this with a min/max value of 1/0
Option 1 (using the logical NOT operator in your code is probably the neatest solution.