Serial GW and motion sensor functionning, but no activity between them



  • Hello everyone ! My first topic here, to search for a help. I'm new to MySensors and a little confused by its working process, but i don't understand why my really simple and standard setup isn't working. Here it is :

    A Serial Gateway on arduino nano clone, with NRF24L01+ attached.
    A SR501 motion sensor on arduino nano clone with same radio attached.
    I've only used the example sketches found here on mysensors, compiled on Arduino IDE 1.8.12.
    GW and sensor are (for now) powered via USB on a desktop computer.

    Here is the log of sensor :

    16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=255,VER=2.3.2
    26 TSM:INIT
    28 TSF:WUR:MS=0
    

    As far as i understand, the sensor is initializing, but that's all, no communication with GW, no data gathering...

    And for the GW :

    0;255;3;0;9;0 MCO:BGN:INIT GW,CP=RNNGA---,FQ=16,REL=255,VER=2.3.2
    0;255;3;0;9;5 TSM:INIT
    0;255;3;0;9;7 TSF:WUR:MS=0
    0;255;3;0;9;15 TSM:INIT:TSP OK
    0;255;3;0;9;18 TSM:INIT:GW MODE
    0;255;3;0;9;21 TSM:READY:ID=0,PAR=0,DIS=0
    0;255;3;0;9;24 MCO:REG:NOT NEEDED
    0;255;3;0;14;Gateway startup complete.
    0;255;0;0;18;2.3.2
    0;255;3;0;9;28 MCO:BGN:STP
    0;255;3;0;9;35 MCO:BGN:INIT OK,TSP=1
    0;255;3;0;9;38 TSM:READY:NWD REQ
    0;255;3;0;9;1850 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
    

    That's it...
    I've tried with different sensors, with other pieces of radio, other nanos... nothing changes.
    Hope it's a ridicoulous newbie problem and i thank you for the help you can bring me.
    Thanks a lot !



  • @Rolland
    Did you give your node an ID?
    You could set via code or burn into ROM. This is needed. Can you post your node-code?



  • @Rolland Post your code for the gateway and the node.



  • @skywatch

    @parachutesj , i've only used the basic example for the mysensors site, no modification at all. Here is the sensor sketch code :

    /*
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2019 Sensnology AB
     * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik Ekblad
     *
     * DESCRIPTION
     * Motion Sensor example using HC-SR501
     * http://www.mysensors.org/build/motion
     *
     */
    
    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_RF24
    //#define MY_RADIO_NRF5_ESB
    //#define MY_RADIO_RFM69
    //#define MY_RADIO_RFM95
    
    #include <MySensors.h>
    
    uint32_t 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
    
    // 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 here is the GW code :

    /**
    * The MySensors Arduino library handles the wireless radio link and protocol
    * between your home built sensors/actuators and HA controller of choice.
    * The sensors forms a self healing radio network with optional repeaters. Each
    * repeater and gateway builds a routing tables in EEPROM which keeps track of the
    * network topology allowing messages to be routed to nodes.
    *
    * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
    * Copyright (C) 2013-2019 Sensnology AB
    * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
    *
    * Documentation: http://www.mysensors.org
    * Support Forum: http://forum.mysensors.org
    *
    * This program is free software; you can redistribute it and/or
    * modify it under the terms of the GNU General Public License
    * version 2 as published by the Free Software Foundation.
    *
    *******************************
    *
    * DESCRIPTION
    * The ArduinoGateway prints data received from sensors on the serial link.
    * The gateway accepts input on serial which will be sent out on radio network.
    *
    * The GW code is designed for Arduino Nano 328p / 16MHz
    *
    * Wire connections (OPTIONAL):
    * - Inclusion button should be connected between digital pin 3 and GND
    * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
    *
    * LEDs (OPTIONAL):
    * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs
    * - RX (green) - blink fast on radio message received. In inclusion mode will blink fast only on presentation received
    * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
    * - ERR (red) - fast blink on error during transmission error or receive crc error
    *
    */
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    
    // Enable and select radio type attached
    #define MY_RADIO_RF24
    //#define MY_RADIO_NRF5_ESB
    //#define MY_RADIO_RFM69
    //#define MY_RADIO_RFM95
    
    // Set LOW transmit power level as default, if you have an amplified NRF-module and
    // power your radio separately with a good regulator you can turn up PA level.
    #define MY_RF24_PA_LEVEL RF24_PA_LOW
    
    // Enable serial gateway
    #define MY_GATEWAY_SERIAL
    
    // Define a lower baud rate for Arduinos 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
    
    // Flash leds on rx/tx/err
    // Uncomment to override default HW configurations
    //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
    //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
    //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
    
    #include <MySensors.h>
    
    void setup()
    {
    	// Setup locally attached sensors
    }
    
    void presentation()
    {
    	// Present locally attached sensors
    }
    
    void loop()
    {
    	// Send locally attached sensor data here
    }
    

    @parachutesj, I've read again the presentation of mysensors functionning principles, and indeed, i've missed the fact that i must define a child id for every sensor, but the sketch already made this. I've the same problem with a DHT-11 node, with child_id_hum set to 0 and child_id_temp set to 1. I've tried to change these ids to 1 and 2, but nothing changed...
    Is the code of the sensor and GW above get you any new ideas ?
    Thanks a lot.



  • @Rolland said in Serial GW and motion sensor functionning, but no activity between them:

    Here is the log of sensor :
    16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=255,VER=2.3.2
    26 TSM:INIT
    28 TSF:WUR:MS=0

    Are these three lines all output from the sensor? That should be more, eg that it is finding its parent etc.
    Did you double check the connections between the Arduino and the NRF24?



  • @parachutesj Reading the library's API, I've understood that the node ID is defined automatically. I don't know how to find the info on seeing this is manually, if this is needed in my case. Can you help?



  • @electrik Yes, that's all debug lines that i get, no matter how long I wait. I've just checked again the connection between Arduino nano and NRF24, for GW and sensor, and it's all good, according to the connect informations on this page. I didn't connect the IRQ pin as mentionned.



  • try and put this into your code of the node

    #define MY_NODE_ID 2
    

    replace the number (2) for each further node with numbers between 1 and 255

    what happens then?



  • @Rolland as far as I know, you need a controller which assigns the node ID's - this of course means that you need a fully functioning setup from the beginning e.g. your gateway connected to a controller.
    As a workaround you could specify the node ID manually. see my other post.



  • @Rolland - The advice from @parachutesj is spot on! - You NEED a controller.

    The gateway is only a conduit through which communications from nodes to the controller flow. With no controller there is no flow of data and so you will see little traffic. A raspberry pi is all you need, then choose from the available software downloads to act as controller. Simple!



  • @Rolland and you should put this into your code from both (if not there yet)

    #define MY_DEBUG 
    


  • Ok guys, thanks a lot for all your advices. I understand better. @skywatch : my gateway is on USB port of a Raspberry Pi 3+ with Home Assitant. But on this side I don't understand fully how to configure the link between gateway and HA, or at least to see if everything is going normal. HA is powerful but there's so much to learn when you discover it.
    I'm discovering a lot of things in a little time : Mysensors, Home assistant, arduino...
    Thanks anyway for your help and kindness.
    @parachutesj , I'll modify my sketch and see what happens.



  • @Rolland The best way to see what is happening is to connect the gateway to the usb of a computer and open the serial monitor in the arduino IDE. Then you can see the values being sent by the nodes to test if it is working.
    @parachutesj suggestion to add my debug to the config is also needed for this, but then reflash the node without my debug before you plug it back into the pi as it can cause issues. I never used HA so can't help you with that side of things, sorry.



  • @parachutesj said in Serial GW and motion sensor functionning, but no activity between them:

    try and put this into your code of the node

    #define MY_NODE_ID 2
    

    replace the number (2) for each further node with numbers between 1 and 255

    what happens then?

    Hi. Nothing change. I still got the same 3 debug lines, no sign of communication between node and gw...



  • I've also tried to clear the eeprom memory of the node, and flash again sensor sketch, but still the same problem... i've also tried to see if the motion sensor was working correctly, and made up a simple sketch with just the sensor and the Arduino, it's working fine.



  • @Rolland Does the motion sensor go HIGH or LOW when activated?


  • Mod

    as @electrik mentioned, the sensor node does not complete its initialization of the radio.

    Therefore, it does not (yet) matter if node ID is defined, or how the motion sensor works. The node never reaches any of that stuff.

    @Rolland if you can, replace the radio on the sensor node. If that doesn't help, try replacing the Arduino. Also try to disconnect everything but the power and the radio from the Arduino.



  • @mfalkvidd true.
    this is the log if the radio works and it does not have an ID. just uploaded to a blank Nano

    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 TSM:FPAR
    15 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    1024 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    1029 TSF:MSG:FPAR OK,ID=0,D=1
    2022 TSM:FPAR:OK
    2023 TSM:ID
    2024 TSM:ID:REQ
    2027 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
    4034 TSM:ID
    4035 TSM:ID:REQ
    4037 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
    6045 TSM:ID
    6046 TSM:ID:REQ
    6048 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
    

    and like this if the NODE_ID was set (here to 155)

    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 TSM:INIT:STATID=155
    15 TSF:SID:OK,ID=155
    16 TSM:FPAR
    53 TSF:MSG:SEND,155-155-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    146 TSF:MSG:READ,0-0-155,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    151 TSF:MSG:FPAR OK,ID=0,D=1
    2060 TSM:FPAR:OK
    2061 TSM:ID
    2062 TSM:ID:OK
    2064 TSM:UPL
    2067 TSF:MSG:SEND,155-155-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2079 TSF:MSG:READ,0-0-155,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2084 TSF:MSG:PONG RECV,HP=1
    2086 TSM:UPL:OK
    2088 TSM:READY:ID=155,PAR=0,DIS=1
    2093 TSF:MSG:SEND,155-155-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    2100 TSF:MSG:READ,0-0-155,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    2108 TSF:MSG:SEND,155-155-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
    2116 TSF:MSG:SEND,155-155-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
    4125 TSF:MSG:SEND,155-155-0-0,s=255,c=3,t=11,pt=0,l=13,sg=0,ft=0,st=OK:Motion Sensor
    4134 TSF:MSG:SEND,155-155-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
    4143 TSF:MSG:SEND,155-155-0-0,s=1,c=0,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
    4149 MCO:REG:REQ
    4155 TSF:MSG:SEND,155-155-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
    4170 TSF:MSG:READ,0-0-155,s=255,c=3,t=27,pt=1,l=1,sg=0:1
    4175 MCO:PIM:NODE REG=1
    4177 MCO:BGN:STP
    4178 MCO:BGN:INIT OK,TSP=1
    0
    4188 TSF:MSG:SEND,155-155-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
    4194 MCO:SLP:MS=120000,SMS=0,I1=1,M1=1,I2=255,M2=255
    4199 MCO:SLP:TPD
    

    if I "kill" the radio, it looks like this, which is still different than what @Rolland got. But would be worth a try to replace the radio.

    0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
    3 TSM:INIT
    4 TSF:WUR:MS=0
    11 !TSM:INIT:TSP FAIL
    12 TSM:FAIL:CNT=1
    14 TSM:FAIL:PDT
    


  • almost forgot:
    to just eliminate the issues with ID, missing controller etc. You could test the radios with a simple NRF24 test script, just google "NRF24 test code" and you will find a bunch to test if the communication works between nodes and radios are ok.



  • Photos of your hardware would be good as 'nano clone' and 'nrf24' come in lots of types and qualities...



  • Hi everybody.
    I'm progressing, thanks to you. Here is some more infos :

    • @mfalkvidd and @electrik , ok thanks a lot, i'll put the ID part of the plan aside for a while. Following your advice, when I unplug everything but the power and radio, I've got some weird things happening, worst of all is a sudden crash and reboot of computer when I try to open serial link monitor... :-x
    • @skywatch : nano clones are these ones, and nRF24L01+ are those ones.
    • @parachutesj : i've tried some very good sketches and begin to see a little clearer about nrf24. Using TMRh20 libraries and sketches, I've tried to make a couple of radios+nanos to communicate. The result I got is not so good : One radio just made my computer reboot :-x , while the two others seem more stable, BUT, when sending the ping between the two of them, the serial link console freezes for a little while, then shows back the sketch from the beginning. From what I've been reading, I think this could be a power supply problem (this post, "Power problems" section. I'll try to connect capacitors between VCC and GND of radios to avoid this "freeze" and "reboot" symptoma.

    Next steps for me would be (I think) :

    • see if capacitors can do the job and solve the problem
    • try some other radio modules maybe ?
    • try an official Arduino nano maybe ?

    Again, thank you all for your help !



  • @Rolland I was hoping you'd post a photo of what you have made so we can see the wiring etc.... But, you have unshielded pa/lna radio modules and I suggest getting some non-pa/lna ones from cdebyte on aliexpress.

    How are you powering the radios?
    What are you using to power the nano?



  • @Rolland unfortunately I have to confirm what @skywatch said: the radios are crap. I had those and never made good experience with them. Also the amplified long range radios are not really needed in most cases and if, then they need a really good power source to run otherwise I never got stable connections.
    Besides, any cheap NRF24 from China worked quite well for me. Some very few were faulty but if you get 10 for 7 USD you can live with that
    https://www.aliexpress.com/item/32518935864.html?spm=a2g0o.productlist.0.0.686fe77cXL8wSb&algo_pvid=ad7873cd-c5ff-4de5-8f42-f1648f896a0b&algo_expid=ad7873cd-c5ff-4de5-8f42-f1648f896a0b-1&btsid=0ab6d70515882563711402031e6ae8&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_
    Not saying those are the best, but easier than the PA-ones.



  • @Rolland don't bother with official Arduino (imho). the clones work flawless. I have a lot here in my home and they work well. It is just not worth it to pay 10x the price



  • @Rolland these are the modules I would recommend.....

    https://www.aliexpress.com/item/4000186023497.html



  • Hello everybody. Ok, I've made some shopping, according to your advices, waiting for items to arrive. Until then, see you soon and take care, thanks again. I'll post the results of the new combination, hoping for success.
    Ciao.



  • @Rolland That is good news - what capacitors did you get for the NRF24's ???



  • @skywatch I've got some 10 µF and 100 µF electrolytic capacitors, and just received a bunch of other various capacitors, ranging from 1 to 470 µF. I haven't tested them for now.
    But good news ! I also received 3 NRF24L01+ with built in antennas, reset the entire crew of nodes and gateway, and it works like a charm 😊
    I'm more than happy. Thanks again for all your advices.
    I'll post some news later, testing the capacitors with NRF24L01+ and antennas.
    Ciao.


Log in to reply
 

Suggested Topics

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts