After obtaining a few nRF24L01 transceiver modules, I wanted to try making a simple project with it, where you can send information from one device to a 'main device' (of sorts). I wanted this 'main device' to have a screen so that it can show the important information and also upload the data online so it can be kept track of.
Each time data is uploaded to the Thingspeak channel, a notification will show up below the square showing the device from which the data is being uploaded.
In this project, an Arduino Nano is used to transmit temperature readings (taken from a DS18B20 temperature sensor) to a TTGO T-Display. The TTGO T-Display has its own DS18B20, and both these temperature readings will be displayed on the device's screen, and also uploaded to a ThingSpeak channel.
How to make itListed below are some of the main components needed for this project.
nRF24L01
The nRF24L01 transceiver module from Nordic Semiconductors operates in the 2.4 GHz ISM frequency band (also used for WiFi) and uses GFSK modulation. It can operate at three different data rates: 250 kbps, 1 mbps, and 2 mbps. The low power consumption of the device and its low price point makes it a very attractive option for projects of this caliber. Many online sources mention that there will be noise introduced into the device. It will therefore be a good idea to place a 10µf capacitor from the Vcc to the Gnd to reduce noise, but this is not compulsory.
DS18B20
This digital thermometer provides 9-bit to 12-bit temperature measurements and is particularly useful thanks to its 1-Wire protocol. Each device has a unique 64-bit serial code, allowing multiple devices to be read using one pin. There is a waterproof device and a non-waterproof one. Regardless of the form-factor you choose, you will require a 4.7k pull up resistor from the Vcc to the Data connection.
Arduino Nano
This device has been around for a while and has all the features of an Arduino Uno in a smaller form factor.
LILYGO TTGO T-Display
This device is equipped with an ESP32 microcontroller and therefore has all the features that come with it (WiFi, Bluetooth, etc.). To top it off, it has its own color LCD display.
ThingSpeak
ThingSpeak makes IoT very easy for hobbyists. It will store and retrieve data from things using the HTTP and MQTT protocol over the Internet or via a Local Area Network. It is quite easy to make a Channel for the data logging, and each channel will have 8 fields to upload data to. It is possible to use a paid subscription, but for this project, the free features will be enough.
AssemblyPhysical
There will be two boards: one for transmitting from an nRF24L01 and one for receiving from an nRF24L01. The Arduino Nano will be used for the transmission end, and the LILYGO TTGO T-Display will be used to receive data and then upload it online. All setups will be assembled on a breadboard as this is a prototype.
The transmitter's assembly is shown in the figure below.
The connections are as follows.
D2 (Arduino Nano) ----------------------------> Data (DS18B20)
D7 (Arduino Nano) ----------------------------> CE (nRF24L01)
D8 (Arduino Nano) ----------------------------> CSN (nRF24L01)
D11 (Arduino Nano) ----------------------------> MOSI (nRF24L01)
D12 (Arduino Nano) ---------------------------> MISO (nRF24L01)
D13 (Arduino Nano) ---------------------------> SCK (nRF24L01)
The receiver's connections are listed below.
The connections are as follows.
GPIO2 (LILYGO TTGO T-Display) ------------------------------> Data (DS18B20)
GPIO32 (LILYGO TTGO T-Display) ----------------------------> CE (nRF24L01)
GPIO33 (LILYGO TTGO T-Display) ----------------------------> CSN (nRF24L01)
GPIO27 (LILYGO TTGO T-Display) ----------------------------> MOSI (nRF24L01)
GPIO25 (LILYGO TTGO T-Display) ---------------------------> MISO (nRF24L01)
GPIO26 (LILYGO TTGO T-Display) ---------------------------> SCK (nRF24L01)
Setting up the Thingspeak Channel
This system will require a Thingspeak channel for use (https://thingspeak.com/). This can be made quite easily after making an account. In the Thinkspeak homepage, go to 'Channels', click on 'My Channels', and click on the green icon that says 'New Channel'. Fill in a suitable name and click the first two tick boxes as we require two fields for this project.
Take note of the 'Write API' key which can be found on the 'API keys' section and the 'Channel ID' from the channel itself. These values need to be input into the code for the LILYGO TTGO T-Display.
Codes
Each device can be programmed using the Arduino IDE. Both files are listed below. The.h files required for both the devices are nRF24L01.h and RF24.h. Note that the RF24.h file used in this project is a fork published by nhatuan84, which can be found here. For more information, visit the following link. This fork makes it easy to alter all the pins used by the microcontroller for the nRF24L01.
For the transmitting Arduino Nano, the file is titled 'transmitter.ino' and for the receiving LILYGO TTGO T-Display, the file is titled 'receiver.ino'. Look through online resources to find out the necessary libraries to set up the LILYGO TTGO T-Display. After installing the necessary libraries, in the 'TFT_eSPI' folder in the Arduino Libraries, open 'User_Setup_Select.h' and uncomment the following line of code
#include <User_Setups/Setup25_TTGO_T_Display.h> // Setup file for ESP32 and TTGO T-Display ST7789V SPI bus TFT
in order to make the library function with this device.
Both devices will have a pipe value as shown below.
const uint64_t pipee = 0xE8E8AAFFE122;
This value needs to be identical for the transmitter and the receiver in order to establish communication.
Comments