Sending sensor data from arduino pro mini via NRF24L01+ to raspberry pi 4



  • Hello,
    for a project I need to send sensor data to a gateway.

    For this I followed the following tutorial:
    https://www.mysensors.org/build/connect_radio
    https://www.mysensors.org/build/temp
    https://www.mysensors.org/build/raspberry

    The output of my Arduino looks like this:

    16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=8,REL=255,VER=2.3.2
    28 MCO:BGN:BFR
    51 TSM:INIT
    53 TSF:WUR:MS=0
    61 TSM:INIT:TSP OK
    61 TSM:FPAR
    65 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    2074 !TSM:FPAR:NO REPLY
    2076 TSM:FPAR
    2078 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    4087 !TSM:FPAR:NO REPLY
    4089 TSM:FPAR
    4091 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    6103 !TSM:FPAR:NO REPLY
    6105 TSM:FPAR
    6107 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    8116 !TSM:FPAR:FAIL
    8118 TSM:FAIL:CNT=1
    8120 TSM:FAIL:DIS
    8122 TSF:TDI:TSL
    18124 TSM:FAIL:RE-INIT
    18126 TSM:INIT
    18132 TSM:INIT:TSP OK
    18135 TSM:FPAR
    18139 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    20148 !TSM:FPAR:NO REPLY
    

    The Raspberry has the following output (in debug mode):

    pi@raspberrypi:~/MySensors $ sudo ./bin/mysgw 
    Mar 04 13:25:39 INFO  Starting gateway...
    Mar 04 13:25:39 INFO  Protocol version - 2.4.0-alpha
    Mar 04 13:25:39 DEBUG MCO:BGN:INIT GW,CP=RNNGL---,FQ=NA,REL=0,VER=2.4.0-alpha
    Mar 04 13:25:39 DEBUG TSF:LRT:OK
    Mar 04 13:25:39 DEBUG TSM:INIT
    Mar 04 13:25:39 DEBUG TSF:WUR:MS=0
    Mar 04 13:25:39 DEBUG TSM:INIT:TSP OK
    Mar 04 13:25:39 DEBUG TSM:INIT:GW MODE
    Mar 04 13:25:39 DEBUG TSM:READY:ID=0,PAR=0,DIS=0
    Mar 04 13:25:39 DEBUG MCO:REG:NOT NEEDED
    Mar 04 13:25:39 DEBUG Listening for connections on pE��:5003
    Mar 04 13:25:39 DEBUG MCO:BGN:STP
    Mar 04 13:25:39 DEBUG MCO:BGN:INIT OK,TSP=1
    Mar 04 13:25:39 DEBUG TSM:READY:NWD REQ
    Mar 04 13:25:40 DEBUG ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
    

    Can someone maybe tell me where my error is and how I can read the sensor data?



  • I am in the same boat as you. I am trying to get temperature and humidity interfaced into OH3. I have gotten slightly farther than you using these links:

    Parent Link: https://www.smarthomeblog.net/diy-home-automation-sensors/

    Referenced steps:

    https://www.smarthomeblog.net/mqtt-openhab/
    https://www.smarthomeblog.net/diy-home-automation-sensors-gateway/ (They mention that 98% of the time its a wiring issue. Sometimes its the NRLF24L01)
    https://www.smarthomeblog.net/diy-home-automation-sensors-first-node/



  • @Leon your node is sending a request to find a parent, in this case your gateway, but your gateway is not responding.
    Without more information it will be impossible to help you further...

    The sketch of the arduino can help, the config file of the Pi gateway, activating the log option in the configuration, ...

    On the hardware side, verify your connections to be sure, did you use the capacitor next to the nrf24?, ...



  • @evb
    Hey, thanks for the quick reply.
    I have checked the wiring several times for correctness.
    Also the config was set up according to the instructions.

    Meanwhile I have found an alternative solution.
    Thanks a lot for your help!



  • @haloway13
    Hey, as I said below, I have found a solution to the problem.

    I have made use of two other tutorials.
    (Attention German language!)
    https://draeger-it.blog/arduino-lektion-48-temperatursensor-ds18b20/
    https://tutorials-raspberrypi.de/funkkommunikation-zwischen-raspberry-pis-und-arduinos-2-4-ghz/

    If you look at the wiring, I can send you my code so far:

    #include <SPI.h>
    #include "printf.h"
    #include "RF24.h"
    #include <OneWire.h>
    #include <DallasTemperature.h>
    
    #define ONE_WIRE_BUS 2  //Sensor DS18B20 at digital pin 2
    
    RF24 radio(7, 8); // using pin 7 for the CE pin, and pin 8 for the CSN pin
    OneWire oneWire(ONE_WIRE_BUS);
    
    DallasTemperature sensors(&oneWire); // Transfer of the OnewWire reference to communicate with the sensor.
    
    uint8_t address[][6] = {"1Node", "2Node"}; // Let these addresses be used for the pair
    bool radioNumber = 1; //to use different addresses on a pair of radios, we need a variable to uniquely identify which address this radio will use to transmit
    int sensorCount;
    
    float payload = 0.0; 
    int ID = 0; 
    float temperature = 0.0;
    float battery = 0.0;
    
    void setup() {
      Serial.begin(115200);
      while (!Serial) {
        // some boards need to wait to ensure access to serial over USB
      }
      
      // initialize the transceiver on the SPI bus
      if (!radio.begin()) {
        Serial.println(F("radio hardware is not responding!!"));
        while (1) {} // hold in infinite loop
      }
    
      // Set the PA Level low to try preventing power supply related problems
      // because these examples are likely run with nodes in close proximity to
      // each other.
      radio.setPALevel(RF24_PA_LOW);  // RF24_PA_MAX is default.
    
      sensors.begin(); // Start communication with the sensor
      sensorCount = sensors.getDS18Count(); // Reading the number of connected
    
      // save on transmission time by setting the radio to only transmit the
      // number of bytes we need to transmit a float
      radio.setPayloadSize(sizeof(payload)); // float datatype occupies 4 bytes
    
      // set the TX address of the RX node into the TX pipe
      radio.openWritingPipe(address[radioNumber]);     // always uses pipe 0
    
      // set the RX address of the TX node into a RX pipe
      radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
      
      radio.stopListening();  // put radio in TX mode
    
    } // setup
    
    void loop() {
    
      if(sensorCount ==0){
         Serial.println("No temperature sensors found");
         Serial.println("Please check your circuit!");
       }
      
      sensors.requestTemperatures();
      
        // This device is a TX node
        payload = sensors.getTempCByIndex(0);
        
        unsigned long start_timer = micros();                    // start the timer
        bool report = radio.write(&payload, sizeof(float));      // transmit & save the report
        unsigned long end_timer = micros();                      // end the timer
    
        if (report) {
          Serial.print(F("Transmission successful! "));          // payload was delivered
          Serial.print(F("Time to transmit = "));
          Serial.print(end_timer - start_timer);                 // print the timer result
          Serial.print(F(" us. Sent: "));
          Serial.println(payload);                               // print payload sent
        } else {
          Serial.println(F("Transmission failed or timed out")); // payload was not delivered
        }
    
        // to make this example readable in the serial monitor
        delay(1000);  // slow transmissions down by 1 second
    
    } // loop
    

Log in to reply
 

Suggested Topics

  • 3
  • 4
  • 15
  • 1
  • 2
  • 24

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts