NRF24L01 can't find parent on gateway



  • Hi there,

    I'm using an ethernet gateway on an UNO R3 with some locally attached sensors and an NRF24L01 attached to it. The locally attached sensors work fine (sending to Domoticz).

    Now I have another Robotdyn UNO with one sensor attached and an NRF24L01 but I can't get it to find the parent on the gateway.

    Tried lowering the power and moving the two closer and further away from each other, but all makes no difference. The node id get's assigned. Below are the logs from both gateway and client:

    0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;RF24:write register, reg=0, value=14
    0;255;3;0;9;RF24:write register, reg=3, value=3
    0;255;3;0;9;RF24:write register, reg=4, value=95
    0;255;3;0;9;RF24:write register, reg=5, value=76
    0;255;3;0;9;RF24:write register, reg=6, value=35
    0;255;3;0;9;RF24:read register, reg=6, value=35
    0;255;3;0;9;RF24:read register, reg=5, value=76
    0;255;3;0;9;RF24:write register, reg=16, value=115
    0;255;3;0;9;RF24:write register, reg=29, value=6
    0;255;3;0;9;RF24:write register, reg=2, value=2
    0;255;3;0;9;RF24:write register, reg=1, value=0
    0;255;3;0;9;RF24:write register, reg=28, value=3
    0;255;3;0;9;RF24:flushRX
    0;255;3;0;9;RF24:flushTX
    0;255;3;0;9;RF24:write register, reg=7, value=112
    0;255;3;0;9;TSM:RADIO:OK
    0;255;3;0;9;TSM:GW MODE
    0;255;3;0;9;RF24:write register, reg=2, value=3
    0;255;3;0;9;RF24:write register, reg=1, value=1
    0;255;3;0;9;RF24:start listening
    0;255;3;0;9;RF24:write register, reg=0, value=15
    0;255;3;0;9;RF24:write register, reg=10, value=0
    0;255;3;0;9;TSM:READY
    IP: 192.168.2.230
    Humid sensor setup complete
    presented data...
    0;255;3;0;9;No registration required
    0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
    T: 23.00
    H: 51.00
    0;255;3;0;9;Eth: connect
    presented data...
    0;255;3;0;9;Eth: 0;0;3;0;2;
    0;255;3;0;9;Eth: 0;0;3;0;2;Get Version
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;RF24:read register, reg=6, value=35
    0;255;3;0;9;RF24:read register, reg=5, value=76
    0;255;3;0;9;TSP:SANCHK:OK
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;RF24:read register, reg=6, value=35
    0;255;3;0;9;RF24:read register, reg=5, value=76
    0;255;3;0;9;TSP:SANCHK:OK
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    H: 52.00
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;RF24:read register, reg=6, value=35
    0;255;3;0;9;RF24:read register, reg=5, value=76
    0;255;3;0;9;TSP:SANCHK:OK
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;Eth: 0;0;3;0;18;PING

    Client:
    verbose:
    Starting sensor (RNNNA-, 2.0.0)
    TSM:INIT
    RF24:write register, reg=0, value=14
    RF24:write register, reg=3, value=3
    RF24:write register, reg=4, value=95
    RF24:write register, reg=5, value=76
    RF24:write register, reg=6, value=35
    RF24:read register, reg=6, value=35
    RF24:read register, reg=5, value=76
    RF24:write register, reg=16, value=115
    RF24:write register, reg=29, value=6
    RF24:write register, reg=2, value=2
    RF24:write register, reg=1, value=0
    RF24:write register, reg=28, value=3
    RF24:flushRX
    RF24:flushTX
    RF24:write register, reg=7, value=112
    TSM:RADIO:OK
    RF24:write register, reg=2, value=3
    RF24:write register, reg=1, value=1
    RF24:start listening
    RF24:write register, reg=0, value=15
    RF24:write register, reg=10, value=5
    TSP:ASSIGNID:OK (ID=5)
    TSM:FPAR
    RF24:stop listening
    RF24:write register, reg=0, value=14
    RF24:open writing pipe, recipient=255
    RF24:write register, reg=10, value=255
    RF24:write register, reg=16, value=255
    RF24:send message to 255, len=7
    RF24:flushTX
    RF24:write register, reg=7, value=48
    RF24:MAX_RT
    RF24:flushTX
    RF24:start listening
    RF24:write register, reg=0, value=15
    RF24:write register, reg=10, value=5
    TSP:MSG:SEND 5-5-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    RF24:stop listening
    RF24:write register, reg=0, value=14
    RF24:open writing pipe, recipient=255
    RF24:write register, reg=10, value=255
    RF24:write register, reg=16, value=255
    RF24:send message to 255, len=7
    RF24:flushTX
    RF24:write register, reg=7, value=48
    RF24:MAX_RT
    RF24:flushTX
    RF24:start listening
    RF24:write register, reg=0, value=15
    RF24:write register, reg=10, value=5
    TSP:MSG:SEND 5-5-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    RF24:stop listening
    RF24:write register, reg=0, value=14
    RF24:open writing pipe, recipient=255
    RF24:write register, reg=10, value=255
    RF24:write register, reg=16, value=255
    RF24:send message to 255, len=7
    RF24:flushTX
    RF24:write register, reg=7, value=48
    RF24:MAX_RT
    RF24:flushTX
    RF24:start listening
    RF24:write register, reg=0, value=15
    RF24:write register, reg=10, value=5
    TSP:MSG:SEND 5-5-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    RF24:stop listening
    RF24:write register, reg=0, value=14
    RF24:open writing pipe, recipient=255
    RF24:write register, reg=10, value=255
    RF24:write register, reg=16, value=255
    RF24:send message to 255, len=7
    RF24:flushTX
    RF24:write register, reg=7, value=48
    RF24:MAX_RT
    RF24:flushTX
    RF24:start listening
    RF24:write register, reg=0, value=15
    RF24:write register, reg=10, value=5
    TSP:MSG:SEND 5-5-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
    RF24:write register, reg=0, value=12
    RF24:power down
    TSM:INIT

    Anyone an idea?

    Thanks!


  • Admin

    @alfredb Please upload your GW & node sketch. Are you using nRF24L01 or nRF24L01+ radios?



  • Hi Tekka,

    Thanks for your reply. I'm using the nRF24L01 (without the +). Hereby the sketches (the gw one is not complete yet as got stuck getting the gw and node talking.

    GW sketch:
    #define MY_DEBUG // Enable debug prints to serial monitor
    #define MY_DEBUG_VERBOSE_RF24

    #include <SPI.h>
    #include <DHT.h>
    #include <Time.h>
    #include <Ethernet.h>
    #include <RemoteTransmitter.h>
    #include <RemoteReceiver.h>
    #include <NewRemoteReceiver.h>
    #include <SensorReceiver.h>
    #include <InterruptChain.h>

    #define GATEWAY_FEATURE
    #define MY_GATEWAY_W5100
    #define MY_RADIO_NRF24
    #define MY_NODE_ID 0
    //#define MY_RF24_SANITY_CHECK
    #define MY_RF24_PA_LEVEL RF24_PA_LOW
    #define MY_RF24_DATARATE RF24_250KBPS

    #define SS_ETHERNET 10
    #define MY_PORT 5003
    #define HUMIDITY_SENSOR_DIGITAL_PIN 3
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define CHILD_ID_RECEIVER 2
    #define CHILD_ID_ACTION_SWITCH_A 3
    #define V_RCODE 0
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    const char SYSTEMCODE = char(31); // Adjust this to your own SYSTEMCODE see RemoteTransmitter.h

    #define MY_SOFT_SPI_SCK_PIN 14
    #define MY_SOFT_SPI_MISO_PIN 16
    #define MY_SOFT_SPI_MOSI_PIN 15

    // When W5500 is connected we have to move CE/CSN pins for NRF radio
    #define MY_RF24_CE_PIN 5
    #define MY_RF24_CS_PIN 6

    // Intantiate a new KaKuTransmitter remote, also use pin 11 (same transmitter!)
    KaKuTransmitter kaKuTransmitter(8);

    DHT dht;
    float lastTemp;
    float lastHum;
    float RFCode = 0;
    bool metric = true;
    // Protocol handler
    bool RFCodeAvailable = false;
    int value01 = 0;

    // Controller ip address. Enables client mode (default is "server" mode).
    // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
    //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254

    #define MY_IP_GATEWAY_ADDRESS 192,168,2,254
    #define MY_IP_ADDRESS 192,168,2,230
    #define MY_IP_SUBNET_ADDRESS 255,255,255,0
    #define MY_MAC_ADDRESS 0x00, 0x08, 0xDC, 0xF4, 0x6D, 0xC1

    int sensorValue = 0; // variable to store the value coming from the sensor

    #include <MySensors.h>
    #include <MyConfig.h>

    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgRCode(CHILD_ID_RECEIVER, V_LIGHT);
    MyMessage msgDeviceA( CHILD_ID_ACTION_SWITCH_A, V_LIGHT );

    void setup()
    {
    Serial.begin(115200);
    dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
    metric = getConfig().isMetric;
    Serial.println("Humid sensor setup complete");
    //RemoteReceiver::init(-1, 2, showOldCode);
    //NewRemoteReceiver::init(-1, 2, showNewCode);
    //InterruptChain::addInterruptCallback(0, RemoteReceiver::interruptHandler);
    //InterruptChain::addInterruptCallback(0, NewRemoteReceiver::interruptHandler);
    //358694,

    while (!Serial) {
    ; // wait for serial port to connect.
    }

    }

    // shows the received code sent from an old-style remote switch
    void showOldCode(unsigned long receivedCode, unsigned int period) {
    // Print the received code.
    Serial.print("Code: ");
    Serial.print(receivedCode);
    Serial.print(", period: ");
    Serial.print(period);
    Serial.println("us.");
    float RFCode = (receivedCode);
    float RFCodeAvailable = true;
    // Serial.println (RFCodeAvailable);
    // Send the received code.
    if (RFCode=='358694') {
    Serial.println ("detected RFCode");
    send(msgRCode.set(RFCode, 1));
    send(msgDeviceA.set(RFCode, 1));
    }

    }

    // Shows the received code sent from an new-style remote switch
    void showNewCode(NewRemoteCode receivedCode) {
    // Print the received code.
    Serial.print("Addr ");
    Serial.print(receivedCode.address);

    if (receivedCode.groupBit) {
    Serial.print(" group");
    } else {
    Serial.print(" unit ");
    Serial.print(receivedCode.unit);
    }

    switch (receivedCode.switchType) {
    case NewRemoteCode::off:
    Serial.print(" off");
    break;
    case NewRemoteCode:🔛
    Serial.print(" on");
    break;
    case NewRemoteCode::dim:
    Serial.print(" dim level ");
    Serial.print(receivedCode.dimLevel);
    break;
    case NewRemoteCode::on_with_dim:
    Serial.print(" on with dim level ");
    Serial.print(receivedCode.dimLevel);
    break;
    }

    Serial.print(", period: ");
    Serial.print(receivedCode.period);
    Serial.println("us.");
    }

    void presentation() {
    // Present locally attached sensors
    sendSketchInfo("Temp and Humidity", "1.0");
    present(CHILD_ID_HUM, S_HUM);
    present(CHILD_ID_TEMP, S_TEMP);
    sendSketchInfo("Kaku Receiver", "2.0");
    present(CHILD_ID_RECEIVER, S_LIGHT);
    present (CHILD_ID_ACTION_SWITCH_A, S_LIGHT);
    sendBatteryLevel(100); // It just looks better in Domoticz
    Serial.println("presented data...");
    }

    void loop() {
    delay(dht.getMinimumSamplingPeriod());

    //Fetch temperatures from DHT sensor
    float temperature = dht.getTemperature();
    if (isnan(temperature)) {
    Serial.println("Failed reading temperature from DHT");
    } else if (temperature != lastTemp) {
    lastTemp = temperature;
    if (!metric) {
    temperature = dht.toFahrenheit(temperature);
    }
    send(msgTemp.set(temperature, 1));
    #ifdef MY_DEBUG
    Serial.print("T: ");
    Serial.println(temperature);
    #endif
    }

    // Fetch humidity from DHT sensor
    

    float humidity = dht.getHumidity();
    if (isnan(humidity)) {
    Serial.println("Failed reading humidity from DHT");
    } else if (humidity != lastHum) {
    lastHum = humidity;
    send(msgHum.set(humidity, 1));
    #ifdef MY_DEBUG
    Serial.print("H: ");
    Serial.println(humidity);
    #endif
    }

    // Print the received code.
    // float RFCode = (receivedCode);
    // float RFCodeAvailable = true;

    sleep(SLEEP_TIME); //sleep a bit

    }

    // kaKuTransmitter.sendSignal('B',2,true);
    void receive(const MyMessage &message) {
    if (message.type == V_LIGHT) {
    Serial.println ("MSG from sensor:");
    Serial.println (message.sensor);
    Serial.println ("MSG from sensor:");
    Serial.println (mGetCommand(message));
    Serial.println (mGetPayloadType(message));
    Serial.println ("Message value:");
    Serial.println (message.getString(_convBuf));

    char *hextstring = (message.getString(_convBuf));
    Serial.println ("Converted:");
    Serial.println (*hextstring);
    
    if (*hextstring=='1') {
    Serial.println("AAN");
    kaKuTransmitter.sendSignal('B',2,true);
    }
    if (*hextstring=='0') {
    Serial.println ("UIT");
    kaKuTransmitter.sendSignal('B',2,false);
    }
    

    }

    }

    Node Sketch:

    #include <SPI.h>
    #define MY_RADIO_NRF24
    #define MY_DEBUG
    #define MY_DEBUG_VERBOSE_RF24

    #define MY_NODE_ID 5
    #define MY_PARENT_NODE_ID 0
    #define MY_PARENT_NODE_IS_STATIC
    // Set RF24L01 channel number
    //#define MY_RF24_CHANNEL 125

    // Define nRF24L01 datarate
    #define MY_RF24_DATARATE RF24_250KBPS
    #define MY_RF24_PA_LEVEL RF24_PA_LOW

    #include <MyConfig.h>
    #include <MySensors.h>
    #define COMPARE_PH 1 // Send PH only if changed? 1 = Yes 0 = No

    unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds)
    float lastPH;

    boolean receivedConfig = false;
    boolean metric = true;

    //Kraanwater 7,380 28-07-2016

    int ph_pin = A5; //This is the pin number connected to Po

    void setup() {
    Serial.begin(9600);
    }

    // Initialize PH message
    MyMessage msg(0, V_PH);

    float getPH() {
    //query your PH sensor here (I2C,Serial,Phidget...)
    float measure = analogRead(ph_pin);
    Serial.print("Measure: ");
    //Serial.print(measure);

    double voltage = 5 / 1024.0 * measure; //classic digital to voltage conversion
    //double voltage = 5 / 1024.0 * measure; //classic digital to voltage conversion
    Serial.print("\tVoltage: ");
    Serial.print(voltage, 3);
    // PH_step = (voltage@PH7 - voltage@PH4) / (PH7 - PH4)
    // PH_probe = PH7 - ((voltage@PH7 - voltage@probe) / PH_step)

    float Po = 7 + ((2.5 - voltage) / 0.18);

    Serial.print("\tPH: ");
    Serial.print(Po, 3);
    //return Po;
    }

    void presentation() {
    // Send the sketch version information to the gateway and Controller
    sendSketchInfo("PH Sensor", "1.1");
    present(0, S_WATER_QUALITY);

    }

    void loop() {

    Serial.println("");
    delay(2000);
    float ph = getPH();
    Serial.print(ph);

    #if COMPARE_PH == 1
    if (lastPH != ph) {
    #endif

    // Send in the new PH value
    send(msg.set(ph, 1));
    // Save new PH value for next compare
    lastPH = ph;
    

    #if COMPARE_PH == 1
    }
    #endif
    //sleep(SLEEP_TIME);
    }



  • @alfredb
    Hi there, meanwhile I've been testing with another gateway (on a NodeMCU) and this worked right away. So there is an issue here with the NRF24L01 module on the Uno, perhaps it has something to do with using the ICSP connections for the NRF24L01 module or the combination with a W5500?

    Regards



  • Short: probably. TrY soft spi for the nrf24


  • Admin

    @alfredb nRF24L01 (non-P) are not supported in 2.0.0, these radios have limited data rates (only 1 and 2Mbps, no 250kbps). I assume you used a different module on your NodeMCU GW?
    The good news is, I've added a fix to 2.0.1 (dev) to support non-P modules, you try the dev lib and set

    #define MY_RF24_DATARATE RF24_1MBPS
    

    on all nodes an GW.



  • @tekka Thanks again, I'll give it a try! I already defined the limited data rate but I was not aware of the fact that the non-P type was not supported.


Log in to reply
 

Suggested Topics

12
Online

11.4k
Users

11.1k
Topics

112.7k
Posts