Basic: Project 083d
Project name: ESP8266 ESP-12E module and NRF24L01 2.4GHZ RF transceiver module – Button and LED
Tags: Arduino IDE, ESP8266 ESP-12E module, Nodemcu v3, Lolin, nRF Serial Adapter, nRF24L01, 2.4GHZ NRF24L01 Module, with PA LNA SMA antenna, NRF24L01 transceiver module, WINGONEER, PA, SMA and LNA with antenna , 2.4G NRF24L01 antenna wireless transceiver module, Arduino, Arduino Uno, Arduino Mega, Arduino Nano, Arduino using NRF24L01 RF module, RF transceiver module, 2.4G, antenna in antistatic foam, wireless transceiver module kit, SPI wireless data transmission module, wireless data acquisition, NRF serial adapter, 5V-3.3V VCC adapter board for NRF24L01 wireless module, breakout adapter for NRF24L01, shield for NRF24L01 with ATMEGA48, base module for nRF24L01 with 3.3V regulator, socket adapter plate for 8pin NRF24L01, ATMEGA48 and NRF24L01 interface, USB adapter for NRF24L01, YL-105, YL 105, AS01-ML01DP3, Arduino Wireless Communication, nRF24L01 – 2.4GHz RF Transceiver With Arduino, nRF24L01 Arduino,button, momentary switch, LED
Attachments: transmittersketch, receiversketch, library2
In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):
1. ESP8266 ESP-12E module and Micro USB cable 1pc

2.Arduino IDE (you can download it here)
3. Breadboard 1 pc

4. NRF24L01 2.4GHZ RF transceiver module without or with external antenna PA LNA SMA – 2pcs

5. Jumper wires F-M, F-F

6. Arduino Nano with Mini-B USB cable 1pc

7. Button (momentary switch) 1 pc

8. Resistor 2 pcs (10KOhm, 220 Ohm)

9.LED (green or any color) 1 pc

General
We will learn how to turn on/off LED attached to ESP8266 ESP-12E module using button(momentary switch) attached to Arduino Nano via NRF24L01 transceiver module. The transmitter will be Arduino Nano with NRF24L01 transceiver module and receiver – ESP8266 ESP-12E module with NRF24L01 transceiver module.
Understanding the momentary switch
You can read more about it here.
Understanding the Arduino Nano
You can read more about it here.
Undestanding the NRF24L01 2.4GHZ RF transceiver module
You can read more about it here.
Understanding the ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3)
You can read more about it here.
Signals and connections of LED
The operating voltage of the LED is 1.8V and the operating current is 10mA-20mA. The Arduino Uno board can supply 5V or 3.3V power. We will use 5V for this project, so the minimum resistance of the current limiting resistor should be (5 V to 1.8 V)/20 = 160 Om. The 220 Om offered in the kit is suitable and you can also choose other resistors that meet the condition. The larger the resistance is, the dimmer the LED will get.
Signals and connections of the NRF24L01 2.4GHZ RF transceiver module
You can read more about it here.
Signals and connections of the Arduino Nano
You can read more about it here.
Signals and connections of the ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3)

TX – transmit pin. GPIO pin
RX – receive pin. GPIO pin
3V3 (or 3V or 3.3V)- power supply pin (3-3.6V).
GND ( or G) – ground pin.
RST – reset pin. Keep it on high (3.3V) for normal operation. Put it on 0V to reset the chip.
EN – Chip enable. Keep it on high (3.3V) for normal operation.
Vin – External power supply 5VDC.
D0-D8 – GPIO (General Purpose Input Output) pins
D5-D8 – SPI interface
D1-D2– I²C/TWI Interface
SC (or CMD) – (Chip Select) – the pin that the master can use to enable and disable specific devices. GPIO pin
SO (or SDO) – Master In Slave Out (MISO) – SPI communication. The Slave line for sending data to the master. GPIO pin
SK (or CLK) – SCK (Serial Clock) – SPI communication.The clock pulses which synchronize data transmission generated by the master. GPIO pin
S1 (or SD1) – Master Out/Slave In (MOSI). SPI communication. The Master line for sending data to the peripherals. GPIO pin
S2 (or SD2) – GPIO pin
S3 (or SD3) – GPIO pin
VU (or VUSB) – external power 5VDC.
A0 – ADC output.
RSV – reserved
Wiring
1.Receiver side

NRF24L01 transceiver module adapter | ESP8266 ESP-12E module |
VCC | VV(5V) |
GND | GND (G) |
CE | D4 (GPIO2) |
CSN | D2 (GPIO4) |
SCK | D5 (GPIO14) |
MOSI (MO) | D7 (GPIO13) |
MISO (MI) | D6 (GPIO12) |
IRQ | NOT USED |
LED | ESP8266 ESP-12E module |
+Anode | D3(GPIO0) |
2.Transmitter side

NRF24L01 transceiver module adapter | Arduino Nano |
VCC | 5V |
GND | GND |
CE | D8 |
CSN | D10 |
SCK | D13 |
MOSI (MO) | D11 |
MISO (MI) | D12 |
Button | Arduino Nano |
GND | GND |
VCC | 5V |
D4 |
Step by Step instruction
1. Adding ESP8266 platform to Arduino IDE
The Arduino environment has to be set up to make it compatible with the ESP8266 ESP-12E module. We are using PC with Windows 7 64 bit OS.
Download and install the Arduino IDE. You can download it here
Open Arduino IDE.
Open the Preferences window from the Arduino IDE. Go to File -> Preferences.

Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field and click the “OK” button. If you already have a URL in there, and want to keep it, you can separate multiple URLs by placing a comma between them. (Arduino 1.6.5 added an expanded text box, separate links in here by line.)

