pepeu
Posts: 18
Joined: Wed Jul 16, 2014 1:58 pm

Could someone make a guide on Pi <> Arduino with nRF24l01+?

Mon Sep 08, 2014 9:54 am

There are some guides out there, yes, but they all are referring to various Github packages which now has changed quite a bit and so the codes and/or command lines isn't working. On another forum thread I made (http://www.raspberrypi.org/forums/viewt ... 91&t=86104), I was trying to follow a guide which had the following command in it:

Code: Select all

g++ -Wall -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -L../librf24/  -lrf24 remote.cpp -o remote
And since the folders and files have changed, it's no longer valid. Instead it gives me some errors.

I bet the guides were great as long as the packages they use didn't change, but as it is now, it's not working.

Could someone lend a hand getting the two devices to communicate? Or maybe post an old package where the code still is valid and working.

User avatar
paul81828384
Posts: 27
Joined: Wed Aug 01, 2012 9:39 am

Re: Could someone make a guide on Pi <> Arduino with nRF24l0

Mon Sep 08, 2014 12:48 pm

Maybe not exactly what you are asking, but I had trouble getting the NRF24L01 to work directly with the Raspberry Pi. My workaround was to use two Arduinos and connect the Pi to one of them via USB and PySerial for communicating data values received via NRF24 from the other Arduino. All fairly easy for Serial comms from the Arduino side and the Pi side (Pyserial or the Arduino IDE serial monitor). There are Arduino libraries for NRF24 which do most of the work for you and the examples included in the libraries are pretty good.

Using two "official" Arduinos can be a bit pricey but I made my own by soldering a simple unit on stripboard containing a Uno bootloaded AtMega328p, a crystal, caps, a Voltage regulator to step down from 5v to 3.3V for the NRF24 and connections for the NRF (an IC holder cut in half and the two halves placed back to back to create the narrow pin socket for the NRF to plug into). I soldered a USB B connector to the board as an easy power supply input (works off a USB phone charger and a printer cable) and added pins for the serial programming function of the ATMega chip. I then connected to the Pi via a USB - TTL converter which you can connect and disconnect as required. That way you can use one converter to program any number of home made arduinos - although for serial transfer you will need one full time to connect from the Pi.
You can also program the arduino direct from the Pi using the Arduino IDE to avoid plugging and unplugging.

There are lots of circuits around for DIY arduino setups and they really are very simple - especially if you ditch the onboard USB and just have header pins for a Serial - TTL converter. I built myself three and they came in for around £5 or so each. You can add i/o pins or terminal connectors to connect various sensors etc. I have used and re-used mine on several different projects. Cheap as chips and very useful for quick experiments and projects. I am even using one at the moment as a quick and dirty way to power a 5v fan from a PC USB socket to aid cooling in a not-ideal shelf location - not using the AtMega chip at all!

Hope this helps
Paul
Pi/Python/Arduino dabbler

pepeu
Posts: 18
Joined: Wed Jul 16, 2014 1:58 pm

Re: Could someone make a guide on Pi <> Arduino with nRF24l0

Tue Sep 09, 2014 3:47 pm

Thank you for your help, Paul! I will take a look at that solution at some point. But I really want it to work like this first. The guides just needs to get updated and then they should be working fine. I just wish they could do it ... now! :O)

pepeu
Posts: 18
Joined: Wed Jul 16, 2014 1:58 pm

Re: Could someone make a guide on Pi <> Arduino with nRF24l0

Tue Sep 16, 2014 8:19 pm

Are we really the only two doing this project now? I thought this would be one of the "must" projects to play with. :O)

kropbj
Posts: 3
Joined: Sat Sep 20, 2014 4:25 am

Re: Could someone make a guide on Pi <> Arduino with nRF24l0

Sat Sep 20, 2014 4:27 am

I'm trying to figure the setup for this as well. No luck so far. Just as you said, there seems to be a lot of miss information out there and things have changed. I'll keep you posted if I figure anything out.

kropbj
Posts: 3
Joined: Sat Sep 20, 2014 4:25 am

Re: Could someone make a guide on Pi <> Arduino with nRF24l0

Sun Sep 21, 2014 3:54 am

I've got my Raspberry Pi and an Arduino successfully setup using the nrf24l01+ radios today.
I used a newer modified version of RF24 libraries that you see quite commonly floating around on the internet.
The information and instructions can be found on TMRh20's Project Blog. http://tmrh20.blogspot.ca/
The libraries for the RPi and the Arduino can both be found here. https://github.com/TMRh20/RF24

pattoj79
Posts: 1
Joined: Sat Sep 27, 2014 9:51 am

Re: Could someone make a guide on Pi <> Arduino with nRF24l0

Sat Sep 27, 2014 1:06 pm

I've been trying for a while now and I can't seem to get the nRF24L01+ to work on my Raspberry Pi B+. I have tried pretty much everything I can find online to get it to do something and I get nothing. I can only get zero's... Are you guys able to help? I can get them to talk between 2 Arduinos no worries but not to the RPi.

Everything online points to RPi B v1 or v2 but i have a B+ and I would have thought that it wouldn't matter because the SPI & GPIO pins are the same. I am also using Occidentallis v0.2.

Pin connections are:
CE - Pin 22
CSN - Pin 26
VCC - Pin 17
GND - Pin 25
MOSI - Pin 19
MISO - Pin 21
SCK - Pin 23
IRQ - Not used

Various methods tried but with no result and I'v tried the same with Various CE and CSN pins;

RF24 radio(RPI_V2_GPIO_P1_15,BCM2835_SPI_CS1, BCM2835_SPI_SPEED_8MHZ)
RF24 radio(RPI_V2_GPIO_P1_15,RPI_V2_GPIO_P1_26, BCM2835_SPI_SPEED_8MHZ)
RF24 radio("/dev/spidev0.0",8000000,25); (Or variations of this)

They all give the same result...... Zero's. Refer to file - and you will notice it calls for nrf24L01 and not the plus version, and not sure that makes difference.
Capture.JPG
Zero's Screen Capture
Capture.JPG (38.77 KiB) Viewed 6899 times
I'm just trying to get the "getting started" to work.

If you guys have done your own step by step guide it would be very useful. I have tried TMRh20 but again the same result.

If you could let me know the following it would be a massive help also;
RPI pin configuration
What you use to call the pins in your code RF24 radio(xxxx)
RPi model
Software Platform (NOOBS, Occidentallis etc)

If you could post your code that works it would help also.
Thanks in advance.

kropbj
Posts: 3
Joined: Sat Sep 20, 2014 4:25 am

Re: Could someone make a guide on Pi <> Arduino with nRF24l0

Sat Sep 27, 2014 3:14 pm

I'll create some documentation as soon as I can and post it up.
I have not yet been able to customize the libraries in a way that I can send sensor data. But I have been able to get most of the example to work. There are some that don't seem to work or they work intermittently. I'm no electronic wiz but I understand enough I think.

tmrh20
Posts: 1
Joined: Sun Sep 28, 2014 3:18 pm
Location: Canada
Contact: Website

Re: Could someone make a guide on Pi <> Arduino with nRF24l0

Sun Sep 28, 2014 3:52 pm

I've just updated the RF24 library(https://github.com/TMRh20/RF24/archive/master.zip) to include the latest BCM2835 driver (1.37) which adds support for the B+. I don't have a B+ to test with, so feedback is always helpful.

