RPi3 Gateway and Uno R3 node cannot communicate



  • Hello,
    I'm using my RPi3 as a gateway, with HomeAssistant and MQTT installed on it.

    Here is my installation and starting log:

    git clone https://github.com/mysensors/MySensors.git
    
    git checkout development #To avoid a bug of branch master
    
    ./configure --my-transport=nrf24 --my-gateway=mqtt --my-controller-ip-address=127.0.0.1 --my-mqtt-publish-topic-prefix=mysensors-out --my-mqtt-subscribe-topic-prefix=gwtopic --my-mqtt-client-id=khaihuynhgwra
    
    make
    
    ./bin/mysgw -d
    

    Log show that I have connect NRF24L01 successfully to my RPi3 and ready to wait for connection from nodes:

    root@raspberrypi:~/KhaiHuynh/tools/MySensors# ./bin/mysgw -d
    mysgw: Starting gateway...
    mysgw: Protocol version - 2.2.0-beta
    mysgw: MCO:BGN:INIT GW,CP=RNNGL---,VER=2.2.0-beta
    mysgw: TSF:LRT:OK
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0
    mysgw: TSM:INIT:TSP OK
    mysgw: TSM:INIT:GW MODE
    mysgw: TSM:READY:ID=0,PAR=0,DIS=0
    mysgw: MCO:REG:NOT NEEDED
    mysgw: MCO:BGN:STP
    mysgw: MCO:BGN:INIT OK,TSP=1
    mysgw: Attempting MQTT connection...
    mysgw: connected to 127.0.0.1
    mysgw: MQTT connected
    mysgw: Sending message on topic: mysensors-out/0/255/0/0/18
    

    Then I moved into wiring and upload my Uno R3 node with motion sensor. Here is my code

    
    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    #include <MySensors.h>
    
    unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define CHILD_ID 1   // Id of the sensor child
    #define MY_RF24_PA_LEVEL RF24_PA_HIGH
    
    // Initialize motion message
    MyMessage msg(CHILD_ID, V_TRIPPED);
    
    void setup()
    {
      pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
    }
    
    void presentation()
    {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Motion Sensor", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID, S_MOTION);
    }
    
    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
    
      // Sleep until interrupt comes in on motion sensor. Send update every two minute.
      sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
    }
    
    

    And log after upload these code lines, it shows that UNO R3 cannot find its parent (gateway):

    176490 TSM:FAIL:RE-INIT
    176 __  __       ____
    |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
    | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
            |___/                      2.2.0-beta
    
    17 MCO:BGN:INIT NODE,CP=RNNNA---,VER=2.2.0-beta
    26 TSM:INIT
    27 TSF:WUR:MS=0
    34 TSM:INIT:TSP OK
    36 TSM:FPAR
    38 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    2048 !TSM:FPAR:NO REPLY
    2050 TSM:FPAR
    2052 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    4060 !TSM:FPAR:NO REPLY
    4062 TSM:FPAR
    4064 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    6072 !TSM:FPAR:NO REPLY
    6074 TSM:FPAR
    6076 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    8084 !TSM:FPAR:FAIL
    8085 TSM:FAIL:CNT=1
    8087 TSM:FAIL:DIS
    8089 TSF:TDI:TSL
    18091 TSM:FAIL:RE-INIT
    18093 TSM:INIT
    18100 TSM:INIT:TSP OK
    18102 TSM:FPAR
    18104 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    20112 !TSM:FPAR:NO REPLY
    20114 TSM:FPAR
    20116 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    22124 !TSM:FPAR:NO REPLY
    22126 TSM:FPAR
    22128 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    24136 !TSM:FPAR:NO REPLY
    24138 TSM:FPAR
    24140 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    26148 !TSM:FPAR:FAIL
    26149 TSM:FAIL:CNT=2
    26151 TSM:FAIL:DIS
    26153 TSF:TDI:TSL
    36157 TSM:FAIL:RE-INIT
    36159 TSM:INIT
    36166 TSM:INIT:TSP OK
    36168 TSM:FPAR
    36170 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    38178 !TSM:FPAR:NO REPLY
    38180 TSM:FPAR
    38182 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    40192 !TSM:FPAR:NO REPLY
    40194 TSM:FPAR
    40196 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    42204 !TSM:FPAR:NO REPLY
    42206 TSM:FPAR
    42208 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    44216 !TSM:FPAR:FAIL
    44217 TSM:FAIL:CNT=3
    44219 TSM:FAIL:DIS
    44221 TSF:TDI:TSL
    

    And there is nothing happend in Gateway.

    root@raspberrypi:~/KhaiHuynh/tools/MySensors# ./bin/mysgw -d
    mysgw: Starting gateway...
    mysgw: Protocol version - 2.2.0-beta
    mysgw: MCO:BGN:INIT GW,CP=RNNGL---,VER=2.2.0-beta
    mysgw: TSF:LRT:OK
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0
    mysgw: TSM:INIT:TSP OK
    mysgw: TSM:INIT:GW MODE
    mysgw: TSM:READY:ID=0,PAR=0,DIS=0
    mysgw: MCO:REG:NOT NEEDED
    mysgw: MCO:BGN:STP
    mysgw: MCO:BGN:INIT OK,TSP=1
    mysgw: Attempting MQTT connection...
    mysgw: connected to 127.0.0.1
    mysgw: MQTT connected
    mysgw: Sending message on topic: mysensors-out/0/255/0/0/18
    

    Does anybody here have an idea about this?

    After searching and scan through forum, I see that we also need
    The gateway has a 47µF cap and the nodes use 10uF
    But I have not done that. Is it the problem?

    Thank,


  • Mod

    @Huỳnh-Minh-Khải the node is missing the node ID. About the caps, any value above 4.7uF should do. Also you may try to lower the output power of the nrf24. How far away is the node from the gateway?


  • Mod

    @Huỳnh-Minh-Khải yes the capacitors are needed. Without them, communication often fails.

    Another note: this define:

    #define MY_RF24_PA_LEVEL RF24_PA_HIGH
    

    will only have an effect if placed before include <MySensors.h>
    But higher power means higher current draw which might make communication worse so I suggest you don't enable it until you know your nodes are working.



  • @gohan said in RPi3 Gateway and Uno R3 node cannot communicate:

    @Huỳnh-Minh-Khải the node is missing the node ID. About the caps, any value above 4.7uF should do. Also you may try to lower the output power of the nrf24. How far away is the node from the gateway?

    I have added 100uF, 16V to both NRF24L01 on node and raspberry, but the issus still there 😞
    I put both of them on my table (distance about 20 cm). I also tried to move them far away, but still the same



  • @mfalkvidd said in RPi3 Gateway and Uno R3 node cannot communicate:

    But higher power means higher current draw which might make communication worse so I suggest you don't enable it until you know your nodes are working.

    Thank you, I changed my gateway channel to 25, MY_RF24_PA_LEVEL to RF24_PA_LOW on both of gateway and node. This is my updated code:

    
    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    #define MY_RF24_PA_LEVEL RF24_PA_LOW
    #define MY_RF24_CHANNEL 25
    #define MY_NODE_ID 1
    #define MY_PARENT_NODE_ID 0
    unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define CHILD_ID 1   // Id of the sensor child
    
    #include <MySensors.h>
    #include <SPI.h>
    
    
    // Initialize motion message
    MyMessage msg(CHILD_ID, V_TRIPPED);
    
    void setup()
    {
      pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
    }
    
    void presentation()
    {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Motion Sensor", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID, S_MOTION);
    }
    
    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
    
      // Sleep until interrupt comes in on motion sensor. Send update every two minute.
      sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
    }
    
    
    

    But the issue still the same. Look at RPi3 log, I see nothing indicates that my node is able to comunicate to GW, like both of them in difference worlds.



  • After soldering capacitors into NLF24L01, it's now working :D. Thank for all your supports!


  • Mod

    @Huỳnh-Minh-Khải great work. Thanks for reporting back!


 

408
Online

7.9k
Users

8.8k
Topics

93.8k
Posts