Open Boards manager. Go to Tools -> Board -> Boards Manager…

There should be a couple new entries in addition to the standard Arduino boards. Look for esp8266. or scroll down to the ESP8266 entry (usually at the bottom). Select the ESP8266 entry. When you click it an install option will appear. Select the latest version and click install.

The board definitions and tools for the ESP8266 include a whole new set of gcc, g++, and other reasonably large, compiled binaries, so it may take a few minutes to download and install (the archived file is ~110MB). Once the installation has completed, an Arduino-blue “INSTALLED” will appear next to the entry.


2. Uploading sketch to ESP8266 ESP-12E development board
If you’re using an ESP-12E NodeMCU Kit, uploading the sketch is very simple, since it has built-in programmer.
Before use ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3), you need to download the manufacture’s driver (CH340) for this chip and install it in your PC. Here is the link. See the description of driver installation package below: CH340 / CH341 USB to serial WINDOWS driver installation package that supports 32/64 bit Windows 10 / 8.1 / 8/7 / VISTA / XP, SERVER 2016/2012/2008/2003, 2000 / ME / 98, through Microsoft digital signature authentication, support USB to 3-wire and 9-wire serial port, with the product release To the end user. Applicable scope: CH340G, CH340C, CH340B, CH340E, CH340T, CH340R, CH341A, CH341T, CH341H chips.
If you have CP2102 chip then you need to download the manufacture’s driver for this chip and install it in your PC. Driver for Mac, Windows, Linux or more..
- Do wiring.
- Open Arduino IDE.
- Plug your ESP8266 ESP-12E module into your PC USB port.
- Choose your NodeMCU board. Go to Tools -> Board -> NodeMCU 1.0 (ESP-12E Module)
- Select the correct com port.
- Open the receiversketch , verify and upload it to your ESP8266 ESP-12E module.
3. Uploading sketch to Arduino Nano
- Do wiring.
- Open Arduino IDE.
- Connect the Arduino Nano to your PC with Mini-B USB cable.
- Go to Tools->Board and select Arduino Nano.
- Go to Tools-> Processor and select ATmega328P (from January 2018 sold NEW Arduino NANO boards). To program old boards you need to choose ATmega328P (Old Bootloader). If you get an error while uploading or you are not sure which bootloader you have, try each type of processor 328P until your board gets properly programmed.
- Go to Tools->Port and select correct serial port. If you have an origianl Arduino Nano the driver for it will be installed automatically, if you have chineese Arduino Nano (non-original) if you can not see your board check the project here.
- Open, verify and upload the transmittersketch to your Arduino Nano. To upload the sketch to the Arduino Nano, click the Upload button in the upper left to load and run the sketch on your board.

Code
1. Transmitter side
First we need to include the necessary libraries and create an RF24 object. The two arguments of RF24 object are the CSN and CE pins : RF24 radio(8, 10); // CE, CSN . We create the buttonState variable.
Next we need to create a so called pipe through which the two modules will communicate.
We can change the value of this address to any string and this enables to choose to which receiver we will talk, so in our case we will have the same address at both the receiver and the transmitter.
In the setup section we need to initialize the radio object and using the radio.openWritingPipe() function we set the address of the receiver to which we will send data.radio. We setup and configure the RF radio: radio.begin();
In the loop section using the radio.write() function we will send that data (buttonState) message to the receiver. The first argument here is the variable that we want to be sent. The second argument is the number of bytes that we want to take from that variable. In this case the sizeof() function gets all bytes of the data array. At the end of the program we will add a second delay.
2.Receiver side
First we need to include the necessary libraries and create an RF24 object. The two arguments of RF24 object are the CSN and CE pins : RF24 radio(2, 4); // CE, CSN . Next we need to create a so called pipe through which the two modules will communicate.
Using the radio.openReadingPipe() function we set the same pipe (address) as in the transmitter sketch and in that way we enable the communication between the two modules.We have the radio.startListening() function which sets the module as receiver.
in the loop section using the radio.available() function we check whether there is data to be received. If that’s true, first we create a variable called “buttonState”, in which we will save the incoming data.Using the radion.read() function we read and store the data into the “buttonState” variable. Depending on buttonState value we will turn on or off the LED.
Summary
We have learnt how to turn on/off LED attached to ESP8266 ESP-12E module using button(momentary switch) attached to Arduino Nano via NRF24L01 transceiver module.
Thank you for reading and supporting us.
Libraries:
- See attachments on the beginning of this project description
- NRF24 library attached. You can read more about it here.Download, unzip and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.
Project resources:
- See attachments on the beginning of this project description
Check for more DIY projects on Acoptex.lt and Acoptex.com!
If you are looking for high quality PCBs PCBWay is the best choice:

RELATED POSTS
Installing the ESP8266 NodeMCU Board in Arduino IDE 2.0 (Windows, Mac OS X, Linux)
How to flash NodeMCU ESP8266 firmware
Arduino guide for microphone sound sensor