Node is not using repeater to talk to gateway
-
@tekka Still weird:
99 says 0203 so 02 is going via 03?? Why?
0 says 0263 so 02 is going via 99?247 22.08.2016 22:15:24 TX 99 - Repeater Node N/A C_INTERNAL NO I_DEBUG R 250 22.08.2016 22:15:24 RX 99 - Repeater Node INTERNAL C_INTERNAL NO I_DEBUG 0000 252 22.08.2016 22:15:24 RX 99 - Repeater Node INTERNAL C_INTERNAL NO I_DEBUG 0203 254 22.08.2016 22:15:24 RX 99 - Repeater Node INTERNAL C_INTERNAL NO I_DEBUG 0404 255 22.08.2016 22:15:50 TX 0 - Gateway N/A C_INTERNAL NO I_DEBUG R 257 22.08.2016 22:15:50 RX 0 - Gateway INTERNAL C_INTERNAL NO I_DEBUG 0263 259 22.08.2016 22:15:50 RX 0 - Gateway INTERNAL C_INTERNAL NO I_DEBUG 6363 -
@tekka Still weird:
99 says 0203 so 02 is going via 03?? Why?
0 says 0263 so 02 is going via 99?247 22.08.2016 22:15:24 TX 99 - Repeater Node N/A C_INTERNAL NO I_DEBUG R 250 22.08.2016 22:15:24 RX 99 - Repeater Node INTERNAL C_INTERNAL NO I_DEBUG 0000 252 22.08.2016 22:15:24 RX 99 - Repeater Node INTERNAL C_INTERNAL NO I_DEBUG 0203 254 22.08.2016 22:15:24 RX 99 - Repeater Node INTERNAL C_INTERNAL NO I_DEBUG 0404 255 22.08.2016 22:15:50 TX 0 - Gateway N/A C_INTERNAL NO I_DEBUG R 257 22.08.2016 22:15:50 RX 0 - Gateway INTERNAL C_INTERNAL NO I_DEBUG 0263 259 22.08.2016 22:15:50 RX 0 - Gateway INTERNAL C_INTERNAL NO I_DEBUG 6363 -
@karl261 But you wrote:
Btw, all is on 2.0.0.
mixed setups are not advisable (and not supported). Please update if possible.
-
@karl261 Can you add this to node 4 (this is the relayed one?):
#define MY_PARENT_NODE_ID 99 #define MY_PARENT_NODE_IS_STATIC@tekka I can add it to node 30 right now. It is also supposed to be relayed. In fact this is why I did start this thread in the first place, I had no luck with these two lines. Will try again.
Oooohhh, there is a mistake further up: I am talking about node 30, and wrote node 3. That is incorrect. Let's see if I can edit. That is why you were asking about the 1.5...
-
@karl261 Can you add this to node 4 (this is the relayed one?):
#define MY_PARENT_NODE_ID 99 #define MY_PARENT_NODE_IS_STATIC -
@tekka Node 30 does still not care about the two lines. It is sending direct.
It also does not send back any routing table. Maybe because it is sleeping most of the time? -
@karl261 If it's not defined as repeater, it won't have a routing table. And yes, sleeping nodes do not listen for incoming traffic. But still, if GW and node 99 are up, it should prefer 99 - can you show me the log of node 30 during booting?
@tekka Now it seems to work.
But I recompiled, because I had MY_DEBUG commented out. Somehow there is something wrong with debug...
Starting sensor (RNNNA-, 2.0.0) TSM:INIT TSM:RADIO:OK TSP:ASSIGNID:OK (ID=30) TSM:FPAR TSP:MSG:SEND 30-30-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSP:MSG:READ 3-3-30 s=255,c=3,t=8,pt=1,l=1,sg=0:1 TSP:MSG:FPAR RES (ID=3, dist=1) TSP:MSG:PAR OK (ID=3, dist=2) TSP:MSG:READ 99-99-30 s=255,c=3,t=8,pt=1,l=1,sg=0:1 TSP:MSG:FPAR RES (ID=99, dist=1) TSP:MSG:FPAR (PPAR FOUND) TSP:MSG:PAR OK (ID=99, dist=2) TSM:FPAR:OK TSM:ID TSM:CHKID:OK (ID=30) TSM:UPL TSP:PING:SEND (dest=0) TSP:MSG:SEND 30-30-99-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1 TSP:MSG:READ 0-0-30 s=255,c=3,t=8,pt=1,l=1,sg=0:0 TSP:MSG:FPAR RES (ID=0, dist=0) TSP:MSG:READ 0-99-30 s=255,c=3,t=25,pt=1,l=1,sg=0:2 TSP:MSG:PONG RECV (hops=2) TSP:CHKUPL:OK TSM:UPL:OK TSM:READY Serial started Voltage: 3289 mV TSP:MSG:SEND 30-30-99-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100 TSP:MSG:SEND 30-30-99-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=ok:2.0.0 TSP:MSG:SEND 30-30-99-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=ok:99 TSP:MSG:READ 0-99-30 s=255,c=3,t=15,pt=6,l=2,sg=0:0100 TSP:MSG:SEND 30-30-99-0 s=255,c=3,t=11,pt=0,l=15,sg=0,ft=0,st=ok:EgTmpHumBat5min TSP:MSG:SEND 30-30-99-0 s=255,c=3,t=12,pt=0,l=10,sg=0,ft=0,st=ok:1.0 151106 TSP:MSG:SEND 30-30-99-0 s=0,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=ok: TSP:MSG:SEND 30-30-99-0 s=1,c=0,t=7,pt=0,l=0,sg=0,ft=0,st=ok: Node and 2 children presented. Request registration... TSP:MSG:SEND 30-30-99-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2 TSP:MSG:READ 0-99-30 s=255,c=3,t=27,pt=1,l=1,sg=0:1 Node registration=1 Init complete, id=30, parent=99, distance=2, registration=1 T: 21.59 TempDiff :121.59 TSP:MSG:SEND 30-30-99-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:21.6 T sent! H: 81 HumDiff :181.00 TSP:MSG:SEND 30-30-99-0 s=1,c=1,t=1,pt=2,l=2,sg=0,ft=0,st=ok:81 H sent! Battery voltage: 3279 mV Battery percent: 98 % TSP:MSG:SEND 30-30-99-0 s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=ok:98 T: 21.61 TempDiff :0.02 H: 81 HumDiff :0.00 -
@tekka Now it seems to work.
But I recompiled, because I had MY_DEBUG commented out. Somehow there is something wrong with debug...
Starting sensor (RNNNA-, 2.0.0) TSM:INIT TSM:RADIO:OK TSP:ASSIGNID:OK (ID=30) TSM:FPAR TSP:MSG:SEND 30-30-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSP:MSG:READ 3-3-30 s=255,c=3,t=8,pt=1,l=1,sg=0:1 TSP:MSG:FPAR RES (ID=3, dist=1) TSP:MSG:PAR OK (ID=3, dist=2) TSP:MSG:READ 99-99-30 s=255,c=3,t=8,pt=1,l=1,sg=0:1 TSP:MSG:FPAR RES (ID=99, dist=1) TSP:MSG:FPAR (PPAR FOUND) TSP:MSG:PAR OK (ID=99, dist=2) TSM:FPAR:OK TSM:ID TSM:CHKID:OK (ID=30) TSM:UPL TSP:PING:SEND (dest=0) TSP:MSG:SEND 30-30-99-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1 TSP:MSG:READ 0-0-30 s=255,c=3,t=8,pt=1,l=1,sg=0:0 TSP:MSG:FPAR RES (ID=0, dist=0) TSP:MSG:READ 0-99-30 s=255,c=3,t=25,pt=1,l=1,sg=0:2 TSP:MSG:PONG RECV (hops=2) TSP:CHKUPL:OK TSM:UPL:OK TSM:READY Serial started Voltage: 3289 mV TSP:MSG:SEND 30-30-99-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100 TSP:MSG:SEND 30-30-99-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=ok:2.0.0 TSP:MSG:SEND 30-30-99-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=ok:99 TSP:MSG:READ 0-99-30 s=255,c=3,t=15,pt=6,l=2,sg=0:0100 TSP:MSG:SEND 30-30-99-0 s=255,c=3,t=11,pt=0,l=15,sg=0,ft=0,st=ok:EgTmpHumBat5min TSP:MSG:SEND 30-30-99-0 s=255,c=3,t=12,pt=0,l=10,sg=0,ft=0,st=ok:1.0 151106 TSP:MSG:SEND 30-30-99-0 s=0,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=ok: TSP:MSG:SEND 30-30-99-0 s=1,c=0,t=7,pt=0,l=0,sg=0,ft=0,st=ok: Node and 2 children presented. Request registration... TSP:MSG:SEND 30-30-99-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2 TSP:MSG:READ 0-99-30 s=255,c=3,t=27,pt=1,l=1,sg=0:1 Node registration=1 Init complete, id=30, parent=99, distance=2, registration=1 T: 21.59 TempDiff :121.59 TSP:MSG:SEND 30-30-99-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:21.6 T sent! H: 81 HumDiff :181.00 TSP:MSG:SEND 30-30-99-0 s=1,c=1,t=1,pt=2,l=2,sg=0,ft=0,st=ok:81 H sent! Battery voltage: 3279 mV Battery percent: 98 % TSP:MSG:SEND 30-30-99-0 s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=ok:98 T: 21.61 TempDiff :0.02 H: 81 HumDiff :0.00 -
@tekka Well, yes, I added the two lines you suggested, re-compiled, and then it was not using the 99. And also some posts above, I had these weird messages transmitted 6-7 times, see logs. This happend while MY_DEBUG was commented out.
Hm, I can re-upload the sketch and see if this is reproducible.
-
@tekka Well, yes, I added the two lines you suggested, re-compiled, and then it was not using the 99. And also some posts above, I had these weird messages transmitted 6-7 times, see logs. This happend while MY_DEBUG was commented out.
Hm, I can re-upload the sketch and see if this is reproducible.
-
@tekka No, it seems to work as expected. Any idea why I am getting this "fail" line?
23.08.2016 00:30:33 RX 0;255;3;0;9;TSP:MSG:READ 30-30-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 23.08.2016 00:30:33 RX 0;255;3;0;9;TSP:MSG:BC 23.08.2016 00:30:33 RX 0;255;3;0;9;TSP:MSG:FPAR REQ (sender=30) 23.08.2016 00:30:33 RX 0;255;3;0;9;TSP:CHKUPL:OK 23.08.2016 00:30:33 RX 0;255;3;0;9;TSP:MSG:GWL OK 23.08.2016 00:30:34 RX 0;255;3;0;9;TSP:MSG:SEND 0-0-30-30 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=ok:0 23.08.2016 00:30:34 RX 0;255;3;0;9;TSP:MSG:READ 99-99-0 s=255,c=3,t=24,pt=1,l=1,sg=0:1 23.08.2016 00:30:34 RX 0;255;3;0;9;TSP:MSG:PINGED (ID=99, hops=1) 23.08.2016 00:30:34 RX 0;255;3;0;9;TSP:MSG:SEND 0-0-99-99 s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=ok:1 23.08.2016 00:30:34 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=255,c=3,t=24,pt=1,l=1,sg=0:2 23.08.2016 00:30:34 RX 0;255;3;0;9;TSP:MSG:PINGED (ID=30, hops=2) 23.08.2016 00:30:34 RX 0;255;3;0;9;TSP:MSG:SEND 0-0-99-30 s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=ok:1 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=255,c=3,t=15,pt=6,l=2,sg=0:0100 23.08.2016 00:30:35 RX 0;255;3;0;9;!TSP:MSG:SEND 0-0-99-30 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=fail:0100 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=255,c=3,t=6,pt=1,l=1,sg=0:99 23.08.2016 00:30:35 RX 30;255;3;0;6;99 23.08.2016 00:30:35 TX 30;255;3;0;6;M 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:SEND 0-0-99-30 s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=ok:M 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=255,c=3,t=12,pt=0,l=10,sg=0:1.0 151106 23.08.2016 00:30:35 RX 30;255;3;0;12;1.0 151106 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=1,c=0,t=7,pt=0,l=0,sg=0: 23.08.2016 00:30:35 RX 30;1;0;0;7; 23.08.2016 00:30:35 DEBUG Update child id=1, type=S_HUM 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=255,c=3,t=26,pt=1,l=1,sg=0:2 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:SEND 0-0-99-30 s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=ok:1 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=0,c=1,t=0,pt=7,l=5,sg=0:24.3 23.08.2016 00:30:35 RX 30;0;1;0;0;24.3 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=1,c=1,t=1,pt=2,l=2,sg=0:73 23.08.2016 00:30:35 RX 30;1;1;0;1;73 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=255,c=3,t=0,pt=1,l=1,sg=0:91 23.08.2016 00:30:35 RX 30;255;3;0;0;91 -
@tekka No, it seems to work as expected. Any idea why I am getting this "fail" line?
23.08.2016 00:30:33 RX 0;255;3;0;9;TSP:MSG:READ 30-30-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 23.08.2016 00:30:33 RX 0;255;3;0;9;TSP:MSG:BC 23.08.2016 00:30:33 RX 0;255;3;0;9;TSP:MSG:FPAR REQ (sender=30) 23.08.2016 00:30:33 RX 0;255;3;0;9;TSP:CHKUPL:OK 23.08.2016 00:30:33 RX 0;255;3;0;9;TSP:MSG:GWL OK 23.08.2016 00:30:34 RX 0;255;3;0;9;TSP:MSG:SEND 0-0-30-30 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=ok:0 23.08.2016 00:30:34 RX 0;255;3;0;9;TSP:MSG:READ 99-99-0 s=255,c=3,t=24,pt=1,l=1,sg=0:1 23.08.2016 00:30:34 RX 0;255;3;0;9;TSP:MSG:PINGED (ID=99, hops=1) 23.08.2016 00:30:34 RX 0;255;3;0;9;TSP:MSG:SEND 0-0-99-99 s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=ok:1 23.08.2016 00:30:34 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=255,c=3,t=24,pt=1,l=1,sg=0:2 23.08.2016 00:30:34 RX 0;255;3;0;9;TSP:MSG:PINGED (ID=30, hops=2) 23.08.2016 00:30:34 RX 0;255;3;0;9;TSP:MSG:SEND 0-0-99-30 s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=ok:1 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=255,c=3,t=15,pt=6,l=2,sg=0:0100 23.08.2016 00:30:35 RX 0;255;3;0;9;!TSP:MSG:SEND 0-0-99-30 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=fail:0100 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=255,c=3,t=6,pt=1,l=1,sg=0:99 23.08.2016 00:30:35 RX 30;255;3;0;6;99 23.08.2016 00:30:35 TX 30;255;3;0;6;M 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:SEND 0-0-99-30 s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=ok:M 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=255,c=3,t=12,pt=0,l=10,sg=0:1.0 151106 23.08.2016 00:30:35 RX 30;255;3;0;12;1.0 151106 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=1,c=0,t=7,pt=0,l=0,sg=0: 23.08.2016 00:30:35 RX 30;1;0;0;7; 23.08.2016 00:30:35 DEBUG Update child id=1, type=S_HUM 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=255,c=3,t=26,pt=1,l=1,sg=0:2 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:SEND 0-0-99-30 s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=ok:1 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=0,c=1,t=0,pt=7,l=5,sg=0:24.3 23.08.2016 00:30:35 RX 30;0;1;0;0;24.3 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=1,c=1,t=1,pt=2,l=2,sg=0:73 23.08.2016 00:30:35 RX 30;1;1;0;1;73 23.08.2016 00:30:35 RX 0;255;3;0;9;TSP:MSG:READ 30-99-0 s=255,c=3,t=0,pt=1,l=1,sg=0:91 23.08.2016 00:30:35 RX 30;255;3;0;0;91 -
@tekka yes, these fails come and go, I see them all the time, but not at the same place necessarily. The logs posted above show plenty of them.
I don't understand this radio trouble.,the distances between the nodes are not long. The radios are all connected using all tricks, the relay is a nrf24+pa+lna which is located in a good location... Maybe all radios are crap? There is only one wifi network and it is not very busy... It's my own. Maybe I should change the channel? 110 or so sounds good. I am using default now. Power is set to max for all nodes, the nrf24+pa+lna is shielded from itself, I put small antenna extensions on the normal ones after @petewill, they all have nice caps, gw and repeater have excellent power sources, ...
I found a script how to test nrf radios... Maybe I should try that?
If I was going to buy new radios, just to try, which ones are the best???
Edit: Hm, I think if I use antennas, it really helps if they all point into the same direction. Like all horizontal or all vertical. Which would make sens, wouldn't it?
-
@tekka But now I found something: the repeater sketch does not work, if MY_DEBUG is commented out. I tried several times forth and back. On the gw I get the output below.
0;255;3;0;9;TSP:MSG:READ 99-99-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;TSP:MSG:BC 0;255;3;0;9;TSP:MSG:FPAR REQ (sender=99) 0;255;3;0;9;TSP:CHKUPL:OK 0;255;3;0;9;TSP:MSG:GWL OK 0;255;3;0;9;!TSP:MSG:SEND 0-0-99-99 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=fail:0 0;255;3;0;9;TSP:MSG:READ 99-99-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;TSP:MSG:BC 0;255;3;0;9;TSP:MSG:FPAR REQ (sender=99) 0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL) 0;255;3;0;9;TSP:MSG:GWL OK 0;255;3;0;9;!TSP:MSG:SEND 0-0-99-99 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=fail:0 -
@tekka But now I found something: the repeater sketch does not work, if MY_DEBUG is commented out. I tried several times forth and back. On the gw I get the output below.
0;255;3;0;9;TSP:MSG:READ 99-99-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;TSP:MSG:BC 0;255;3;0;9;TSP:MSG:FPAR REQ (sender=99) 0;255;3;0;9;TSP:CHKUPL:OK 0;255;3;0;9;TSP:MSG:GWL OK 0;255;3;0;9;!TSP:MSG:SEND 0-0-99-99 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=fail:0 0;255;3;0;9;TSP:MSG:READ 99-99-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;TSP:MSG:BC 0;255;3;0;9;TSP:MSG:FPAR REQ (sender=99) 0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL) 0;255;3;0;9;TSP:MSG:GWL OK 0;255;3;0;9;!TSP:MSG:SEND 0-0-99-99 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=fail:0 -
@karl261 That's weird - I've just tested that scenario and everything is fine here.
Can you add an indicator in loop() to make sure the repeater sketch is running? Also, what board are you using as repeater and how do you power it?@tekka I will try this a bit later, thanks.
Right now I am going crazy, the node is again not using the defined parent. Did I overlook something in the sketch?Starting sensor (RNNNA-, 2.0.0) TSM:INIT TSM:RADIO:OK TSP:ASSIGNID:OK (ID=4) TSM:FPAR TSP:MSG:SEND 4-4-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSP:MSG:READ 0-0-4 s=255,c=3,t=8,pt=1,l=1,sg=0:0 TSP:MSG:FPAR RES (ID=0, dist=0) TSP:MSG:PAR OK (ID=0, dist=1) TSM:FPAR:OK TSM:ID TSM:CHKID:OK (ID=4) TSM:UPL TSP:PING:SEND (dest=0) TSP:MSG:SEND 4-4-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1 TSP:MSG:READ 0-0-4 s=255,c=3,t=25,pt=1,l=1,sg=0:1 TSP:MSG:PONG RECV (hops=1) TSP:CHKUPL:OK TSM:UPL:OK TSM:READY BME init success! TSP:MSG:SEND 4-4-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100 TSP:MSG:SEND 4-4-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=ok:2.0.0 TSP:MSG:SEND 4-4-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=ok:0 TSP:MSG:READ 0-0-4 s=255,c=3,t=15,pt=6,l=2,sg=0:0100 TSP:MSG:SEND 4-4-0-0 s=255,c=3,t=11,pt=0,l=13,sg=0,ft=0,st=ok:OUTSIDE P&T&H TSP:MSG:SEND 4-4-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=ok:1.2 TSP:MSG:SEND 4-4-0-0 s=1,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=ok: TSP:MSG:SEND 4-4-0-0 s=2,c=0,t=8,pt=0,l=0,sg=0,ft=0,st=ok: TSP:MSG:SEND 4-4-0-0 s=0,c=0,t=7,pt=0,l=0,sg=0,ft=0,st=ok: Request registration... TSP:MSG:SEND 4-4-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2 TSP:MSG:READ 0-0-4 s=255,c=3,t=27,pt=1,l=1,sg=0:1 Node registration=1 Init complete, id=4, parent=0, distance=1, registration=1 TSP:MSG:SEND 4-4-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:24.7 TSP:MSG:SEND 4-4-0-0 s=0,c=1,t=1,pt=2,l=2,sg=0,ft=0,st=ok:57 TSP:MSG:SEND 4-4-0-0 s=2,c=1,t=4,pt=7,l=5,sg=0,ft=0,st=ok:1012.9 TSP:MSG:SEND 4-4-0-0 s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=ok:115/* Sketch with Si7021 and battery monitoring. by m26872, 20151109 */ // Enable and select radio type attached #define MY_RADIO_NRF24 #define MY_PARENT_NODE_ID 99 #define MY_PARENT_NODE_IS_STATIC #define MY_NODE_ID 4 #define MY_DEBUG #define MY_BAUD_RATE 9600 #include <MySensors.h> #include <Wire.h> //This library allows you to communicate with I2C / TWI devices. #include <SPI.h> #include <RunningAverage.h> #include <SparkFunBME280.h> //#define DEBUG // local debug #ifdef DEBUG #define DEBUG_SERIAL(x) Serial.begin(x) #define DEBUG_PRINT(x) Serial.print(x) #define DEBUG_PRINTLN(x) Serial.println(x) #else #define DEBUG_SERIAL(x) #define DEBUG_PRINT(x) #define DEBUG_PRINTLN(x) #endif // #define NODE_ID 132 // <<<<<<<<<<<<<<<<<<<<<<<<<<< Enter Node_ID #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_PRES 2 #define SLEEP_TIME 15000 // 15s for DEBUG //#define SLEEP_TIME 300000 // 5 min #define FORCE_TRANSMIT_CYCLE 36 // 5min*12=1/hour, 5min*36=1/3hour #define BATTERY_REPORT_CYCLE 2880 // Once per 5min => 12*24*7 = 2016 (one report/week) #define VMIN 1900 #define VMAX 3300 #define HUMI_TRANSMIT_THRESHOLD 3.0 // THRESHOLD tells how much the value should have changed since last time it was transmitted. #define TEMP_TRANSMIT_THRESHOLD 0.5 #define PRES_TRANSMIT_THRESHOLD 1.0 #define AVERAGES 2 int batteryReportCounter = BATTERY_REPORT_CYCLE - 1; // to make it report the first time. int measureCount = 0; float lastTemperature = -100; float lastPressure = -100; int lastHumidity = -100; RunningAverage raHum(AVERAGES); //SI7021 humiditySensor; BME280 mySensor; // MyMessage to controler MyMessage msgTemp(CHILD_ID_TEMP,V_TEMP); // Initialize temperature message MyMessage msgHum(CHILD_ID_HUM,V_HUM); MyMessage msgPres(CHILD_ID_PRES,V_PRESSURE); void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("OUTSIDE P&T&H", "1.2"); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_PRES, S_BARO); present(CHILD_ID_HUM, S_HUM); DEBUG_PRINT("Node and "); DEBUG_PRINTLN("3 children presented."); } void setup() { DEBUG_SERIAL(9600); // <<<<<<<<<<<<<<<<<<<<<<<<<< Note BAUD_RATE in MySensors.h DEBUG_PRINTLN("Serial started"); DEBUG_PRINT("Voltage: "); DEBUG_PRINT(readVcc()); DEBUG_PRINTLN(" mV"); /* delay(500); DEBUG_PRINT("Internal temp: "); DEBUG_PRINT(GetInternalTemp()); // Probably not calibrated. Just to print something. DEBUG_PRINTLN(" *C"); */ mySensor.settings.commInterface = I2C_MODE; mySensor.settings.I2CAddress = 0x77; //runMode can be: // 0, Sleep mode // 1 or 2, Forced mode // 3, Normal mode mySensor.settings.runMode = 1; mySensor.settings.filter = 0; mySensor.settings.tempOverSample = 1; mySensor.settings.pressOverSample = 1; mySensor.settings.humidOverSample = 1; delay(500); // Allow time for radio if power used as reset if (!mySensor.begin()) { Serial.println("BME init failed!"); while (1); } else Serial.println("BME init success!"); raHum.clear(); } void loop() { measureCount ++; batteryReportCounter ++; bool forceTransmit = false; if (measureCount > FORCE_TRANSMIT_CYCLE) { forceTransmit = true; } mySensor.begin(); sendTempHumidityMeasurements(forceTransmit); /* // Read and print internal temp float temperature0 = static_cast<float>(static_cast<int>((GetInternalTemp()+0.5) * 10.)) / 10.; DEBUG_PRINT("Internal Temp: "); DEBUG_PRINT(temperature0); DEBUG_PRINTLN(" *C"); */ // Check battery if (batteryReportCounter >= BATTERY_REPORT_CYCLE) { long batteryVolt = readVcc(); DEBUG_PRINT("Battery voltage: "); DEBUG_PRINT(batteryVolt); DEBUG_PRINTLN(" mV"); uint8_t batteryPcnt = constrain(map(batteryVolt,VMIN,VMAX,0,100),0,255); DEBUG_PRINT("Battery percent: "); DEBUG_PRINT(batteryPcnt); DEBUG_PRINTLN(" %"); sendBatteryLevel(batteryPcnt); batteryReportCounter = 0; } sleep(SLEEP_TIME); //if(isTransportOK()){ // sleep(SLEEP_TIME); // transport is OK, node can sleep // } // else { // wait(5000); // transport is not operational, allow the transport layer to fix this // } } // function for reading Vcc by reading 1.1V reference against AVcc. Based from http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/ // To calibrate reading replace 1125300L with scale_constant = internal1.1Ref * 1023 * 1000, where internal1.1Ref = 1.1 * Vcc1 (per voltmeter) / Vcc2 (per readVcc() function) long readVcc() { // set the reference to Vcc and the measurement to the internal 1.1V reference ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); delay(2); // Wait for Vref to settle ADCSRA |= _BV(ADSC); // Start conversion while (bit_is_set(ADCSRA,ADSC)); // measuring uint8_t low = ADCL; // must read ADCL first - it then locks ADCH uint8_t high = ADCH; // unlocks both long result = (high<<8) | low; result = 1134738L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000 return result; // Vcc in millivolts } // function for reading internal temp. From http://playground.arduino.cc/Main/InternalTemperatureSensor double GetInternalTemp(void) { // (Both double and float are 4 byte in most arduino implementation) unsigned int wADC; double t; // The internal temperature has to be used with the internal reference of 1.1V. Channel 8 can not be selected with the analogRead function yet. ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3)); // Set the internal reference and mux. ADCSRA |= _BV(ADEN); // enable the ADC delay(20); // wait for voltages to become stable. ADCSRA |= _BV(ADSC); // Start the ADC while (bit_is_set(ADCSRA,ADSC)); // Detect end-of-conversion wADC = ADCW; // Reading register "ADCW" takes care of how to read ADCL and ADCH. t = (wADC - 88.0 ) / 1.0; // The default offset is 324.31. return (t); // The returned temperature in degrees Celcius. } /********************************************* * * Sends temperature and humidity from Si7021 sensor * Parameters * - force : Forces transmission of a value (even if it's the same as previous measurement) *********************************************/ void sendTempHumidityMeasurements(bool force) { bool tx = force; float temperature = mySensor.readTempC(); DEBUG_PRINT("T: ");DEBUG_PRINTLN(temperature); float diffTemp = abs(lastTemperature - temperature); DEBUG_PRINT(F("TempDiff :"));DEBUG_PRINTLN(diffTemp); if (diffTemp > TEMP_TRANSMIT_THRESHOLD || tx) { send(msgTemp.set(temperature,1)); lastTemperature = temperature; measureCount = 0; DEBUG_PRINTLN("T sent!"); } int humidity = mySensor.readFloatHumidity(); DEBUG_PRINT("H: ");DEBUG_PRINTLN(humidity); raHum.addValue(humidity); humidity = raHum.getAverage(); // MA sample imply reasonable fast sample frequency float diffHum = abs(lastHumidity - humidity); DEBUG_PRINT(F("HumDiff :"));DEBUG_PRINTLN(diffHum); if (diffHum > HUMI_TRANSMIT_THRESHOLD || tx) { send(msgHum.set(humidity)); lastHumidity = humidity; measureCount = 0; DEBUG_PRINTLN("H sent!"); } float pressure = mySensor.readFloatPressure()/100.0; DEBUG_PRINT("P: ");DEBUG_PRINTLN(pressure); float diffPress = abs(lastPressure - pressure); DEBUG_PRINT(F("PressDiff :"));DEBUG_PRINTLN(diffPress); if (diffPress > PRES_TRANSMIT_THRESHOLD || tx) { send(msgPres.set(pressure,1)); lastPressure = pressure; measureCount = 0; DEBUG_PRINTLN("P sent!"); } }