The updated and modified BCM driver is included with RF24, but docs etc. can be found here: (http://www.airspayce.com/mikem/bcm2835/) The download link appears to be out of date, but should point here: (http://www.airspayce.com/mikem/bcm2835/ ... .37.tar.gz)

Pins can be specified slightly differnently from RPi B:
RPi B example: RPI_V2_GPIO_P1_24
RPi B+ example: RPI_BPLUS_GPIO_J8_24

See http://www.airspayce.com/mikem/bcm2835/ ... 57736d0939 for pin info

A quick-start guide is shown here:
https://github.com/TMRh20/RF24/tree/master/RPi/RF24
The RF24 documentation is here:
https://tmrh20.github.io/RF24

Good luck!

rahul.opengts
Posts: 4
Joined: Thu Aug 21, 2014 12:47 pm

Re: Could someone make a guide on Pi <> Arduino with nRF24l0

Wed Nov 19, 2014 6:59 am

Dear All,
need inputs and help while using raspberry pi B+.

I followed the steps mentioned at

https://github.com/TMRh20/RF24/blob/master/README.md.
I followed steps under "RPi - RF24 Quick-Start" on this page.
I used RF24 radio(RPI_BPLUS_GPIO_J8_15,RPI_BPLUS_GPIO_J8_24, BCM2835_SPI_SPEED_8MHZ); in the constructor.

Also, followed the connection mentioned in the table.

My NRF24L01+ initializes properly, but fails while sending the data. it says "failed" and timed out.

Can someone help me in resolving this if anyone has used this for raspberry pi B+

Thanks.
Rahul

rahul.opengts
Posts: 4
Joined: Thu Aug 21, 2014 12:47 pm

Re: Could someone make a guide on Pi <> Arduino with nRF24l0

Thu Nov 20, 2014 4:29 am

Dear All,
Just to update, I got my raspberry pi B+ running with NRF24L01+.

But it works only when I put setAutoAck(0) on transmitter/receiver.

Anyone having any idea , please help. I am also investigating further.

Regards,
Rahul

freezkyd
Posts: 8
Joined: Wed Aug 19, 2015 5:18 am

Re: Could someone make a guide on Pi <> Arduino with nRF24l0

Wed Aug 19, 2015 7:08 am

What did you find finally ? I am having the same problem.

Madhu3
Posts: 9
Joined: Thu Jan 14, 2016 8:14 am

Re: Could someone make a guide on Pi <> Arduino with nRF24l0

Sat Mar 12, 2016 6:51 pm

Hello,
I am trying to make a new C file using the tmrh20 RF24 library in my Raspi 2. However, I am getting lots of errors, which I believe are due to the fact that the compiler is not recognizing these libraries.The examples work correctly. Could you please let me know, how to include these libraries in my program? Also whether I need to store new files in specific folders and how to debug them?

Following are the includes that I use in the program:
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <unistd.h>
#include <RF24/RF24.h>


Kindly let me know, if there is anything missing. Thankyou.

Madhu3
Posts: 9
Joined: Thu Jan 14, 2016 8:14 am

Solved it!

Mon Mar 14, 2016 2:35 pm

For those who are having similar problem as me, I would like to tell you that I have found the solution. Although it shouldn't make a difference, but my compilation was clear, when I used the header #include <RF24/RF24.h> before the other headers. Also, turns out that the syntax I was using for compilation was faulty. The online tutorials that most of us refer have a slight mistake in the statement used for compilation, which is as follows:

g++ -Wall -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -L../librf24/ -lrf24-bcm trial.cpp -o trial

Most blogs have different library root written in place of the part that I have highlighted. Use lrf24-bcm and that should solve most of the RF24::int main loop errors.
Hope it helps :)

rajeev2301
Posts: 22
Joined: Mon Jan 15, 2018 8:14 am

Re: Solved it!

Mon Apr 16, 2018 4:36 am

Madhu3 wrote:
Mon Mar 14, 2016 2:35 pm
For those who are having similar problem as me, I would like to tell you that I have found the solution. Although it shouldn't make a difference, but my compilation was clear, when I used the header #include <RF24/RF24.h> before the other headers. Also, turns out that the syntax I was using for compilation was faulty. The online tutorials that most of us refer have a slight mistake in the statement used for compilation, which is as follows:

g++ -Wall -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -L../librf24/ -lrf24-bcm trial.cpp -o trial

Most blogs have different library root written in place of the part that I have highlighted. Use lrf24-bcm and that should solve most of the RF24::int main loop errors.
Hope it helps :)
Hi
Exactly followed the steps you suggested above.. But I am still getting below error. g++ -Wall -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -L../librf24/ -lrf24 Test2.cpp -o Test2
/tmp/ccrOXkQh.o: In function `setup()':
Test2.cpp:(.text+0x4c): undefined reference to `RF24::setPALevel(unsigned char)'
/tmp/ccrOXkQh.o: In function `_GLOBAL__sub_I_radio':
Test2.cpp:(.text.startup+0xc0): undefined reference to `RF24::RF24(unsigned short, unsigned short, unsigned int)'

Can anyone help me identify the reason ?

Here is the code that I used.

Code: Select all

#include "RF24.h"
#include <cstdlib>
#include <iostream>
#include "RF24_config.h"
//#include "RF24.h"
//#include "/home/pi/RF24/RF24.h"
//#include "MyLibrary.h"
//#include "gpio.h"
#include "utility/RPi/spi.h"

RF24 radio(RPI_BPLUS_GPIO_J8_15,RPI_BPLUS_GPIO_J8_24, BCM2835_SPI_SPEED_8MHZ);
 
const uint64_t pipes[2] = { 0xE8E8F0F0E9LL, 0xF0F0F0F0D2LL };

//Init_sensors Sensor;


struct HuMotion1{
     float value;
     float Humidity;
     float Temp;
     bool Humidifier_Status;
     bool Lamp_Status;
     int Daytime;
     int HuMotion_loc;
    };

 HuMotion1 HuMotion11;
void setup(void)
{

  radio.begin();

  // optionally, increase the delay between retries & # of retries
  radio.setRetries(15,15);

  // optionally, reduce the payload size.  seems to
  // improve reliability
   radio.setDataRate(RF24_250KBPS);
   radio.setPayloadSize(sizeof(HuMotion11)); 
   radio.setChannel(0x4c);
   radio.setPALevel(RF24_PA_MAX);

  //
  // Open pipes to other nodes for communication
  //

  // This simple sketch opens two pipes for these two nodes to communicate
  // back and forth.
  // Open 'our' pipe for writing
  // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)

   radio.openReadingPipe(1,pipes[0]);
   radio.startListening();

  //
  // Dump the configuration of the rf unit for debugging
  //

    radio.printDetails();
}

void loop(void)
{
  
//sleep(1);
   if ( radio.available() )
    {
      // Dump the payloads until we've gotten everything
      //unsigned long got_time;
      bool done = false;
      uint8_t len = radio.getDynamicPayloadSize();
      while (!done)
      {
        // Fetch the payload, and see if this was the last one.
      radio.read( &HuMotion11, len);

        
       done =  printf(" Humidity Date From Arduino...");
        printf("%lf\n",HuMotion11.Humidity);

	// Delay just a little bit to let the other unit
	// make the transition to receiver
	//delay(20);
      }

      radio.stopListening();
    
     }
}

int main(int argc, char** argv)
{
        setup();
        while(1)
        loop();
        return 0;
}

rajeev2301
Posts: 22
Joined: Mon Jan 15, 2018 8:14 am

Re: Solved it!

Sun Apr 22, 2018 7:11 am

Hi ,
I have been developing a C++ code on Raspberry Pi3 using NRF24L01 module. I am able to compile the code successfully however I am unable to pull up the structure data from Arduino. Interestingly , Arduino to Arduino communication is working fine. Appreciate your help. Plz find the code below.

The output structure is just throwing ZERO value for all itś variables. Please ref to the code below.
Please help me uncover the error.

/*****************************************************/
#include <RF24/RF24.h>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <unistd.h>

using namespace std;

RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ);


const uint64_t deviceID = 0xE8E8F0F0E9LL;
bool role_ping_out = 1, role_pong_back = 0, role = 0;
uint8_t counter = 1;

struct HuMotion{
int value;
float Humidity;
float Temp;
bool Humidifier_Status;
bool Lamp_Status;
int Daytime;
int HuMotion_loc;
}myHuMotion1;

int main(int argc, char** argv)
{
setup();
myHuMotion1.value = 13;
myHuMotion1.Humidity =13.56;
myHuMotion1.Temp = 23.15;

sleep(1);
while (1)
{

if (radio.available())
{
radio.read( &myHuMotion1, sizeof(myHuMotion1));
printf("\nRadio is ON | ");
//radio.writeAckPayload(counter,counter , sizeof(counter));
printf(" Temp = %f " ,myHuMotion1.Temp);
//cout << myHuMotion1.value;
}
else
{
printf("\nRadio is OFF");
}

sleep(1);
}

} //main

void setup()
{
radio.begin();
radio.setRetries(15,15);
radio.enableAckPayload();
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_MAX); // Allow optional ack payloads
radio.enableDynamicPayloads();
radio.printDetails(); // Dump the configuration of the rf unit for debugging
radio.openReadingPipe(1,deviceID);
radio.powerUp();
}



****** Output ******

Radio is ON | Temp = 0.000000

Return to “Troubleshooting”