NRF24 / Arduino / Ethernet

Hi all,

I’ve been experimenting with a network of NRF24 radio transmitters. Because of the ease of use and their cheapness of course. It’s pretty easy to setup a monitoring network with all kinds of sensors exchanging data. Because it’s 2.4 Ghz it’ll get pretty far.

Anyway, there is a big caveat when using these sensors. In case of ethernet connectivity with your Arduino. It shares the bus (SPI) with the Ethernet adapter. There possibly is some wrong coding in some of the libraries, either the RF24 (which I use) in combination with the BlinkEthernet. After about a day I need to reset my Arduino.

I’m not sure where the error exactly occurs, but of course both NRF and Blynk need some sort of way to keep the network alive and I’m guessing at a certain point they start talking together through the SPI which can result in disaster and global warming (if you have your heater on it, lol).

The last two days I’ve disabled the NRF part and so far it seems to be working stable. So be warned, this may be a bad combination, but I’m not done trying. There are some other NRF24 libraries out there, but the RF24 / RF24Network libs are really easy to use and also compatible with a lot of other transceivers like regular 433mhz domotic stuff.

If anybody has more information or experience with this, I’d love to share some thoughts :slight_smile:

I was just going to try the same. Want to explore how low power this kind of setup can get.
My idea is to use radio for all sensors, ESP8266 for all controllers (because they can be closer to power source)

Never thought about the limitation you shared. Please keep updated on how it goes.

Low power is relative. I assume you know the ESP takes some power. I suspect this is also true for the NRF. I still need to fiddle with the power sources. It may be just that, but for now I’m suspecting some coding issues because separately they work fine. But I think I power all the stuff via a 12v / 1A power supply. The Ethernet and NRF are powered via a DC / DC convertor to make 5v and it should be able to handle 2A, so I think the power is not really the issue, but since I don’t have equipment for measuring that I can’t be sure. The only way for me to find out is experiment, lol.

Radio stuff requires lots of power in comparison to “just” electronics. This is inherent to the nature of the device and how they work. Low power means very low range. The NRF can be adjusted for low power output via the RF24 library though. There are some example codes (you can check my complete code at the vpin / timer topic, it also mentions the NRF module).

May be I was not detailed enough. What I meant is that many sensors are not required to take measurements often - they could just wake up once in an hour, work for 30 sec and send data to the hub (arduino / raspberry).

That is very true. However, at the receiving side you never know when you will be receiving stuff. And that is where the SPI bus won’t match. A solution would be to use the ESP via Serial but I like my “main” Arduino to be the master and have a decent ethernet connector (it won’t move anyway).

Therefor I need the RF network to be constantly active on the receiving side. But I see where you are getting it. It may be nice to go the other way around and use a “pull system” on the main device instead of it waiting to receive data and spent CPU cycles on keeping your RF network online.

I have to think about the logic in that somewhere, but I think it could make sense. Maybe use a sort of initial “hey I wanna talk” message to your sensor and if that’s received enter a “yo man, tell me your sensor value”-state.

That could actually work a lot better then just wait to receive a message.

1 Like

Just wana share my experiment with nrf24, esp8266 and blynk. I’m pretty happy with what I’ve done so far.
At first I tried RF24 / RF24Network libs but not so easy to configure with blynk. So I tried the mysensors lib and it works really great.

Here is my settup:

  • HW: esp8266 + nrf24 ; SW: blynk + mysensors gateway (the brain, translate blynk command to mysensors command)
  • HW: arduino pro mini + nrf24 + temp/humidity ; SW: custom mysensors node ( wakes up every 30min to measure battery level, humidity and temperature) 1 inside & 1 outside
  • HW: arduino pro mini + nrf24 + IRFZ44N; SW: mysensors dimmable led node
  • HW: arduino pro mini + nrf24; SW: mysensors dimmable RGB led node
  • HW: arduino pro mini + nrf24 + motion detector; SW: custom mysensors node

As I said, work pretty well.
I know I can do less coding by using an esp8266 chip by node and use the bridge widget of blynk but my first need was to have a network of sensors that can work together without internet connection. In this way, your home automation script can still run even if your internet connection is down (well you can set up your own blynk home sever but …).

1 Like

Could you please add more explanations, may be photos, code, links to resources. I’m going to build very similar thing, so it would be so helpful. I never worked with RF24.


1 Like

Currently I’m building a “big” testboard to incorporate a lot of different elements. I want to be able to test all sorts of stuff on it. A sort of custom breadboard. I’ll post some pictures and descriptions soon.

The plan is to add at least the following components:

  • Arduino Nano (done)
  • NRF2.4 Ghz (done)
  • Dallas temp sensor (done)
  • ENC28J60 Ethernet port, TODO (SPI interface)
  • LCD 16x2 display, TODO (non-I2C)
  • ESP-01, TODO (as Shield, plus buttons to program the firmware)
  • Seperate PSU’s for both 3.3v and 5v, TODO (w/ possibility to disconnect them)

Maybe I’ll add some other universal stuff to do more testing and there probably will be some status LEDs.

