Sporadic issues finding parent gateway



  • Hi all!

    Recently I tried my hand out at MySensors as I was looking for a low-power solution for small sensors where power sockets were not readily available.

    I started off by creating a simple Serial Gateway to be connected to the Rasppi running HA OS with the YAML configuration as shown:

    mysensors: 
      gateways:
        - device: '/dev/ttyUSB0'
          persistence_file: 'mysensors/mysensors.json'
          baud_rate: 115200
      optimistic: false
      persistence: true
      version: 2.3.2
        
    logger: 
      default: error
      logs:
        mysensors: debug
        homeassistant.components.mysensors: debug
    

    I uploaded the standard Serial Gateway sketch to the Arduino Nano serving as the Serial Gateway after doing some minor edits to the inclusion mode and LED indicators:

    (Removed description text)
    
    // 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
    }
    

    as well as a simple LightSensor example sketch to an arduino nano via breadboard:

    // 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
    
    #include <MySensors.h>
    
    #define CHILD_ID_LIGHT 0
    #define LIGHT_SENSOR_ANALOG_PIN 0
    
    uint32_t SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    
    MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
    int lastLightLevel;
    
    
    void presentation()
    {
    	// Send the sketch version information to the gateway and Controller
    	sendSketchInfo("Light Sensor", "1.0");
    
    	// Register all sensors to gateway (they will be created as child devices)
    	present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
    }
    
    void loop()
    {
    	int16_t lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23;
    	Serial.println(lightLevel);
    	if (lightLevel != lastLightLevel) {
    		send(msg.set(lightLevel));
    		lastLightLevel = lightLevel;
    	}
    	sleep(SLEEP_TIME);
    }
    

    For both setups power for the Radio module is being sourced from the 3v3 pins of the respective nanos.

    Viewing the Serial log from the node, I observed that the node was consistently failing to find the parent and so I moved the two setups closer and also hooked up the gateway to another instance of IDE to view the serial logs from there. It seems that for some reason only very small snippets of comms are being transferred sporadically between the two.

    The serial logs on the node are as follows:

    | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
            |___/                      2.3.2
    
    16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=255,VER=2.3.2
    26 TSM:INIT
    28 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
    

    and for the gateway:

    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;45 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
    0;255;3;0;9;84532 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;84538 TSF:MSG:BC
    0;255;3;0;9;84540 TSF:MSG:FPAR REQ,ID=255
    0;255;3;0;9;84544 TSF:PNG:SEND,TO=0
    0;255;3;0;9;84547 TSF:CKU:OK
    0;255;3;0;9;84550 TSF:MSG:GWL OK
    0;255;3;0;9;85140 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;206804 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;206812 TSF:MSG:BC
    0;255;3;0;9;206814 TSF:MSG:FPAR REQ,ID=255
    0;255;3;0;9;206818 TSF:PNG:SEND,TO=0
    0;255;3;0;9;206821 TSF:CKU:OK
    0;255;3;0;9;206824 TSF:MSG:GWL OK
    0;255;3;0;9;207832 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;210833 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;210839 TSF:MSG:BC
    0;255;3;0;9;210842 TSF:MSG:FPAR REQ,ID=255
    0;255;3;0;9;210846 TSF:CKU:OK,FCTRL
    0;255;3;0;9;210849 TSF:MSG:GWL OK
    0;255;3;0;9;211787 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;279139 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;279145 TSF:MSG:BC
    0;255;3;0;9;279147 TSF:MSG:FPAR REQ,ID=255
    0;255;3;0;9;279151 TSF:PNG:SEND,TO=0
    0;255;3;0;9;279154 TSF:CKU:OK
    0;255;3;0;9;279157 TSF:MSG:GWL OK
    0;255;3;0;9;279795 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;281152 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;281159 TSF:MSG:BC
    0;255;3;0;9;281161 TSF:MSG:FPAR REQ,ID=255
    0;255;3;0;9;281165 TSF:CKU:OK,FCTRL
    0;255;3;0;9;281168 TSF:MSG:GWL OK
    0;255;3;0;9;281769 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;283166 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;283172 TSF:MSG:BC
    0;255;3;0;9;283175 TSF:MSG:FPAR REQ,ID=255
    0;255;3;0;9;283180 TSF:CKU:OK,FCTRL
    0;255;3;0;9;283183 TSF:MSG:GWL OK
    0;255;3;0;9;283751 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;297221 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;297228 TSF:MSG:BC
    0;255;3;0;9;297230 TSF:MSG:FPAR REQ,ID=255
    0;255;3;0;9;297234 TSF:PNG:SEND,TO=0
    0;255;3;0;9;297237 TSF:CKU:OK
    0;255;3;0;9;297240 TSF:MSG:GWL OK
    0;255;3;0;9;297528 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;363339 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;363346 TSF:MSG:BC
    0;255;3;0;9;363348 TSF:MSG:FPAR REQ,ID=255
    0;255;3;0;9;363353 TSF:PNG:SEND,TO=0
    0;255;3;0;9;363356 TSF:CKU:OK
    0;255;3;0;9;363359 TSF:MSG:GWL OK
    0;255;3;0;9;364230 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;5;1
    0;255;3;0;9;435504 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;435510 TSF:MSG:BC
    0;255;3;0;9;435513 TSF:MSG:FPAR REQ,ID=255
    0;255;3;0;9;435516 TSF:PNG:SEND,TO=0
    0;255;3;0;9;435520 TSF:CKU:OK
    0;255;3;0;9;435522 TSF:MSG:GWL OK
    0;255;3;0;9;435853 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;5;0
    0;255;3;0;9;501621 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;501627 TSF:MSG:BC
    0;255;3;0;9;501630 TSF:MSG:FPAR REQ,ID=255
    0;255;3;0;9;501635 TSF:PNG:SEND,TO=0
    0;255;3;0;9;501638 TSF:CKU:OK
    0;255;3;0;9;501641 TSF:MSG:GWL OK
    0;255;3;0;9;502553 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;505652 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;505658 TSF:MSG:BC
    0;255;3;0;9;505661 TSF:MSG:FPAR REQ,ID=255
    0;255;3;0;9;505664 TSF:CKU:OK,FCTRL
    0;255;3;0;9;505668 TSF:MSG:GWL OK
    0;255;3;0;9;506512 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;639902 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;639908 TSF:MSG:BC
    0;255;3;0;9;639911 TSF:MSG:FPAR REQ,ID=255
    0;255;3;0;9;639915 TSF:PNG:SEND,TO=0
    0;255;3;0;9;639919 TSF:CKU:OK
    0;255;3;0;9;639921 TSF:MSG:GWL OK
    0;255;3;0;9;640875 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;842288 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;842294 TSF:MSG:BC
    0;255;3;0;9;842297 TSF:MSG:FPAR REQ,ID=255
    0;255;3;0;9;842300 TSF:PNG:SEND,TO=0
    0;255;3;0;9;842304 TSF:CKU:OK
    0;255;3;0;9;842306 TSF:MSG:GWL OK
    0;255;3;0;9;842894 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    0;255;3;0;9;900008 TSF:SAN:OK
    0;255;3;0;9;976541 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;976547 TSF:MSG:BC
    0;255;3;0;9;976550 TSF:MSG:FPAR REQ,ID=255
    0;255;3;0;9;976555 TSF:PNG:SEND,TO=0
    0;255;3;0;9;976558 TSF:CKU:OK
    0;255;3;0;9;976560 TSF:MSG:GWL OK
    0;255;3;0;9;977257 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    

    Occasionally though some data gets through because the green light on the gateway LED will flash and it is also reflected in the gateway logs but there is no consistency or pattern to which I can predict when this will happen.

    Things that I have tried:

    • Soldering the nRF24L01 to the pins of the board via perfboard to eliminate issues with the jumper wires
    • attaching 100uF between 3v3 and GND

    Things I am thinking of trying:

    • Using a dedicated 3.3V supply for the nRF24L01s
    • giving up on 2.4GHz altogether and trying my luck with 433mHz

    At this juncture I highly suspect the issue to be with the quality of my nRF24L01 or the power supply. However if someone has encountered this issue before and would be able to share their experience, I would be more than grateful as this would save me a lot on guesswork.

    Thanks!

    Cheers,
    Ethan



  • @Ethan-Chua Some photos of the wiring and set up would be of help here along with a link tothe radio modules you are using. Maybe try moving them further apart, counter-intuitive I know but it might be receiving module being swamped with the power of the TX one. You could also try a different channel (use nrf doctor to find where there are 'quiet' areas) and see if that helps.

    Do you have a lot of bluetooth/wifi in the building? anything else in the 2.4GHz band like cameras, keyboard,mouse etc?



  • Hi there,

    Thanks for your response! It turns out I needed a better 3.3V power supply because I was powering the NRF24L01 from the Nano's 3.3V pin which is derived from the CH340 USB-Serial converter and is not ideal. Upgrading the supply to an AMS1117 3.3V supply solved the issue completely!

    Sorry for the late reply and thanks so much for your tips! Will try them out if issues crop up in the future.


Log in to reply
 

Suggested Topics

  • 3
  • 6
  • 5
  • 2
  • 8
  • 1

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts