[SOLVED] Bridge not reliable?

Hi,

I have 2 devices. Arduino Mega and ESP8266. The Arduino gets from a PIR the information that somebody is moving. If moving is detectet, the Arduino Mega sends via “bridge1.virtualWrite(V31,1)” the “moving” information to the ESP which switches only the LED in the kitchen on (1) or of (0).

When I start the Mega, all works fine. But after a while, the bridge stops working. Then I have to reset the Mega and it starts working for a while.

I made 2 Blink-Apps. One for the Mega where I can see, that the PIR is working correct (moving=App.LED on) and one for the ESP where I can switch manually the LED in the kitchen on or off. Manuylly, I can switch always on or off the light in the kitchen. But via the bridge, it stops working after a while.

Both devices runs stable with no reset or sleep-modes. Means, always connected to the Net.

Anny suggestions?

Greetz, Bernd

Hello. How long does it work before stopping? Is that possible to enable debug on your board to get more info about what is going on? Are you sure your logic doesn’t switch to some execution branch that don’t call bridge anymore?

Deubug from both devices? From the Mega I have debug startet. Do you need the whole debug output? It’s a lot…

In general what we would like to know is - “does your mega actually sends bridge commands or not”.

Here is the debug output of working situation. I think the virtualWrite 31 is important. 1 means LED on and 0 means LED off. I send a copy of debug log if setup stops working. Thanks, Bernd

[17886] <msg 2,1,32
<TOKEN OF MEGA
[22889] Connecting to blynk-cloud.com:8442
[23054] <msg 2,1,32
<TOKEN OF MEGA
[23166] >msg 0,1,200
[23168] Ready (ping: 112ms).
[23169] <msg 17,1,96
<ver 0.3.4 h-beat 10 buff-in 256 dev Arduino cpu ATmega2560 con W5100 build Mar 28 2016 14:09:00 
[23187] <msg 15,2,36
<0 i TOKEN OF ESP8266
[23197] <msg 16,3,5
<vr 31
[23203] >msg 20,29096,9
>pm 13 out
[23288] >msg 0,1,200
[23299] >msg 0,2,200
[23310] >msg 20,3,16
>vw 31 1459167172
[23316] Time sync: OK
[33202] <msg 6,4,0
[33303] >msg 0,4,200
[43204] <msg 6,5,0
[43307] >msg 0,5,200
[53206] <msg 6,6,0
[53307] >msg 0,6,200
[63208] <msg 6,7,0
[63309] >msg 0,7,200
[73210] <msg 6,8,0
[73312] >msg 0,8,200
[82588] <msg 20,9,8
<vw 5 255
[82590] <msg 15,10,9
<0 vw 31 1
[82595] <msg 20,11,51
<vw 1 Node 41 : 4033mV PIR = ON 13:13:51 28.3.2016

[83314] <msg 6,12,0
[83416] >msg 0,12,200
[93316] <msg 6,13,0
[93418] >msg 0,13,200
[103318] <msg 6,14,0
[103421] >msg 0,14,200
[113320] <msg 6,15,0
[113422] >msg 0,15,200
[123322] <msg 6,16,0
[123436] >msg 0,16,200
[133324] <msg 6,17,0
[133427] >msg 0,17,200
[143326] <msg 6,18,0
[143429] >msg 0,18,200
[153328] <msg 6,19,0
[153432] >msg 0,19,200
[163330] <msg 6,20,0
[163433] >msg 0,20,200
[173332] <msg 6,21,0
[173451] >msg 0,21,200
[183334] <msg 6,22,0
[183473] >msg 0,22,200
[187671] <msg 20,23,6
<vw 5 0
[187673] <msg 15,24,9
<0 vw 31 0
[187678] <msg 20,25,52
<vw 1 Node 41 : 4033mV PIR = OFF 13:15:36 28.3.2016

[193474] <msg 6,26,0
[193589] >msg 0,26,200
[203476] <msg 6,27,0
[203578] >msg 0,27,200
[213479] <msg 6,28,0
[213581] >msg 0,28,200
[223481] <msg 6,29,0
[223583] >msg 0,29,200
[233483] <msg 6,30,0
[233594] >msg 0,30,200
[243485] <msg 6,31,0
[243588] >msg 0,31,200
[253487] <msg 6,32,0
[253589] >msg 0,32,200
[263489] <msg 6,33,0
[263591] >msg 0,33,200
[273491] <msg 6,34,0
[273594] >msg 0,34,200
[283493] <msg 6,35,0
[283594] >msg 0,35,200
[293495] <msg 6,36,0
[293598] >msg 0,36,200
[303497] <msg 6,37,0
[303601] >msg 0,37,200
[313499] <msg 6,38,0
[313604] >msg 0,38,200
[323501] <msg 6,39,0
[323603] >msg 0,39,200

Hi, now it runs nearly 2 days befor it stops working. Here are the debug output: At the end you can see that the PIR sends “moving” and “vw 31 1” and “vw 31 0” will be send from the Arduino Mega. But it seems that the ESP8266 did not get the information from the bridge.

Any Idea?

Greetz, Bernd

