Hello
I had 2 separate projects that are working fine, each project connected to it own ESP8266. I want to combine 2 projects into one ESP8266 so I can add or subtract the value on each project to get a final output.
For example:
project 1 has output value for V1, V2, V3
Project 2 has output value for V7, v8, v9
==> I want the output to be V22 (which V22= V3-V7)
With Blynk you could use the bridge to send the value to one ESP then calculate it in that ESP and send the result to the app. Or if you are using MQTT you could send both values to node Red to calculate there and send the value to the app. The last would require bode red knowledge and a bit of Java to calculate.
I’ve never used Bridge (because I use Node-Red and MQTT instead) but my understanding is that one device will be the receiver. This doesn’t need any Bridge code, other than a BLYNK_WRITE(vPin) which will be triggered when data is sent to it from the other device.
The other device has its’s own Auth code which will be different to the first one (you haven’t shown this in your second sketch, it just says “Put your Blynk local server IP address here”) and the Bridge Auth code which is the Auth code from the first device.
The second device sends data to the first one via the Bridge virtual pin (V23) via a Blynk.virtualWrite(V23, Value) command, which you are doing.
The other issue is that both of your devices valve code which does nothing for the vast majority of the time, because they have a delay(1000) in their void loops, blocking all code execution for one second. Blynk.virtualWrites don’t get processed until a Blynk.run is encountered, and neither do BLYNK_WRITE callbacks.
You’ll need to move the code out of your void loop and into a function that is called with a timer - in both sets of code, if you want this to work correctly.
I have modified my sketch (see above) to make it simpler to troubleshoot but I still ran into the problem as the beginning that the reading on sketch A still not show up in sketch B and the combine reading still wrong.