This way I can quickly check to see how stuff works, including, but not limited to, how they interact.

1 Like

Well, I didn’t have the code right now and it is still kind of dirty prototyping code.

Here are some step to start with the mysensors libs (

  1. First, you can follow the get started.
  2. You should understand the protocol & API sensorAPI & serialAPI.
  3. Assuming you have the hardware, start building your first node, you can find lot of standard stuff here.
    ex: Let say we want a temperature sensor node
  4. Then connect the radio.
  5. Now you’re first node is ready to use. I would recommend to start with a serial gateway not the esp8266 gateway.
  6. Set up the serial gateway (ex: Adruino UNO + nrf24) with the serial gateway code.
  7. Try this very handy PC software, it acts as the controller of the serial gateway
  8. You should be able to see and send messages with the controller

When you are comfortable with the mysensors API, you can switch your serial gateway to the esp8266 gateway.
The esp8266 wifi gateway start a server at the esp wifi adress, I removed all that stuff since I wanted to use it with blynk. So you can clean up the code to fit your need and add the blynk esp8266 standalone feature.

In my setup, I used only the virtual pin as I/O, send mysensors command to some sensors node and receive mysensors data from node.

For example, to turn ON a led strip node with a blynk push button on virtual pin 0 :


Here, THE_LED_STRIP_SENSOR_ID is the ID of the led strip on the node (1 node can have up to 255 sensors connected to it) and the THE_LED_STRIP_NODE_ID is the address of the led strip node in the nrf24 network.
Hope I’m not confusing you guys (in my setup, if I remember correctly, THE_LED_STRIP_SENSOR_ID=0, THE_LED_STRIP_NODE_ID=1).

If you want something more robust, you can use the ack of MyMessage and somewhat send the message every sec until the ack is received, didn’t tried yet but on my toto list.

But for me, mysensors is more a domotic framework, so I’m planning to switch the esp8266 to a raspberrypi in order to play with some home automation software (openHAB etc …) and use blynk as remote control.

Hope it helps. Blynk is awesome, keep up the good work!!
And sorry @Lichtsignaal to steal your topic (no Ethernet here) :wink:


Lol, np dude :smile:

Knowledge and experience should be shared.

I think I found a little something. Check out this website:

It explains the usage of multiple SPI devices on the Arduino. Currently I’m running a QVGA screen and the NRF module on the SPI bus both with different SS lines. I’m gonna add an ethernet interface later, but mine doesn’t work with Blynk anymore so I have to wait for a new one. Weird though, it works with UIP lib samples perfectly.

Anyway, just a heads up if you use multiple SPI devices on the same Arduino. It could have consequences.


I’ve been testing a couple things in combination with each other:

  1. ENC + QVGA display = no go. The LCD messes up the SPI communication. Even with CS manually set to low you still can’t operate your ethernet
  2. ENC + NRF = maybe workable. The netwerk interface still works, haven’t tested the NRF yet though.
1 Like

Hallo Lichtsignaal,
From day one using Blynk, I’ve been working with an Arduino Ethernet board and Mega both using a nRF24L01 to exchange (bidirectional) messages. To give a bit more context, the mega is the core component of a standalone burglar alarm while the Ethernet is the bridge of all future projects towards internet.
I could write pages with trial & errors but I’ll jump to conclusions. Basically I had to rely on a SoftSPI library due to the pinout of the Ethernet board. This site helped me out to get the basics working:
Until this site came along: I’ve tested this couple of weeks ago with 4 boards and worked like a charm! So, this afternoon I was able to convert my code using the RF24Network library successfully, which now opens the door for the integration of new projects. =)

One large caveat is with my current code the Arduino Ethernet (which is basically an Uno) now uses (99%) of program storage space. 50% of this goes to the Blynk codes, which is massive! The only way to reduce that is to give in some virtual pins and usability but I dislike the idea. Second option (roughly 20% of storage) is the UDP/NTP feature. I’m getting my clock via NTP over internet as I initially had time drift issues using both I2C LCD and RTC (Real Time Clock) Module on the same SPI bus. I might reconsider to investigate the root case but for now NTP clock is less hassle. 3rd option is to change the board.

My lessons learned for now is use the correct basic libraries (RF24 & SoftSPI) to start with (there are a lot of incompatibles out there). Scope your wireless design first, choose the correct transmitters (and powersup’s) knowing these standard antennas hardly travers through think brick walls. Lastly, if you think you’ll need lots of code you might want to look for a Mega (+ENC28J60), although I haven’t used this Ethernet module yet. Is it recommendable? I’m not sure if I’ll use it as I expect my UDOO NEO to arrive any day now and got a brand new Onion Omega (but fairly useless without the breakout board in backlog).



I do know how to get the RF24 working. That part already works quite nice. The ENC is what I’m using and I’m guessing there is something in that library what messes up the SPI interface. I’ll give the softSPI a go. It may be enough to get everything going ok since the RF24 doesn’t require much bandwidth and it could be push/pull instead of continuous use, like an ethernet interface needs.

I still haven’t been able to get the ENC working stable. It disconnects every couple days so I may be do something wrong, but it could also be a caveat in the library.

