[Solved] MySensors node not working, Trouble finding parent node



  • Hello,
    Have been having problem trying to get atleast 2 nodes to work properly and I can't seems to figure out the problem/solution.
    I have the Ardunio Uno as my serial gateway connected to the NRF24L01+ radio with a 10uf cap using the 2.0 GatewaySerial example (unchanged and even changed :)).
    Have checked the pins for continuity and voltage drop where everything seems okay.
    On the sensor node side, I have an Arduino Mega 2560 connected to the same NRF24L01+ 2.4GHz radio powered by an external 3.3V regulator.
    On the sensor node am running the default dust sensors code adding just a modification of static node id of 6 and arduino mega CS and CE radio pins

    What I've tried: Swapping the codes between the 2 arduino boards, trying out another type of the nrf24l01+ radio, moving the node further away from the gateway, moving the node and gateway closer, trying other example similar codes for the sensor node.

    I don't have a controller, so I've hard-coded the node ID and parent id with #define MY_NODE_ID 6 and #define MY_PARENT_NODE_ID 0 for the sensor node not sure if that's necessary for the gateway device.
    At the end am hoping to build my own limited controller powered by the Arduino mega or Due incorporating the Nextion touch Display for User Interface.

    So, when I start the two monitors up within a few seconds of each other (gateway first), here's the output of the gateway:

    Gateway log messages
    
    0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;TSM:RADIO:OK
    0;255;3;0;9;TSM:GW MODE
    0;255;3;0;9;TSM:READY
    0;255;3;0;14;Gateway startup complete.
    0;255;0;0;18;2.0.0
    0;255;3;0;9;No registration required
    0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
    0;255;3;0;9;TSP:MSG:READ 6-6-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=6)
    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-6-6 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 6-6-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=6)
    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-6-6 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 6-6-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=6)
    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-6-6 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 6-6-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=6)
    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-6-6 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 6-6-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=6)
    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-6-6 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 6-6-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=6)
    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-6-6 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=fail:0
    0;255;3;0;9;TSP:SANCHK:OK
    0;255;3;0;9;TSP:MSG:READ 6-6-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;TSP:MSG:BC
    

    Output from the Arduino Mega 2560 Sensor node

    NOde Log Message
    
    Starting sensor (RNNNA-, 2.0.0)
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=6)
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    !TSM:FPAR:FAIL
    !TSM:FAILURE
    TSM:PDT
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=6)
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    !TSM:FPAR:FAIL
    !TSM:FAILURE
    TSM:PDT
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=6)
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    !TSM:FPAR:FAIL
    !TSM:FAILURE
    TSM:PDT
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=6)
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    !TSM:FPAR:FAIL
    !TSM:FAILURE
    TSM:PDT
    

    This is the code preview of the dust sensor running on the Arduino Mega 2560

    #define MY_DEBUG
    
    #define MY_RADIO_NRF24
    
    // Optional for Arduino Mega only
    #define MY_RF24_CS_PIN 53
    #define MY_RF24_CE_PIN 40
    
    #define MY_NODE_ID 6
    #define MY_PARENT_NODE_ID 0
    //#define MY_PARENT_NODE_IS_STATIC
    
    #include <SPI.h>
    #include <MySensors.h>  
    
    #define CHILD_ID_DUST 0
    #define DUST_SENSOR_ANALOG_PIN 1
    
    unsigned long SLEEP_TIME = 3*1000; // Sleep time between reads (in milliseconds)
    //VARIABLES
    int val = 0;           // variable to store the value coming from the sensor
    float valDUST =0.0;
    float lastDUST =0.0;
    int samplingTime = 280;
    int deltaTime = 40;
    int sleepTime = 9680;
    float voMeasured = 0;
    float calcVoltage = 0;
    float dustDensity = 0;
    
    MyMessage dustMsg(CHILD_ID_DUST, V_LEVEL);
    
    void presentation() {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Dust Sensor", "1.1");
    
      // Register all sensors to gateway (they will be created as child devices)
      present(CHILD_ID_DUST, S_DUST);  
    }
    
    void loop() {    
      uint16_t voMeasured = analogRead(DUST_SENSOR_ANALOG_PIN);// Get DUST value
    
      // 0 - 5V mapped to 0 - 1023 integer values
      // recover voltage
      calcVoltage = voMeasured * (5.0 / 1024.0);
    
      // linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
      // Chris Nafis (c) 2012
      dustDensity = (0.17 * calcVoltage - 0.1)*1000;
     
      Serial.print("Raw Signal Value (0-1023): ");
      Serial.print(voMeasured);
      
      Serial.print(" - Voltage: ");
      Serial.print(calcVoltage);
      
      Serial.print(" - Dust Density: ");
      Serial.println(dustDensity); // unit: ug/m3
     
      if (ceil(dustDensity) != lastDUST) {
          send(dustMsg.set((int)ceil(dustDensity)));
          lastDUST = ceil(dustDensity);
      }
     
      sleep(SLEEP_TIME);
    }
    

    This is the gateway code

    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    //#define MY_NODE_ID 1
    //#define MY_PARENT_NODE_ID 0
    
    
    #define MY_RF24_PA_LEVEL RF24_PA_LOW
    
    // Enable serial gateway
    #define MY_GATEWAY_SERIAL
    
    // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
    #if F_CPU == 8000000L
    #define MY_BAUD_RATE 38400
    #endif
    
    // Enable inclusion mode
    #define MY_INCLUSION_MODE_FEATURE
    // Enable Inclusion mode button on gateway
    //#define MY_INCLUSION_BUTTON_FEATURE
    
    // Inverses behavior of inclusion button (if using external pullup)
    //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
    
    // Set inclusion mode duration (in seconds)
    #define MY_INCLUSION_MODE_DURATION 60
    // Digital pin used for inclusion mode button
    //#define MY_INCLUSION_MODE_BUTTON_PIN  3
    
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Inverses the behavior of leds
    //#define MY_WITH_LEDS_BLINKING_INVERSE
    
    #include <MySensors.h>
    
    void setup() {
      // Setup locally attached sensors
    }
    
    void presentation() {
     // Present locally attached sensors
    }
    
    void loop() {
      // Send locally attached sensor data here
    }
    

    From what I believe is happening is that the sensor node is trying to request for the Parent address I think and the Gateway sees that sensor node request but somehow failed to respond to request. Also am still worried why the sensor node is actually trying to request for the parent id when it has already been hardcoded into the senor code as

    #define MY_PARENT_NODE_ID 0

    I believe their must be something I am dong wrong here?? or something I am not seeing well.

    Any help to make these all work will be appreciated.



  • Okay....So after some trial I finally got the whole system to work now. The problem was from the node device, I re-soldered everything on the node part and it works flawlessly. I have even try adding more nodes to it which works without problem too. Now I will proceed to building my own Arduino based controller.
    Thanks I guess :)



  • Hope the following helps someone.
    In my case I wanted to test communication between

    • "GatewaySerial" sketch on one Uno board("Uno1")
    • "Motionsensor" sketch on another Uno board ("Uno2").

    I also wanted to see the "debug" messages without getting confused so I used 2 computers, one for each Uno board.
    In my case, I used a 3.3V rectifier powered by the 5V line on the Uno board and most importantly - YOU MUST SOLDER A CAPACITOR TO EACH RF24L01+ BOARD - if you don't do this, you might have to power the UNO boards separately (to make the radios work OK) - because the power supplied by the USB connection just might not be clean enough - if you put a capacitor on the RF24L01, then you should be OK.

    This is what worked for me:

    1. Prepare both Uno boards ("Uno1" and "Uno2") by loading and running the sketch "ClearEepromConfig"

    2. Connect "Uno1" via USB to computer 1, and before you program it with the sketch "GatewaySerial", make sure you uncomment the DEBUG line (This is so you can use USB serial to see the messages). After programming "Uno1", disconnect it.

    3. Connect "Uno2" via USB to computer 2, and before you program it with sketch "MotionSensor", make sure you:

      • uncomment the DEBUG line (as before)

      • add the line "#define MY_NODE_ID 123" *just before the line "#include <MySensors.h>". *
        N.B. During testing without a "controller" , the presence of MY_NODE_ID in the sensor code solves the CHKID error, but remember to remove this line after testing i.e. before you deploy your sketch for use with a "controller"! In the case above, the sensor will have a node id of 123 and the Gateway will recognise it OK. After programming "Uno2", disconnect it.

    4. Attach Uno1 (GatewaySeriall) to computer 1.
      N.B. IF NO CAP ON YOUR RF24L01+ BOARD, MAKE SURE YOU ALSO POWER "Uno1" SEPARATELY IN ADDITION TO THE USB CONNECTION (this will solves the FPAR error)
      Press "Reset" on Uno1 and look at the serial output output using Putty/Termite/Ide serial bus. You should see about 9 lines (Baud 115200) starting with something like
      "0:255:2:0:9 Starting Gateway" and ending with the "init complete" line

    5. Attach Uno2 ("MotionSensor") to computer 2 and look at the serial output.
      N.B. IF NO CAP ON YOUR RF24L01+ BOARD, MAKE SURE YOU ALSO POWER "Uno2" SEPARATELY IN ADDITION TO THE USB CONNECTION (this solves the FPAR error)
      Press "Reset" on UNO2 and you should see it communicating fine :)

    @EDIT 071016
    Check if your board has a "screen print" error! If it does, you have to move the GPIO4 wire to GPIO5!
    https://twitter.com/bdcatalin/status/663434209265078272



  • @CurlyWurly
    How did you power your Uno's separately?



  • @LOST
    In my case I'm using clone Uno boards for testing. you can see there is a separate jack for power (if you don't want to use USB power) .

    "Arduino UNO R3 Compatible DCCduino ATMEGA328 Development Board"
    (use google to find them - £3.30 shipped)



  • @CurlyWurly
    OK, thanks!



  • Nice one @CurlyWurly



  • @update
    OK - just following this up with extra info.
    Previously, I was using radios without the cap.
    Once a 47 uf cap was added, I didn't need the extra power supplies (the USB power was enough to the Uno clones).
    Thinking about this now, It wasn't the uno boards, it must have been noise/weak power on my laptop USB.

    Also, I wasted a lot of time on a bad rf24L01 board ( I think I bust it a while ago by supplying 5v :( ).
    So, the moral of the story?

    • If you get a message saying "radio bad" - try another rf24l01
    • ALWAYS add a capacitor to every rf2401 board


  • I also experienced similar things. And has now been solved thanks to this topic. :smile:


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.