Basic project 083b ESP8266 ESP-12E module and NRF24L01 2.4GHZ RF transceiver module – Time and Date on LCD1602 I2C module


Basic: Project 083b

Project name:  ESP8266 ESP-12E module and NRF24L01 2.4GHZ RF  transceiver moduleTime and Date on LCD1602 I2C module

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, LCD1602 I2C module, date and time

Attachments: transmittersketch, receiversketch, library1, 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

A6 GSM GPRS module

2.Arduino IDE (you can download it here)

3. Breadboard 1 pc (optional)

breadboard

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

NRF24L01

5. Jumper wires F-M, M-M

wires

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

arduino nano

7. LCD 1602 I2C module 1 pc

lcd 1602 i2c

General

We will learn how to get the real-time Timestamp from the internet server using ESP8266 ESP-12E module and transmit it to Arduino Nano via NRF24L01 transceiver module and print it on LCD1602 I2C module connected to Arduino Nano. The transmitter will be ESP8266 ESP-12E module with NRF24L01 transceiver module and receiver – Arduino Nano with NRF24L01 transceiver module.

Project steps:

  • ESP8266 ESP-12E module will get the real-time Timestamp (data) with inbuilt time library of ESP8266 using “pool.ntp.org” internet server;
  • ESP8266 ESP-12E module will transmit the data to the Arduino Nano using NRF24L01 transceiver module;
  • Arduino Nano will receive the data from ESP8266 ESP-12E module using NRF24L01 transceiver module;
  • Arduino Nano will display data on LCD1602 I2C module.

Understanding the LCD1602 I2C module

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 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 LCD1602 I2C module

LCD 1602 I2C module has 4 connections: GND (-), VCC (+5V), Serial Data Line (SDA) and Serial Clock Line (SCL).

Signals and connections of the ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3)

A6 GSM GPRS module

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.Trasmitter side

NRF24L01 transceiver module  adapter
NRF24L01 transceiver module adapter ESP8266 ESP-12E module
VCCVV (5V)
GNDGND (G)
CED4 (GPIO2)
CSND2 (GPIO4)
SCK D5 (GPIO14)
MOSI (MO)D7 (GPIO13)
MISO (MI)D6 (GPIO12)
IRQ NOT USED

2.Receiver side

NRF24L01 transceiver module  adapter
NRF24L01 transceiver module adapterArduino Nano
VCC5V
GNDGND
CED8
CSND10
SCKD13
MOSI (MO)D11
MISO (MI)D12
LCD1602 I2C moduleArduino Nano
GNDGND
VCC5V
SDAA4
SCLA5

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.

A6 GSM GPRS module

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.)

A6 GSM GPRS module

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

A6 GSM GPRS module

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

A6 GSM GPRS module

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.

A6 GSM GPRS module
A6 GSM GPRS module

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 MacWindowsLinux or more.. 

  1. Do wiring.
  2. Open Arduino IDE.
  3. Plug your ESP8266 ESP-12E module into your PC USB port.
  4. Choose your NodeMCU board. Go to Tools -> Board -> NodeMCU 1.0 (ESP-12E Module)
  5. Select the correct com port.
  6. Modify the transmittersketch with your local network SSID and password.
  7. Verify and upload it to your ESP8266 ESP-12E module.

3. Uploading sketch to Arduino Nano

  1. Do wiring.
  2. Open Arduino IDE.
  3. Connect the Arduino Nano to your PC with Mini-B USB cable. 
  4. Go to Tools->Board and select Arduino Nano.
  5. 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.
  6. 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
  7. Open the receiversketch .
  8. Find your I2C address. Each device has an I2C address that it uses to  accept commands or send messages. Load the sketch over at http://playground.arduino.cc/Main/I2cScanner and follow the instructions to use it.  By opening up the Serial monitor at 9600 bps in Arduino IDE after you upload the sketch, Arduino will scan the address range looking for a reply.  Even though the documentation said it was 0x27, this scanner can detect different (in our case 0x3F)
  9. Modify the line LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE) (See part marked bold), compile and upload the receiversketch 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.
NRF24L01 Nodemcu

Code

1.Transmitter side

First we include all necessary libraries which we are going to use in this project.

Then we define the credentials of the network to which the ESP8266 ESP-12E module will be connected. So replace with your network ssid and password here.

const char* ssid = “”;
const char* password = “”;

Then we define an object named nrf24 which defines the two connected pins of ESP8266 ESP-12E module. That means we have connected CE and CSN of the NRF24L01 to the D4, D2 pins of ESP8266 ESP-12E module respectively – RH_NRF24 nrf24(2,4);

Then we have configured the Wireless module initialization commands like channel selection, transmission power, data rate and check them if they initialized perfectly without any error. Otherwise it will parse an error in the serial terminal.

Then set the ESP8266 ESP-12E module in station mode by calling the function WiFi.mode(). After that we are calling WiFi.begin function to connect to the network using the given network credentials.

In the time library configTime function supports time zone definition is given in seconds. It takes time zone and daylight saving value as its parameter. We will also pass the server name as its argument from which we can get the current time which is “pool.ntp.org” and “time.nist.gov”. As in Lithuania the time zone is UTC +2 as (- 10800s). Here day light saving is not considered so it is taken as 0.

In the infinite loop we have called the time() function to get the current time and then converted it into a string variable. Then this string variable is get converted into a binary array as NRF24L01 transceiver only transmits data in binary format. Finally using nrf24.send() function we can transmit this binary array of time to the receiver side.

2. Receiver Side

In the receiver side also, the first step is to include necessary library files and define the pins of Arduino board which will be connected to LCD1602 I2C module.

Next, we have created a new binary array with maximum RadioHead user message length that can be supported by this library and calculated its length using sizeof() library .

The final step is to print the received data in 16×2 LCD. But before that we have converted it into string as we have to substring the complete data to get time and date distinctly. For this, function data.substring() is called. The substring() method extracts the characters from the string, between two specified indices, and returns the new sub string.

Summary

We have learnt how to get the real-time Timestamp from the internet server using ESP8266 ESP-12E module and transmit it to Arduino Nano via NRF24L01 transceiver module and print it on LCD1602 I2C module connected to Arduino Nano.

Thank you for reading and supporting us.

Libraries:

  • See attachments on the beginning of this project description
  • We have used the library – NewliquidCrystal which we downloaded, unzipped, changed the name of folder to LiquidCristal and added 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. If you have LiquidCristal folder in this location already – delete this folder and copy folder, which was made by you, to this location.
  • RadioHead library attached. 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. You can read more about it here.

Project resources:

  • See attachments on the beginning of this project description

AcoptexCom

Leave a Reply

Your email address will not be published.