Categories
TUTORIALS

creating wireless communication across separate arduinos using nRF24L01 transceivers

In this tutorial we will learn how to use one arduino UNO’s, one arduino NANO and two NRF24L01 Transceivers to send CTA messages from a safe needle kit vending machine to a monitoring facility. 

What it does:

The  button is used as a quick remote response for seeking help with troubleshoots at the vending machine while requesting a safe needle kit or a Naloxone kit.  When the user pushes the button, the transceiver 1(transmitter ) at the vending machine will send a message to the transceiver 2 (Receiver) at the monitoring facility.

How it works:

Using the NRF24L01 transceiver modules we will demonstrate a simple way to create a wireless communication between two Arduinos that can be up to 100 meters apart. In the first Arduino we will have the pushbutton and one LED light. In the second Arduino we will have a second LED light. The transceiver 1 will send the message to the  transceiver 2 through the pushbutton input. This single push button controls both LED lights at both arduinos.

**This tutorial modifies the code from the Arduino Wireless Communication Tutorial, by Dejan Nedelkovski, www.HowToMechatronics.com.  

Wiring Image showing all tutorial parts

Parts Needed:

– Arduino UNO starter kit

– Arduino UNO Nano micro controller (or a second Arduino Board)

– One push button (or two if you want to make it more interesting!!)

– Jumper wires (female /female, male/female)

– NRF24L01+PA+LNA Wireless Transceiver RF Transceiver Module 2.4G 1100m (2 pcs)

-330K photo resistors (1)

-10k photo resistors (1)

– Antenna in Antistatic Foam Compatible Arduino (2 pcs) 

– Yellow and red LED’s (2 pc)

Circuit/wiring

1. Plug in your Arduino UNO and Arduino NANO to their respective breadboards

2. Prepare your two – NRF24L01+PA+LNA Transceivers with the antennas and plug in the wires as shown in the chart and diagram below.

***(if your Arduino has more digital pins, you can change your pins for MISO, MOSI, SCK, CE like in this example: www.HowToMechatronics.com )***

3. Wire your pushbutton and your red LED to the Arduino UNO.

4. Wire your yellow LED to the Arduino Nano. 

Code

1. First, make sure you download the ZIP file for this library (Optimized fork of nRF24L01 for Arduino & Raspberry Pi/Linux Devices): TMRh20/RF24, https://github.com/tmrh20/RF24/

2. Open your Arduino software and add the library:

3. COPY the Transmitter code and PASTE it into a new empty sketch file.

4. COPY the Receiver code and PASTE it into your a new empty sketch file.

5. SAVE the Transmitter and Receiver sketches in TWO separate files

6. LOAD the Transmitter Code to the Arduino UNO/Transceiver 1. You must upload this code BEFORE uploading the receiver code. Make sure your arduino board is set to GENUINO/UNO and the proper port.

7. LOAD the Receiver Code to the Arduino NANO/Transceiver 2. Keep the receiver connected to your computer so that you are able to open the serial monitor. Make sure your arduino board is set to Arduino NANO and the processor to ATmega328p (Old Bootloader).

8. Use a USB wall charger adapter (similar to those use for phones, output of 5V) and plug in your Arduino UNO/Transceiver 1 to the wall.

9. While your serial monitor is open, push the button at the Arduino UNO/Transceiver 1. Notice how the LED’s at both Arduinos are turning ON and the serial monitor in the receiver is getting a message from the Arduino UNO/Transceiver 1.

You’re done!!

***Final Notes:

Several manipulations can be done to the LED’s blinking pattern and the amount of push button inputs accross transmitters. Feel free to leave any comments, suggestions or ask any questions. Thank You!!

References:

nRF24L01 – How It Works, Arduino Interface, Circuits, Codes

One reply on “creating wireless communication across separate arduinos using nRF24L01 transceivers”

I hv tried with same (single push button), and with two buttons, and two led outputs at receiver end. Working fine. But when I increase the no of buttons to 3, or 4, 5 in the same way. It is not working. Either flicker, or don’t respond, erratic .
Plz suggest can I not send 5 inputs to receiver with nrf24l01. Tr Nano, Rcv Uno.

Leave a Reply

Your email address will not be published. Required fields are marked *