Sending from node fails first time, but second is ok



  • Hello,
    First mysensors build here,
    I set up a Wemos D1 mini + nrf24 gateway and an Arduino Uno + nrf24 node, its only a test setup. Both use a 47uf capacitor between radio vcc and gnd.
    On the gateway Im using ESP8266 Ethernet gateway, On the arduino Im using the motion sensor sketch.

    Presentation of the node looks fine, so it seems communication is ok.
    I tried for a few hours to send a message to gateway and it was giving error all the time

    !TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=NACK:0
    

    no acknowledge it seems.

    After hours of fiddling discovered if I send the message twice, the first time fails but the second is sent and received by the gateway ok.

    45351 !TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=NACK:0
    45360 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=1,st=OK:0
    

    It is totally consistent so I can reliably send messages but I dont know why I have to send the messages twice

    void loop()
    {
    	// Read digital motion value
    	bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
    
    	Serial.println(tripped);
    	send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
            send(msg.set(tripped?"1":"0"));  // Send tripped value to gw     <----------Second time ¿?
    
    	// Sleep until interrupt comes in on motion sensor. Send update every two minute.
    	sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
    }
    

    Any idea why is this happening?


  • Mod

    Welcome to the forum @alex-garcia!
    The problem is probably the same as discussed in https://forum.mysensors.org/topic/9655/delay-after-tsf-tri-tsb/14

    Solution: use development version of MySensors or wait for the next release.



  • Indeed it looks like the same problem.

    Thank you!


  • Mod

    @alex-garcia you're welcome 🙂
    In case you need a workaround: add wait(200) after the sleep.


Log in to reply
 

Suggested Topics

7
Online

11.4k
Users

11.1k
Topics

112.7k
Posts