PS At the beginning of the log is a Hartbeat timeout and the Mega reconnects. There is only the token from the Mega. No token from the ESP8266. Is this ok?

[85248314] <msg 6,8750,0
[85248412] Heartbeat timeout (last in: 85232411)
[85253315] Connecting to blynk-cloud.com:8442
[85259743] <msg 2,1,32
<TOKEN FROM THE MEGA
[85259858] >msg 0,1,200
[85259859] Ready (ping: 113ms).
[85259860] <msg 17,8751,96
<ver 0.3.4 h-beat 10 buff-in 256 dev Arduino cpu ATmega2560 con W5100 build Mar 28 2016 14:09:00 
[85259883] >msg 20,29096,9
>pm 13 out
[85259982] >msg 0,8751,200
[85269882] <msg 6,8752,0
[85269999] >msg 0,8752,200
[85279884] <msg 6,8753,0
[85279986] >msg 0,8753,200
[85289886] <msg 6,8754,0
[85289992] >msg 0,8754,200
[85299888] <msg 6,8755,0
[85299990] >msg 0,8755,200
[85309890] <msg 6,8756,0
[85309993] >msg 0,8756,200
[85312564] <msg 20,8757,8
<vw 3 255
[85312570] <msg 20,8758,9
<vw 4 4033
[85312572] <msg 20,8759,11
<vw 2 17.88#
[85312575] <msg 20,8760,68
<vw 1 Node 51 : 4033mV PIR = ON Temperature 17.88# 6:8:46 30.3.2016

[85319996] <msg 6,8761,0
[85320101] >msg 0,8761,200
[85329998] <msg 6,8762,0
[85330102] >msg 0,8762,200
[85332161] <msg 20,8763,6
<vw 3 0
[85332166] <msg 20,8764,9
<vw 4 4018
[85332168] <msg 20,8765,11
<vw 2 17.88#
[85332171] <msg 20,8766,68
<vw 1 Node 51 : 4018mV PIR = OFF Temperature 17.88# 6:9:5 30.3.2016

[85340104] <msg 6,8767,0
[85340208] >msg 0,8767,200
[85350106] <msg 6,8768,0
[85350208] >msg 0,8768,200
[85360108] <msg 6,8769,0
[85360208] >msg 0,8769,200
[85370110] <msg 6,8770,0
[85370211] >msg 0,8770,200
[85380113] <msg 6,8771,0
[85380213] >msg 0,8771,200
[85390115] <msg 6,8772,0
[85390216] >msg 0,8772,200
[85400117] <msg 6,8773,0
[85400217] >msg 0,8773,200
[85410119] <msg 6,8774,0
[85410221] >msg 0,8774,200
[85420121] <msg 6,8775,0
[85420222] >msg 0,8775,200
[85424509] <msg 20,8776,8
<vw 5 255
[85424512] <msg 15,8777,9
<0 vw 31 1
[85424515] <msg 16,8778,5
<vr 31
[85424521] <msg 20,8779,50
<vw 1 Node 41 : 4033mV PIR = ON 6:10:38 30.3.2016

[85424617] >msg 0,8777,6
[85424620] >msg 20,8778,16
>vw 31 1459314638
[85424626] Time sync: OK
[85434534] <msg 6,8780,0
[85434636] >msg 0,8780,200
[85444536] <msg 6,8781,0
[85444635] >msg 0,8781,200
[85454538] <msg 6,8782,0
[85454640] >msg 0,8782,200
[85464540] <msg 6,8783,0
[85464639] >msg 0,8783,200
[85474542] <msg 6,8784,0
[85474644] >msg 0,8784,200
[85484544] <msg 6,8785,0
[85484646] >msg 0,8785,200
[85494546] <msg 6,8786,0
[85494646] >msg 0,8786,200
[85504548] <msg 6,8787,0
[85504649] >msg 0,8787,200
[85514550] <msg 6,8788,0
[85514651] >msg 0,8788,200
[85524552] <msg 6,8789,0
[85524653] >msg 0,8789,200
[85531936] <msg 20,8790,6
<vw 5 0
[85531938] <msg 15,8791,9
<0 vw 31 0
[85531943] <msg 20,8792,51
<vw 1 Node 41 : 4033mV PIR = OFF 6:12:25 30.3.2016

[85532041] >msg 0,8791,6
[85541955] <msg 6,8793,0
[85542055] >msg 0,8793,200
[85551958] <msg 6,8794,0
[85552058] >msg 0,8794,200
[85561960] <msg 6,8795,0
[85562060] >msg 0,8795,200
[85571962] <msg 6,8796,0
[85572063] >msg 0,8796,200

Please check the Bridge example sketch - it uses BLYNK_CONNECTED() to setup bridge Auth Token.
This technique should help…

It seems solved now. Isue was, that when the connection to the Inet was interrupted, the bridge was broken. I have added

BLYNK_CONNECTED() {
  bridge1.setAuthToken(auth1); //Bridge to ESP8266 LED-Light in kitchen
  Serial.println("Reconnect done!");
}

befor the main loop and now the reconect works fine.

Thanks and greetz, Bernd

1 Like