What happens if you do if(value == 1) instead of if(value) ? Could be some weird Arduino bug.
I don’t think that would be the case, because MY_VP
is actively toggling between 0 and 1.
Another thing to try is using “V27” instead of 27 to indicate you are using virtual pins, not sure if it matters, but at least it makes it more clear to read.
Did you btw at least try the if thing? If you don’t try you’ll never know.
I have display value widget that can read Uno A’s V5, and it shows that V5 is constantly toggling between 1 and 0. I guess it pretty much confirms that the conditional was indeed executed.
Do you mind if I ask you some favor? Could you test both of my code above with your boards? Just to confirm that they really work.
Really weird. I have two ESP boards so I can test it for you later today, that’s no problem
I’ve been testing it and I have some good news and bad news, it works flawlessly for me. The value on the second ESP/Arduino keeps changing.
Did you add the Bridge Widget on the Dashboard of Arduino A?
Yes, I did.
Can I see your code? Both of them?
I copy/pasted yours, with exception of the connection library because I use a wifi chip. Other than that, it’s exactly the same, so I’m a bit puzzled. The only think I can think of is that it’s not working with USB. Do you have the option to test via Wifi or Ethernet?
I just bought 2 Wemos D1R2 boards, and now I’m re-running those two code.
Still not working, somehow.
Do you projects work fine separate? E.g. can you turn a virtual LED on/off on each project by itself? At least we can establish the Blynk connection is in working order with that.
That is exactly what I did. Make sure every board is properly connected before trying to establish bridge between them.
Do I have to use separate PC to program them?
No, that should make no difference.
Can you enable the Debug on both Wemos boards and post the output here?
Sorry, it’s been awhile…
Code for Sender:
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
char auth[] = "e3796764647e44b29d460222e23a4c38";
char ssid[] = "tenziB-v2";
char pass[] = "xxxxxx";
WidgetBridge bridge1(V1);
SimpleTimer timer1;
static bool value = true;
void setup(){
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
while(!Blynk.connect());
timer1.setInterval(1000L, blynkAnotherDevice);
pinMode(D0, OUTPUT);
}
void loop(){
Blynk.run();
timer1.run();
}
BLYNK_WRITE(V0){
int pinData1 = param.asInt();
digitalWrite(D0, pinData1);
}
BLYNK_CONNECTED(){
BLYNK_LOG("Preparing to bridge...");
bridge1.setAuthToken("696738ee42eb4cccac194f249631bb14");
BLYNK_LOG("Bridge done.");
}
void blynkAnotherDevice(){
if(value){
BLYNK_LOG("Send 1 to B");
bridge1.virtualWrite(V5, 1);
}
else{
BLYNK_LOG("Send 0 to B");
bridge1.virtualWrite(V5, 0);
}
value = !value;
}
Code for Receiver:
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "696738ee42eb4cccac194f249631bb14";
char ssid[] = "tenziB-v2";
char pass[] = "xxxxxx";
void setup(){
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
while(!Blynk.connect());
pinMode(D0, OUTPUT);
pinMode(D1, OUTPUT);
}
void loop(){
Blynk.run();
}
BLYNK_WRITE(V0){
int pinData1 = param.asInt();
digitalWrite(D0, pinData1);
}
BLYNK_WRITE(V5){
int pinData2 = param.asInt();
digitalWrite(D1, pinData2);
}
BLYNK_WRITE(V1){
int pinData3 = param.asInt();
digitalWrite(D1, pinData3);
}
And here’s the output shown in Serial Monitor.
Sender:
ŠH�lè‰h¶¬¬xIÅ$ø[249] Connecting to tenziB-v2
[1752] Connected to WiFi
[1752] IP: 17.8.45.10
[1752] Blynk v0.4.0 on Arduino
[5001] Connecting to blynk-cloud.com:8442
[5049] <[02|00|01|00] e3796764647e44b29d460222e23a4c38
[5079] >[00|00|01|00]È
[5079] Ready (ping: 1ms).
[5079] <[11|00|01|00]Gver[00]0.4.0[00]h-beat[00]10[00]buff-in[00]256[00]dev[00]Arduino[00]build[00]Nov 7 2016 09:21:06[00]
[5186] Preparing to bridge...
[5191] <[0F|00|02|00]$1[00]i[00]696738ee42eb4cccac194f249631bb14
[5288] Bridge done.
[10080] Connecting to blynk-cloud.com:8442
[10123] <[02|00|01|00] e3796764647e44b29d460222e23a4c38
[10157] >[00|00|01|00]È
[10157] Ready (ping: 4ms).
[10157] <[11|00|03|00]Gver[00]0.4.0[00]h-beat[00]10[00]buff-in[00]256[00]dev[00]Arduino[00]build[00]Nov 7 2016 09:21:06[00]
[10267] Preparing to bridge...
[10272] <[0F|00|04|00]$1[00]i[00]696738ee42eb4cccac194f249631bb14
[10369] Bridge done.
[10369] >[00|00|03|00]È
[10391] >[00|00|04|00]È
[11369] Send 1 to B
[11369] <[0F|00|05|00|08]1[00]vw[00]5[00]1
[11399] >[00|00|05|00|07]
[12369] Send 0 to B
[12369] <[0F|00|06|00|08]1[00]vw[00]5[00]0
[12399] >[00|00|06|00|07]
[13369] Send 1 to B
[13369] <[0F|00|07|00|08]1[00]vw[00]5[00]1
[13398] >[00|00|07|00|07]
[14369] Send 0 to B
[14369] <[0F|00|08|00|08]1[00]vw[00]5[00]0
[14398] >[00|00|08|00|07]
[15369] Send 1 to B
[15369] <[0F|00|09|00|08]1[00]vw[00]5[00]1
[15398] >[00|00|09|00|07]
[16369] Send 0 to B
[16369] <[0F|00|0A|00|08]1[00]vw[00]5[00]0
[16398] >[00|00|0A|00|07]
[17369] Send 1 to B
[17369] <[0F|00|0B|00|08]1[00]vw[00]5[00]1
[17397] >[00|00|0B|00|07]
[18369] Send 0 to B
[18369] <[0F|00|0C|00|08]1[00]vw[00]5[00]0
[18398] >[00|00|0C|00|07]
[19369] Send 1 to B
[19369] <[0F|00|0D|00|08]1[00]vw[00]5[00]1
[19399] >[00|00|0D|00|07]
[20369] Send 0 to B
[20369] <[0F|00|0E|00|08]1[00]vw[00]5[00]0
[20398] >[00|00|0E|00|07]
[21369] Send 1 to B
[21369] <[0F|00|0F|00|08]1[00]vw[00]5[00]1
[21397] >[00|00|0F|00|07]
[22369] Send 0 to B
[22369] <[0F|00|10|00|08]1[00]vw[00]5[00]0
[22398] >[00|00|10|00|07]
[23369] Send 1 to B
[23369] <[0F|00|11|00|08]1[00]vw[00]5[00]1
[23399] >[00|00|11|00|07]
[24369] Send 0 to B
[24369] <[0F|00|12|00|08]1[00]vw[00]5[00]0
[24398] >[00|00|12|00|07]
[25369] Send 1 to B
[25369] <[0F|00|13|00|08]1[00]vw[00]5[00]1
[25398] >[00|00|13|00|07]
[26369] Send 0 to B
[26369] <[0F|00|14|00|08]1[00]vw[00]5[00]0
[26399] >[00|00|14|00|07]
[27369] Send 1 to B
[27369] <[0F|00|15|00|08]1[00]vw[00]5[00]1
[27397] >[00|00|15|00|07]
[28369] Send 0 to B
[28369] <[0F|00|16|00|08]1[00]vw[00]5[00]0
[28398] >[00|00|16|00|07]
[29369] Send 1 to B
[29369] <[0F|00|17|00|08]1[00]vw[00]5[00]1
[29399] >[00|00|17|00|07]
[30369] Send 0 to B
[30369] <[0F|00|18|00|08]1[00]vw[00]5[00]0
[30398] >[00|00|18|00|07]
[31369] Send 1 to B
[31369] <[0F|00|19|00|08]1[00]vw[00]5[00]1
[31397] >[00|00|19|00|07]
[32369] Send 0 to B
[32369] <[0F|00|1A|00|08]1[00]vw[00]5[00]0
[32398] >[00|00|1A|00|07]
[33369] Send 1 to B
[33369] <[0F|00|1B|00|08]1[00]vw[00]5[00]1
[33398] >[00|00|1B|00|07]
[34369] Send 0 to B
[34369] <[0F|00|1C|00|08]1[00]vw[00]5[00]0
[34398] >[00|00|1C|00|07]
[35369] Send 1 to B
[35369] <[0F|00|1D|00|08]1[00]vw[00]5[00]1
[35399] >[00|00|1D|00|07]
[36369] Send 0 to B
[36369] <[0F|00|1E|00|08]1[00]vw[00]5[00]0
[36399] >[00|00|1E|00|07]
[37369] Send 1 to B
[37369] <[0F|00|1F|00|08]1[00]vw[00]5[00]1
[37398] >[00|00|1F|00|07]
[38369] Send 0 to B
[38369] <[0F|00] [00|08]1[00]vw[00]5[00]0
[38398] >[00|00] [00|07]
[39369] Send 1 to B
[39369] <[0F|00]![00|08]1[00]vw[00]5[00]1
[39398] >[00|00]![00|07]
[40369] Send 0 to B
[40369] <[0F|00]"[00|08]1[00]vw[00]5[00]0
[40398] >[00|00]"[00|07]
...
Receiver:
sum 0x2d
v3de0c112
~ld
HéÉ쨬l$øx$:Xþû[325] Connecting to tenziB-v2
[2828] Connected to WiFi
[2828] IP: 17.8.45.21
[2828] Blynk v0.4.0 on Arduino
[5001] Connecting to blynk-cloud.com:8442
[5048] <[02|00|01|00] 696738ee42eb4cccac194f249631bb14
[5076] >[00|00|01|00]È
[5076] Ready (ping: 1ms).
[5076] <[11|00|01|00]Gver[00]0.4.0[00]h-beat[00]10[00]buff-in[00]256[00]dev[00]Arduino[00]build[00]Nov 7 2016 09:25:29[00]
[10077] Connecting to blynk-cloud.com:8442
[10122] <[02|00|01|00] 696738ee42eb4cccac194f249631bb14
[10150] >[00|00|01|00]È
[10150] Ready (ping: 1ms).
[10150] <[11|00|02|00]Gver[00]0.4.0[00]h-beat[00]10[00]buff-in[00]256[00]dev[00]Arduino[00]build[00]Nov 7 2016 09:25:29[00]
[10264] >[00|00|02|00]È
[17179] >[14|00];[00|06]
[17179] >vw[00]0[00]1
[17793] >[14|00]<[00|06]
[17793] >vw[00]0[00]0
[20265] <[06|00|03|00|00]
[20292] >[00|00|03|00]È
[30293] <[06|00|04|00|00]
[30321] >[00|00|04|00]È
[40322] <[06|00|05|00|00]
...
[17179] >vw[00]0[00]1
[17793] >[14|00]<[00|06]
[17793] >vw[00]0[00]0
...
17179 - 17793
happenned because my tap on button widget that triggered V0, just to check that my board was indeed connected to Blynk server.
So, what’s the problem?
@Dmitriy @Lichtsignaal
@Costas, @mars - I’m sorry to randomly tag you guys, and for Costas I’ve been following your YouTube channel, and I guess you guys could help me with my problem here.
I’m really at a loss here. I can’t see anything wrong.
Last option I can think of is delete your the project for Board B and generate a new auth token. I can’t really see why it should help, but as an IT guy my last resort is always to reset and start from scratch (be glad it’s not 700 lines of code, lol).
Could you please provide output debug from the same code that you tried the other day the same way I did up above?
I’ll try and make that happen tonight
Thanks, you are awesome! I really appreciate it!
I ask it because I want to make sure about one thing. You see when the board execute bridge1.setAuthToken("696738ee42eb4cccac194f249631bb14");
, the log says <[0F|00|02|00]$1[00]i[00]696738ee42eb4cccac194f249631bb14
. I assume 1
in $1
is the virtual pin number that I’m using to declare WidgetBridge
. Let see when the board execute bridge1.virtualWrite(V5, 0);
, the log says [0F|00|06|00|08]1[00]vw[00]5[00]0
. Do you also notice something different? The $1
is no longer there, now it’s just a 1
. Do you think it would be the case?
I’m not sure about the inner workings of the magic that is Blynk, but at least we can run a compare and see if there are things different
It’s not really a YouTube channel but more a set of brief video clips to inform potential users of some of the new widgets as and when Blynk introduce them. We would like to produce more detailed videos but they are quite time consuming and we have our own projects to work on.
The clips are intended to persuade individuals to join Blynk or to take another look at it if they haven’t seen how it has developed over time. Regular Blynkers will not learn anything from the videos as they are more promotional than informational. Following your comment we have been asked for details of “our Channel” so it is provided here for reference https://www.youtube.com/channel/UCE0ZC7z3FXbexqyT3LIS7Gg
As far as your Bridge problem is concerned all I can say is that, like all widgets, I have tested it and it works. Bridge is not a function we use ourselves so we don’t really have any hands on experience other than our initial testing of the widget.
I think @Lichtsignaal has been through everything we would suggest but if you are still struggling in the coming days we could probably load up your sketches on our hardware and see if any issues occur for us.
Thank you for the reply.
Yeah, @Lichtsignaal was helping a lot narrowing down the problem. I can’t thank enough.
Although until this point I still can’t make it work. So, I can send data from the app to the board, and vice versa, for both of the boards that I’m trying to bridge. From the debugging log we can see that the function for sending data to another board was executed, but the other board never received the data. I think I’ve handled the incoming data well. My question is:
- What would be the problem? Because now I’m completely clueless.
- Would the problem be Network Address Translation (NAT)? Because after all of trials, the one thing that never change is the network. I’m using a network with NAT enabled.
- I wonder what exactly
bridge.virtualWrite()
does. Is it different from whatever the app does when we tap a button that connected to some board’s pin / a virtual one?