Unable to send message from gw to sensor(!TSF:MSG:SEND)



  • Problem: Everything seems to work correctly except the fact that I'm unable to send any message of my own.
    Goal: Sending any given message to my sensor.
    What I need: Guidance in how I can debug this.

    After setting everything up I telnet to port 5003 on my PI and get greeted by the gateway after which I see data passing by:

    0;255;3;0;14;Gateway startup complete.
    0;255;0;0;18;2.2.0-rc.1
    2;255;1;0;16;1
    2;255;1;0;16;0
    2;255;1;0;16;1
    2;255;1;0;16;0
    2;255;1;0;16;1
    2;255;1;0;16;0
    2;255;1;0;16;1
    2;255;1;0;16;0
    

    As soon as I send my own message 2;255;1;0;16;2 I'm seeing the following in the logs of my gateway:

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

    At this point I don't know what I can do to debug this any further. I've tried switching power sources with and without the voltage converter and capacitors but all to no avail.


    Some logs for insight are added to the bottom of this post:

    • #1: Gateway starting up
    • #2: Gateway registering sensor
    • #3: Sensor registering to gateway

    My Gateway hardware consist of:

    • 1x Raspberry Pi 1B
    • 1x nrf24l01
    • 1x LD1337 voltage regulator
    • 2x 100uF capacitor (on 5v and 3.3v side of the regulator)
    • 1x 47uF capacitor (on the VCC/GND of the nrf24)

    and has been configured with the following:

    $ git clone https://github.com/mysensors/MySensors.git --branch development
    $ cd MySensors
    $ sudo ./configure --my-transport=nrf24
    ...
    $ make
    ...
    $ sudo ./bin/mysgw -d
    

    Note: current commit I'm on is 682a6b0.

    My Sensor hardware consists of:

    • Arduino Uno r3
    • 1x nrf24l01
    • 1x 47uF capacitor (on the VCC/GND of the nrf24)

    and has been configured with the following:

    #define MY_DEBUG
    #define MY_RADIO_NRF24
    
    #include <SPI.h>
    #include <MySensors.h>
    
    #define OPEN 1
    #define CLOSE 0
    
    MyMessage msg(MY_NODE_ID, V_TRIPPED);
    
    uint8_t value = OPEN;
    
    void presentation()
    {
        present(MY_NODE_ID, S_DOOR);
    }
    
    void loop()
    {
        value = value == OPEN ? CLOSE : OPEN;
        send(msg.set(value));
        sleep(10000);
    }
    
    void receive(const MyMessage &message)
    {
      Serial.println("Received message from the big giant head!");
    }
    

    Logs:
    #1: Gateway starting up

    $ sudo ./bin/mysgw -d
    mysgw: Starting gateway...
    mysgw: Protocol version - 2.2.0-rc.1
    mysgw: MCO:BGN:INIT GW,CP=RNNGL---,VER=2.2.0-rc.1
    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: Listening for connections on 0.0.0.0:5003
    mysgw: MCO:BGN:STP
    mysgw: MCO:BGN:INIT OK,TSP=1
    

    #2: Gateway registering sensor

    mysgw: TSF:MSG:READ,2-2-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    mysgw: TSF:MSG:BC
    mysgw: TSF:MSG:FPAR REQ,ID=2
    mysgw: TSF:CKU:OK,FCTRL
    mysgw: TSF:MSG:GWL OK
    mysgw: TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    mysgw: TSF:MSG:READ,2-2-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
    mysgw: TSF:MSG:PINGED,ID=2,HP=1
    mysgw: TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1
    mysgw: TSF:MSG:READ,2-2-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    mysgw: TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    mysgw: TSF:MSG:READ,2-2-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.1.1
    mysgw: TSF:MSG:READ,2-2-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0
    mysgw: TSF:MSG:READ,2-2-0,s=255,c=0,t=0,pt=0,l=5,sg=0:2.1.1
    mysgw: TSF:MSG:READ,2-2-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
    mysgw: TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
    mysgw: TSF:MSG:READ,2-2-0,s=255,c=1,t=16,pt=1,l=1,sg=0:0
    

    #3: Sensor registering to gateway

    0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
    3 TSM:INIT
    4 TSF:WUR:MS=0
    11 TSM:INIT:TSP OK
    13 TSF:SID:OK,ID=2
    14 TSM:FPAR
    51 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    177 TSF:MSG:READ,0-0-2,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    182 TSF:MSG:FPAR OK,ID=0,D=1
    2058 TSM:FPAR:OK
    2059 TSM:ID
    2060 TSM:ID:OK
    2062 TSM:UPL
    2065 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2077 TSF:MSG:READ,0-0-2,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2082 TSF:MSG:PONG RECV,HP=1
    2085 TSM:UPL:OK
    2086 TSM:READY:ID=2,PAR=0,DIS=1
    2092 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    2098 TSF:MSG:READ,0-0-2,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    2105 TSF:MSG:SEND,2-2-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
    2114 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
    4121 TSF:MSG:SEND,2-2-0-0,s=255,c=0,t=0,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
    4128 MCO:REG:REQ
    4131 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
    4137 TSF:MSG:READ,0-0-2,s=255,c=3,t=27,pt=1,l=1,sg=0:1
    4143 MCO:PIM:NODE REG=1
    4145 MCO:BGN:INIT OK,TSP=1
    4149 TSF:MSG:SEND,2-2-0-0,s=255,c=1,t=16,pt=1,l=1,sg=0,ft=0,st=OK:0
    

  • Mod

    @sPENKMAN thanks for a very detailed description of the problem.

    In loop of the sensor node, there is a sleep.
    When a node is sleeping, it can not receive any messages. So that's probably why no message is received, and why the gateway doesn't receive an acknowledgement.

    Replace the sleep with wait and see if that helps.


  • Mod

    A side note: You might be aware of this already, but in the code, the node id (MY_NODE_ID) is re-used for the child id of the node (in present(MY_NODE_ID, S_DOOR)).

    While MY_NODE_ID is just a number, reusing the same define for the child id can cause logical problems later on.

    My guess is that the example on https://www.mysensors.org/download/sensor_api_20#sensor-nodes misled you. I'll see if we can make that example clearer.



  • I knew it had to be something simple, but damn! Thank you so much, now I finally can go forward with my project. Fun times ahead!

    I was aware that the node/child id setup wasn't quite in order but as it didn't stood in my way I hadn't made the effort to change it from the example.


  • Mod

    I've updated the example. Hopefully it is more clear now.


Log in to reply
 

Suggested Topics

  • 3
  • 2
  • 1
  • 6

1
Online

11.4k
Users

11.1k
Topics

112.7k
Posts