16 responses to “Sending structs with nRF24L01 modules and the RF24 library”

  1. Robo

    Hello!

    What if you would like to send the analog values from potentiometer to another arduino? Do you have to do it using float? I’m struggling to send the values and provide it to the servo.

    Thanks!

  2. Vaclav

    Hello,
    thanks for the idea. I’m trying to make this work between Arduino and Raspberry Pi (with RF24 ported). The data send from Arduino to Raspberry gets through ok, but vice versa I have some issues with the struct contruct. It seems like some of the struct data gets mixed up.

    Anyway, I came back to this post to see if I didn’t miss anything important. Rereading the source, I don’t understand, why you created two structs – the A_t and the B_t. Wouldn’t just one type be enough? Then of course make two variables duino1 and duino2, but both of the same one type?

  3. pater

    @Vaclav, remember that representation of some variable types like float can be represented differently in memory on arduino and raspberry pi so it’s better to send them like integers (multiple by 100 for example)

  4. Mauro

    Many thank’s for the example… after many days of research and test with different sketch found on other page without results I found yours…..

    Now I’m able to send wireless from one arduino to the other data like temperature, pressure, UV etc.

    Ciao

    1. ddea

      Hi.

      I’m also working on getting my RPi Setup to recieve data structs, sending them from my arduino setup is easy thanks to this blog.

      Can anyone help with getting the RPi code working using https://github.com/stanleyseow/RF24 Fork?

      Thanks

      Ddea

  5. sevkisahin

    Hi, i have a question about nrf24l01. So, i want to sending measured gas ratio,temp.,humidity,day,month,..,clock information. And i tried some library but i didn’t get result yet. How to edit your code for my request ? Can you help me for this ?
    Thanks. Success in your works.
    Greetings from Turkey.

  6. MIGUEL

    thank you sooooooo much.

  7. Yngve

    Hi
    i have been using structs and send data between arduinos.
    But are struggling a bit related to sending 2 different structs from one Ardu to another.
    I have never got any think through yet, during my attempts with sending 2 different structs.
    Presumably it can be done with sending this struct by pipeA and that struct by pipeB and receiving mode by PipeC. The other Ardu will have RX pipeA and RX pipeB and TX pipeC.

    This below i have not tried, but it must be possible as well.
    Or actually just using one struct, with float and ints and bytes and so on, and having one byte for packet allocation. so when the RX are getting the message it check the allocation byte and than copy the package to a specific data map, and if its different allocation number it copies to another data map. So than Dates, temperature, and whatever you are sending will be copied to the correct variables.

  8. NRF24L01 Networking Completed | Paladin Enabling Technologies

    […] sending a payload containing a structure of data (A guide on how to implement this can be found here). In this structure I have the “transmission pathway” which is the relay node addresses […]

  9. Paavo

    Problem with power down.
    If VCC of radio or goes down and rises back again the program loop can’t find radio again. Same problem is when distance of devices grows too long.
    How to reset Arduinos in those cases or how to get radio contact again?

  10. DevDuino Sensor Node – Part 1 – Programming the DevDuino – Squix TechBlog

    […] How to send dataobjects over the air and this […]

  11. rema

    hi sir, i have to control the robot car project. Where the rear wheels in the form of a dc motor is controlled with flex sensors and front wheels in the form of a servo motor controlled by the accelerometer sensor. Robot controller with a car connected with nrf24l01. if one of the sensors to control I can. but if it combines both to control I can not. Both sensors transmit data simultaneously . dc motors and servo motors confused receive data so that its movement is chaotic. How should I fix this? can you help me.? Can I send my program to you and you see.? Please.

  12. Mr. Imhoff

    I’m sorry but I’m new to nRF24 modules and I love how simple the code is arranged, but I would like to see a diagram of how the wires are connected… Of course I don’t need VCC and GND, but the rest would be nice to have.

    1. Cyril

      Here are the connection details for Arduino and Raspberry Pi.

      Arduino

      Arduino Pin 11 to RF Module Pin 6 ( MOSI)
      Arduino Pin 12 to RF Module Pin 7 ( MISO )
      Arduino Pin 13 to RF Module Pin 5 ( SCK )
      Arduino Pin 7 to RF Module Pin 4 ( CSN )
      Arduino Pin 8 to RF Module Pin 3 ( CE )*** RF Module can only take 3.3V
      Arduino GND to RF Module Pin 1 ( GND )
      RF Module Pin 8 (IRQ) is not connected

      Raspberry Pi

      RPi GPIO9 (Pin 21) to RF Module Pin 7 ( MISO )
      RPi GPIO10 (Pin 19) to RF Module Pin 6 ( MOSI )
      RPi GPIO 11 (Pin 23) to RF Module Pin 5 ( SCK )
      RPi GPIO8 (Pin 24) to RF Module Pin 3 ( CE )
      RPi GPIO 25 (Pin 22) to RF Module Pin 4 ( CSN )
      RPI 3.3V (Pin 17) to RF Module Pin 2 ( VCC/3.3V )
      RPi Gnd (Pin 25) to RF Module Pin 1 (GND)

Leave a Reply

*