Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. raspberrry pi 4 + rf24 receives data from arduino + rf24

raspberrry pi 4 + rf24 receives data from arduino + rf24

Scheduled Pinned Locked Moved Troubleshooting
6 Posts 2 Posters 106 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Stoica AndreeaS Offline
    Stoica AndreeaS Offline
    Stoica Andreea
    wrote on last edited by mfalkvidd
    #1

    Hello!

    I have a Raspberry Pi 4 with a nrf24l01 module connected that has to receive data (temperature measured by a DHT) from an Arduino that also has a nrf24l01 connected to it. I want to implement it to Openhab, but first I am trying to see in the terminal if the connection is ok - currently it fails (it doesn’t receive any data). Here are the steps I have taken.

    I have connected the Arduino to the nrf24l01 module and to a DHT sensor as it follows:

    nrf24l01             Arduino Uno
    GND                    GND
    CE                       pin 4
    SCK                     pin 13
    MISO                   pin 12
    VCC                     3.3V
    CSN                     pin 2
    MOSI                   pin 11
    IRQ                      to nothing
    

    The code on the Arduino is:

    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached 
    #define MY_RADIO_RF24
    //#define MY_RADIO_RFM69
    //#define MY_RS485
    
    // Enable serial gateway
    #define MY_GATEWAY_SERIAL
     
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DHT.h>
    
    // Set this to the pin you connected the DHT's data pin to
    #define DHT_DATA_PIN 3
    
    #define DHTTYPE DHT11
    
    // Sleep time between sensor updates (in milliseconds)
    // Must be >1000ms for DHT22 and >2000ms for DHT11
    static const uint64_t UPDATE_INTERVAL = 60000;
    
    #define CHILD_ID_TEMP 2
    
    float lastTemp;
    uint8_t nNoUpdatesTemp;
    bool metric = true;
    
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    DHT dht(DHT_DATA_PIN, DHTTYPE);
    
    void presentation()  
    { 
      // Send the sketch version information to the gateway
      sendSketchInfo("Temperature", "1.1");
      
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_TEMP, S_TEMP);
    }
    
    
    void setup()
    {
      dht.begin();
    }
    
    
    void loop()      
    {  
      // Get temperature from DHT library
      float temperature = dht.readTemperature();
      
      send(msgTemp.set(temperature, 1));
    
      // Sleep for a while to save energy
      sleep(UPDATE_INTERVAL); 
    }
    

    The wiring scheme for the Raspberry Pi 4 is:
    55160dd0-8293-40a0-a7a7-fc0224d977d6-image.png

    I have followed the instructions at https://www.mysensors.org/build/raspberry with the following configurations:
    --my-transport=rf24
    --my-gateway=serial --my-serial-is-pty —my-serial-port=/dev/ttyMySensorsGateway

    I have build the gateway but when I test it with sudo ./bin/mysgw I get the following error message:

    9cc37d23-4d40-4277-98ee-db7b7717712c-image.png

    Do you know what may cause the error? I am relatively new and I didn’t try debugging it yet.

    Thanks!

    mfalkviddM 1 Reply Last reply
    0
    • Stoica AndreeaS Stoica Andreea

      Hello!

      I have a Raspberry Pi 4 with a nrf24l01 module connected that has to receive data (temperature measured by a DHT) from an Arduino that also has a nrf24l01 connected to it. I want to implement it to Openhab, but first I am trying to see in the terminal if the connection is ok - currently it fails (it doesn’t receive any data). Here are the steps I have taken.

      I have connected the Arduino to the nrf24l01 module and to a DHT sensor as it follows:

      nrf24l01             Arduino Uno
      GND                    GND
      CE                       pin 4
      SCK                     pin 13
      MISO                   pin 12
      VCC                     3.3V
      CSN                     pin 2
      MOSI                   pin 11
      IRQ                      to nothing
      

      The code on the Arduino is:

      // Enable debug prints
      #define MY_DEBUG
      
      // Enable and select radio type attached 
      #define MY_RADIO_RF24
      //#define MY_RADIO_RFM69
      //#define MY_RS485
      
      // Enable serial gateway
      #define MY_GATEWAY_SERIAL
       
      #include <SPI.h>
      #include <MySensors.h>  
      #include <DHT.h>
      
      // Set this to the pin you connected the DHT's data pin to
      #define DHT_DATA_PIN 3
      
      #define DHTTYPE DHT11
      
      // Sleep time between sensor updates (in milliseconds)
      // Must be >1000ms for DHT22 and >2000ms for DHT11
      static const uint64_t UPDATE_INTERVAL = 60000;
      
      #define CHILD_ID_TEMP 2
      
      float lastTemp;
      uint8_t nNoUpdatesTemp;
      bool metric = true;
      
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      DHT dht(DHT_DATA_PIN, DHTTYPE);
      
      void presentation()  
      { 
        // Send the sketch version information to the gateway
        sendSketchInfo("Temperature", "1.1");
        
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID_TEMP, S_TEMP);
      }
      
      
      void setup()
      {
        dht.begin();
      }
      
      
      void loop()      
      {  
        // Get temperature from DHT library
        float temperature = dht.readTemperature();
        
        send(msgTemp.set(temperature, 1));
      
        // Sleep for a while to save energy
        sleep(UPDATE_INTERVAL); 
      }
      

      The wiring scheme for the Raspberry Pi 4 is:
      55160dd0-8293-40a0-a7a7-fc0224d977d6-image.png

      I have followed the instructions at https://www.mysensors.org/build/raspberry with the following configurations:
      --my-transport=rf24
      --my-gateway=serial --my-serial-is-pty —my-serial-port=/dev/ttyMySensorsGateway

      I have build the gateway but when I test it with sudo ./bin/mysgw I get the following error message:

      9cc37d23-4d40-4277-98ee-db7b7717712c-image.png

      Do you know what may cause the error? I am relatively new and I didn’t try debugging it yet.

      Thanks!

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      Welcome to the forum @Stoica-Andreea

      TSM INIT TSP FAIL means that the Raspberry Pi is unable to talk to the nrf24. Double/triple-check the wiring. If you can't find anything wrong, post photos from multiple angles and we'll try to spot the problem. An extra pair of eyes can often help.

      Also try to switch the nrf24. It could be broken.

      If you haven't already, see https://forum.mysensors.org/topic/666/read-this-first-it-could-save-you-a-lot-of-time/ for the most common problems and how to troubleshoot them efficiently.

      1 Reply Last reply
      0
      • Stoica AndreeaS Offline
        Stoica AndreeaS Offline
        Stoica Andreea
        wrote on last edited by
        #3

        Thanks a lot for the reply! It was very useful. After debugging I came to the conclusion that one of the nrf24 modules was faulty.

        1 Reply Last reply
        1
        • Stoica AndreeaS Offline
          Stoica AndreeaS Offline
          Stoica Andreea
          wrote on last edited by
          #4

          I have replaced de nrf24 sensors and I managed to get the right message for testing:
          Screenshot 2020-10-27 at 18.26.04.png

          I am confused because I have read a lot of posts and I couldn't find a clear answer.
          I want to use the rpi as the gateway without connecting a controller via the usb port. Still, I have used ./configure with the serial gateway tags as explained in this tutorial https://www.mysensors.org/build/raspberry because I have read that the port can be virtual and it doesn't need a controller connected to the rpi. The mysgw.service is up and running at every boot of the rpi.

          I am working with openhab and I need to display the measured values on the web site. Here is the debug window for openhab.Screenshot 2020-10-28 at 15.07.38.png

          Do you have any suggestions or tutorials I can follow?

          mfalkviddM 1 Reply Last reply
          0
          • Stoica AndreeaS Stoica Andreea

            I have replaced de nrf24 sensors and I managed to get the right message for testing:
            Screenshot 2020-10-27 at 18.26.04.png

            I am confused because I have read a lot of posts and I couldn't find a clear answer.
            I want to use the rpi as the gateway without connecting a controller via the usb port. Still, I have used ./configure with the serial gateway tags as explained in this tutorial https://www.mysensors.org/build/raspberry because I have read that the port can be virtual and it doesn't need a controller connected to the rpi. The mysgw.service is up and running at every boot of the rpi.

            I am working with openhab and I need to display the measured values on the web site. Here is the debug window for openhab.Screenshot 2020-10-28 at 15.07.38.png

            Do you have any suggestions or tutorials I can follow?

            mfalkviddM Offline
            mfalkviddM Offline
            mfalkvidd
            Mod
            wrote on last edited by
            #5

            @Stoica-Andreea In an earlier post, you said that you had set the name of the serial port to /dev/ttyMySensorsGateway. The openhab debug window says that it tries to open /dev/ttyAMA0. The gateway and openhab need to use the same name.

            Stoica AndreeaS 1 Reply Last reply
            0
            • mfalkviddM mfalkvidd

              @Stoica-Andreea In an earlier post, you said that you had set the name of the serial port to /dev/ttyMySensorsGateway. The openhab debug window says that it tries to open /dev/ttyAMA0. The gateway and openhab need to use the same name.

              Stoica AndreeaS Offline
              Stoica AndreeaS Offline
              Stoica Andreea
              wrote on last edited by
              #6

              @mfalkvidd I have renamed it to /dev/ttyAMA0

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              22

              Online

              11.7k

              Users

              11.2k

              Topics

              113.1k

              Posts


              Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • MySensors
              • OpenHardware.io
              • Categories
              • Recent
              • Tags
              • Popular