The invention of radio has revolutionized the world. It was a successful tool for communicating information using wireless communication. Another great invention was the telephone. Do you remember those days when we used those bulky landline phones? Now the era has changed. Landline phones are getting replaced by mobile phones.
We have to accept the fact that wireless communication has become an essential part of our life. If we look around ourselves, we will find many devices which work on wireless communication like mouse, keyboard, lock keys, radio, cordless phone and much more. Also, wireless communication is sometimes referred as Radio Frequency (RF) communication.
Why are we in love with wireless communication? The answers are obvious. First, we want to get rid of wires that lie around us and cause irritation. Second, we want remote access to information. These are the reasons that have raised the demand for wireless communication. Those days are not far when wired communication will become obsolete.
This article is dedicated to the establishment of wireless communication between two NRF modules. We will start with the basic code for transmitting an 8-bit value wirelessly.
Let’s revise some specs about RF transceiver used in NRF24LE1.
First of all, it works on 2.4 GHz frequency, which lies in ISM band which is free to use for Industrial, Scientific and Medical purposes. Also, it uses GMSK modulation.
Secondly, the NRF works on 250 Kbps, 1Mbps or 2Mbps data rate. Besides, NRF24LE1 is fully compatible with other NRF24LXX series. We will be using nrfsdk (software development kit) provided by Nordic Semiconductors Ltd.
Note: Please refer to our previous articles on this module for more understanding.
We will now discuss some in-built functions provided by nrfsdk:
• hal_nrf_set_operation_mode() – This functions is used to select TX or RX mode
• hal_nrf_set_rx_payload_width() – To set the width of the payload to be received
• hal_nrf_set_power_mode() – This function is used to power up the RF.
• hal_nrf_write_tx_payload() – This function takes payload data to be transmitted.
• CE_PULSE() – This function starts the transmission
• CE_HIGH() – To enable the receiver
• hal_nrf_get_clear_irq_flags(): This function reads and clears interrupt flags related to radio.
• hal_nrf_rx_fifo_empty(): To check if Rx buffer is empty or not.
• hal_nrf_flush_tx():To flush the Tx FIFO buffer
The description of various functions is:
These functions have been used in code. The code is commented for greater understanding. Please share your feedback in the comments section below.