I think most people who write libraries for the hardware just don’t really care about how to really use the SPI bus since it should support multiple devices. Ah well, gonna fiddle around a bit more, thanks very much for your input!

a bit late … it seems I didn’t pressed the Reply button :blush:

Then allow me to help you a bit more as there are a lot of them too and there is nothing more fustrating looking for correct libaries instead of doing the real stuff. This is the Library I’m using without any issue (for many months):

You’ll need both RF24Soft & DigitalIO to get it working AND you’ll need to remove your RF24 libary due to overlap/conflicts. There is a modified (hybrid) library out there to select either the soft or “hard” SPI, however I can’t get it working properly.

Nice information Gaitt, I’ve tried to treat the information from the node, but I couldn’t separate the values from the other informations in Mysensors Library. Could you give me a hand?
thanks a lot

I’m not 100% what you want to achieve, but you can send multiple values through the air with the NRF. You just have to create the correct constructor. Something like:

struct payload_t
  unsigned int messageMode;
  unsigned int messagePWM;
  unsigned int messageColor;
  unsigned int messageChannel;

Read out on other node:

int mode = payload.messageMode // Etc.

This will send four values to the other node. If you need a complete example for reading/writing with NRF please let me know, I happen to have something here for my trains, but it will serve your purpose too I think.

1 Like

Thanks a lot Lichtsignaal!

I’m trying to use multiple nodes connected by NRF, receive all the information, collect them and send to the Blynk App. Showing al the values in the mobile.

I’ve done the network with NRF24 network library an got the values, but as you said, it doesn’t permit to connect with ESP8266 with Blynk. That’s the reason I’m trying to use the Mysensors Library, because Gaitt said that it works.

I’ve connected the SerialGateway example in Mysensors Library, with one node example, but I cannot separate the vaues that I’m receiving, and I need to treat them to separate in different displays in Blynk APP.

I’m thinking too much how to send all the values “organized”, and I don’t know if its easier to use “2 nodes and a Gateway as a Central” or “3 nodes connected between each other” or “2 nodes connected to one node sending the information working like a central station”.

Please, If you have an example of how to do it, it would be great. How the send data from two different nodes trough NRF, receive the values at a thrid node, and connect to the blynk without any conflict, showing on the APP.

You would save me, really. Thanks a lot!!

I think the NRF library, if you use RF24, also has a sort of “multicast” send option, but I’m not sure how that works. It’s supposed to be able to send a messages to all nodes on the network at once. You could look into that.

Anway, short examples of code for sending messages. I’ll leave out the blynk part, but you can imagine that in between the lines, right? :wink:

Sending node:

#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>

/ RF24 ce, csn
RF24 radio(49, 48);
RF24Network network(radio);

// NRF addressing
const uint16_t controllerAddress  = 0;
const uint16_t nodeOneAddress = 1;
const uint16_t nodeTwoAAddress = 2;

struct payload_t
  unsigned int messageDataOne;
  unsigned int messageDataTwo;
  unsigned int messageDataThree;
  unsigned int messageDataFour;

void setup()

  // Init network on channel 90, with address of controllerAddress variable
  network.begin(90, controllerAddress);

void loop()
  // Keep NRF network going

  // Construct header with destination address
  RF24NetworkHeader header(nodeOneAddress);

  messageOne = analogRead(A0);
  messageTwo = analogRead(A1);
  messageThree = analogRead(A2);
  messageFour = analogRead(A3);

  // Construct message to be send
  payload_t payload_0 = { messageOne, messageTwo, messageThree, messageFour };
  network.write(header, &payload_0, sizeof(payload_0));


-sorry- pressed Enter too soon, rest of code will be here soon :stuck_out_tongue:

This will send the message containing the data every 5 seconds (in this case just a readout of the random fluctuating analog ports).

Receiving Arduino:

#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>

RF24 radio(9,10);
RF24Network network(radio);

struct payload_t
  unsigned int messageDataOne;
  unsigned int messageDataTwo;
  unsigned int messageDataThree;
  unsigned int messageDataFour;

const uint16_t nodeOneAddress = 1;

void setup() 
  network.begin(90, nodeOneAddress);

void loop() 

  while ( network.available() )
    RF24NetworkHeader header;
    payload_t payload;,&payload,sizeof(payload));


This should print the values every 5s to the serial screen :slight_smile:

If you want to add a third node, just change the nodeAddressOne variable on the second receiving arduino and send a message to there with the first sketch.

I’ve written it up here a bit more elegant:

It has the complete source code with Blynk added, you can refer to that too.

1 Like

Thank you very much! Nice project at instructables as well!

Just a last question, does the code with RF24 network, works with wifi interface ESP8266 and Blynk? Doesn’t it have any conflict between the SPI communication?

Thank you once more by the code, thanks!

Yes that should work fine because ESP uses TX/RX Serial communication. The SPI is another bus. I’m not sure about other shields, but this should do fine.

I got it working with an ENC ethernet interface which is actually also an SPI device, but I set the NRF to other pins for CE and CSN so both devices know when to talk and when to shut up :slight_smile: