NRF24L01 interfacing with 8051 – Wireless Xbee

NRF24L01 interfacing with 8051 tutorial is intended to enable wireless data transfer for 8051.  So to do that, we will interface nRF24L10 with 8051. This will enable us to transfer the data wirelessly (by air) between two 8051 boards using NRF24L01.

NRF24L01 interfacing with 8051

Hardware Required

  • 8051 Development board – 2
  • NRF24L01 – 2
  • PC (To send/read data through UART using any serial terminal)

NRF24L0

Before start coding, we will see something about NRF24L01 to get some idea.

The nRF24L01 is a wireless transceiver module, meaning each module can both send as well as receive data. They operate in the frequency of 2.4GHz, which falls under the ISM band, and hence it is legal to use in almost all countries for engineering applications. The modules when operated efficiently can cover a distance of 100 meters (200 feet) which makes it a great choice for all wireless remote controlled projects.

The module operates at 3.3V hence can be easily used with 3.2V systems or 5V systems. Each module has an address range of 125 and each module can communicate with 6 other modules hence it is possible to have multiple wireless units communicating with each other in a particular area. Hence mesh networks or other types of networks are possible using this module. So if you are looking for a wireless module with the above properties then this module would be an ideal choice for you.

These modules are very cheap, smaller in size, and has a lot of specifications. Some of the specifications of these modules are as follows,

nRF24L01 Features

  • 2.4GHz RF transceiver Module
  • Operating Voltage: 3.3V
  • Nominal current: 50mA
  • Range: 50 – 200 feet
  • Operating current: 250mA (maximum)
  • Communication Protocol: SPI
  • Baud Rate: 250 kbps – 2 Mbps.
  • Channel Range: 125
  • Maximum Pipelines/node: 6
  • Low-cost wireless solution

Note: Complete Technical Details can be found on the NRF24L01 datasheet.

nRF24L01 Pin Configuration

Pin NumberPin NameAbbreviationFunction
1GroundGroundConnected to the Ground of the system
2VccPowerPowers the module  using 3.3V
3CEChip EnableUsed to enable SPI communication
4CSNShip Select NotThis pin has to be kept high always, else it will disable the SPI
5SCKSerial ClockProvides the clock pulse using which the SPI communication works
6MOSIMaster Out Slave InConnected to MOSI pin of MCU, for the module to receive data from the MCU
7MISOMaster In Slave OutConnected to MISO pin of MCU, for the module to send data from the MCU
8IRQInterruptIt is an active low pin and is used only if the interrupt is required

Applications

  • Wireless Control application
  • Mesh Networks
  • RF Remote Controllers
  • Connected devices

How to Use the NRF24L01

The NRF24L01 module works with the help of SPI communications. These modules can either be used with a 3.3V microcontroller or a 5V microcontroller but it should have an SPI port. Since 8051 doesn’t have the SPI, we are going to implement the SPI using bit-banging method.

And SPI will be having just 4 lines but here it has one more line extra called CE pin to enable reception, transmission, and put the device into standby mode.

Write Register

  • Write SPI write register address + 0x20
  • Then write register value

Read Register

  • Write the register address
  • Read the data

One status register is there (0x07). You can read the status of the transaction.

For more information, please check the datasheet.

Programming

In this tutorial, we are going to use one setup for transmitter purpose and another for receiver purpose. The concept is much simple. When we send something through the serial port in the transmitter, that will be transmitted over the air. Since we are using the same address for both TX and RX, RX will receive the data from the air and print the data through the serial port.

You can get the complete source code from the GitHub.

Connection

  • MISO – Port 1.0
  • MOSI – Port 1.1
  • SCK – Port 1.2
  • CSN – Port 1.3
  • CE – Port 1.4

TX Code

We have added only the NRF24L01 related source code. You can get the full project’s code from the GitHub.

nRF24L01.h

RX Code

We have added only the NRF24L01 related source code. You can get the full project’s code from the GitHub.

nRF24L01.h

 

0 0 vote
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
%d bloggers like this: