This article is a continuation of the series of tutorials on the LPC2148 Microcontroller (ARM7). The aim of this series is to provide easy and practical examples that anyone can understand. In the previous tutorial, we have interfaced the PIR sensor with LPC2148 (ARM7). In this tutorial, we are going to see RF Module Interfacing with LPC2148. RF is very useful for wireless communication projects. Let’s start.
Prerequisites
Before we will start I would suggest you to read these topics. Then you can understand this strongly. If you already know, please go ahead.
- LPC2148 Introduction
- LPC2148 GPIO Tutorial
- LPC2148 Interrupt Tutorial
Components Required
- LPC2148 Development Board
- RF Transmitter & Receiver
- Encoder and Decoder
- LED
- Switch or Button
Introduction
The RF module, as the name suggests, operates at Radio Frequency. The corresponding frequency range varies between 30 kHz & 300 GHz. In this RF system, the digital data is represented as variations in the amplitude of the carrier wave. This kind of modulation is known as Amplitude Shift Keying (ASK).
Transmission through RF is better than IR (infrared) because of many reasons. Firstly, signals through RF can travel through larger distances making it suitable for long-range applications. Also, while IR mostly operates in line-of-sight mode, RF signals can travel even when there is an obstruction between transmitter & receiver. Next, RF transmission is more strong and reliable than IR transmission. RF communication uses a specific frequency, unlike IR signals which are affected by other IR emitting sources.
RF Module 434
This RF module comprises an RF Transmitter and an RF Receiver. The transmitter/receiver (Tx/Rx) pair operates at a frequency of 434 MHz.
An RF module (radio frequency module) is an electronic device used to transmit and/or receive radio signals between two devices wirelessly. Basically, the RF modules communicate with the 433MHz radio signals. When considering RF some terms are most important; module frequency, baud rate, transmitter power, communication distance, antenna length, etc.
The RF module is often used along with a pair of encoders/decoders. The encoder is used for encoding parallel data for transmission feed while the reception is decoded by a decoder. HT12E-HT12D, HT640-HT648, etc. are some commonly used encoder/decoder pair ICs.
RF ASK Transmitter
The Transmitter is an ASK hybrid transmitter module. It is designed by the saw resonator, with an effective low cost, small size and simple to use for designing.
- Frequency Range: 433.92 MHz
- Supply Voltage: 3V ~ 12V
- Output Power : 4 ~ 12 dBm
- Standard Operating Voltage: 5V
Pin Description
Pin Num | Name | Description |
---|---|---|
1 | GND | Ground (0V) |
2 | Data | Serial Data Input |
3 | Vcc | Input voltage (5V) |
4 | Antenna | Antenna Output |
RF ASK Receiver
The Receiver is an ASK Hybrid receiver module. It is an effective low-cost solution for using 433 / 434MHz.
- Receiver Frequency: 433.92 MHz
- Typical Sensitivity : 105 dBm
- Supply Voltage: 3V ~ 12V
- Supply Current: 3.5 mA
- Standard Operating Voltage: 5V
Pin Description
Pin No | Name | Description |
---|---|---|
1 | GND | Ground (0V) |
2 | Data | Serial Data Output |
3 | NC | No Connection |
4 | Vcc | Input voltage (5V) |
5 | Vcc | Input voltage (5V) |
6 | GND | Ground (0V) |
7 | GND | Ground (0V) |
8 | Antenna | Antenna Output |
Features
- Low power consumption.
- Easy for application.
- On-Chip VCO with integrated PLL using crystal oscillator reference
- Integrated IF and data filters.
- Operating temperature range: -40 to 80 °C
- Operating voltage: 5 Volts
Range in open space (Standard Conditions) : 500 Meters (with Antenna) / 100-200 Meters (without Antenna)
Applications
- Remote Controls
- Automation System
- Wireless Security System
- Sensor Reporting
- Car Security System
- Remote Keyless Entry
Note:
Supports All Wireless Applications using 8051/AVR/PIC/ARM Microcontrollers (Using HT12E – HT12D Pair). This transmitter and receiver in conjunction with HT12E and HT12D ICs can be used to build a remote control.
Description
This radio frequency (RF) transmission system employs Amplitude Shift Keying (ASK) with transmitter/receiver (Tx/Rx) pair operating at 434 MHz. The transmitter module takes serial input and transmits these signals through RF. The transmitted signals are received by the receiver module placed away from the source of transmission.
The system allows one-way communication between two nodes, namely, transmission and reception. The RF module has been used in conjunction with a set of four-channel encoder/decoder ICs. Here HT12E & HT12D have been used as encoder and decoder respectively. The encoder converts the parallel inputs (from the microcontroller) into a serial set of signals. These signals are serially transferred through RF to the reception point. The decoder is used after the RF receiver to decode the serial format and retrieve the original signals as outputs. These outputs can be given to another microcontroller.
Encoder [HT12E]
HT12E is an encoder integrated circuit of 2^12 series of encoders. They are paired with 2^12 series of decoders for use in remote control system applications. It is mainly used in interfacing RF and infrared circuits. The chosen pair of encoder/decoder should have a same number of addresses and data format. Simply put, HT12E converts the parallel inputs into serial output. It encodes the 12 bit parallel data into serial for transmission through an RF transmitter. These 12 bits are divided into 8 address bits and 4 data bits.
HT12E has a transmission enable pin which is active low. When a trigger signal is received on the TE pin, the programmed addresses/data are transmitted together with the header bits via an RF or an infrared transmission medium. HT12E begins a 4- word transmission cycle upon receipt of a transmission enable. This cycle is repeated as long as TE is kept low. As soon as TE returns to high, the encoder output completes its final cycle and then stops.
Pin Description
Pin No | Pin Name | Description |
---|---|---|
1 to 8 | A0,A1,A2,A3,A4,A5,A6 & A7 | These are the 8-bit address bits, which is used to protect your data. We should set the bits in same pattern on Encoder and Decoder IC to pair them. |
9 | Ground(0V) | Connected to the Ground of circuit |
10 to 13 | AD0, AD1, AD2 & AD3 | These four pins are used to send data, the data encoded here will be decoded on HT12D IC sharing the same address bits |
14 | Transmission Enable(TE) | This pin has to be connected to Ground (0V) to enable the Transmission. Active Low |
15 and 16 | Oscillator pins 1 & 2 | The IC has a built in oscillator. This oscillator can be used by connecting these two pins through a 1M Resistor |
17 | Serial data output | The Encoded 12 bit output data can be obtained from this pin |
18 | Vcc | This pin powers the IC, typically +5V is used. Can range from 2.4V to 12V |
Applications
- Used to convert Parallel 4-bit data to series data
- Highly useful in wireless communication projects involving RF or IR
- Remote-controlled systems like garage doors, Car alarm systems, Car door controls, etc.
- Can be used in Home automation for short-range remote switching
- Safety systems like the Burglar alarm system, Smoke or Fire alarm system, etc.
Decoder [HT12D]
HT12D IC comes from HolTek Company. HT12D is a decoder integrated circuit that belongs to the 2^12 series of decoders. This series of decoders are mainly used for remote control system applications, like burglar alarm, car door controller, security system, etc. It is mainly provided to interface RF and infrared circuits. They are paired with 2^12 series of encoders. The chosen pair of encoder/decoder should have a same number of addresses and data format.
In simple terms, HT12D converts the serial input into parallel outputs. It decodes the serial addresses and data received by, say, an RF receiver, into parallel data and sends them to output data pins. The serial input data is compared with the local addresses three times continuously. The input data code is decoded when no error or unmatched codes are found. A valid transmission is indicated by a high signal at the VT pin.
HT12D is capable of decoding 12 bits, of which 8 are address bits and 4 are data bits. The data on 4-bit latch type output pins remain unchanged until new is received.
Pin Description
Pin No | Pin Name | Description |
---|---|---|
1 to 8 | A0,A1,A2,A3,A4,A5,A6 & A7 | These are the 8-bit address bits, which is used to protect your data. We should set the bits in same pattern on Encoder and Decoder IC to pair them. |
9 | Ground (0V) | Connected to the Ground of circuit |
10 to 13 | AD0, AD1, AD2 & AD3 | These four pins are used to obtain the data bits by decoding the data from HT12E IC |
14 | Serial data input | The Encoded 12 bit output data obtained from HT12E has to be given here |
15 and 16 | Oscillator pins 1 & 2 | The IC has a built in oscillator. This oscillator can be used by connecting these two pins through a 1M Resistor |
17 | Valid Transmission (VT) | This pin will go high when a data is received. Active high |
18 | Vcc | This pin powers the IC should use only 5V |
Applications
- Used to convert series data to Parallel 4-bit data
- Highly useful in wireless communication projects involving RF or IR
- Remote-controlled systems like garage doors, Car alarm systems, Car door controls, etc.
- Can be used in Home automation for short-range remote switching
- Safety systems like the Burglar alarm system, Smoke or Fire alarm system, etc.
Transmitter Operation
Encoder IC (HT12E) receives parallel data in the form of address bits and control bits. The control signals from the microcontroller along with 8 address bits constitute a set of 12 parallel signals. The encoder HT12E encodes these parallel signals into serial bits. Transmission is enabled by providing ground to pin14 (TE Pin in Encoder) which is active low. The control signals are given at pins 10-13 of HT12E. The serial data is fed to the RF transmitter through pin17 of HT12E.
Receiver Operation
The transmitter, upon receiving serial data from encoder IC (HT12E), transmits it wirelessly to the RF receiver. The receiver, upon receiving these signals, sends them to the decoder IC (HT12D) through pin2. The serial data is received at the data pin (DIN, pin14) of HT12D. The decoder then retrieves the original parallel format from the received serial data.
When no signal is received at the data pin of HT12D, it remains in standby mode and consumes very less current (less than 1µA) for a voltage of 5V. When the signal is received by the receiver, it is given to the DIN pin (pin14) of HT12D. On reception of the signal, the oscillator of HT12D gets activated. IC HT12D then decodes the serial data and checks the address bits three times. If these bits match with the local address pins (pins 1-8) of HT12D, then it puts the data bits on its data pins (pins 10-13) and makes the VT pin high. You can connect an LED to the VT pin (pin17) of the decoder. This LED will act as an indicator to indicate a valid transmission. The corresponding output is thus generated at the data pins of decoder IC.
A signal is sent by lowering any or all the pins 10-13 of HT12E and the corresponding signal is received at the receiver’s end (at HT12D). Address bits are configured by using the first 8 pins of both encoder and decoder ICs. To send a particular signal, address bits must be the same at encoder and decoder ICs. By configuring the address bits properly, a single RF transmitter can also be used to control different RF receivers of the same frequency.
To summarize, on each transmission, 12 bits of data are transmitted consisting of 8 address bits and 4 data bits. The signal is received at the receiver’s end which is then fed into decoder IC. If address bits get matched, the decoder converts them into parallel data.
RF Module Interfacing with LPC2148
Circuit Diagram
Transmitter
- P0.0 – AD0 of HT12E
- P0.1 – AD1 of HT12E
- P0.2 – AD2 of HT12E
- P0.3 – AD3 of HT12E
- P0.4 – TE of HT12E
- P1.16 – Switch 1
- P1.17 – Switch 2
Receiver
- P0.8 – D0 of HT12D
- P0.9 – D1 of HT12D
- P0.10 – D2 of HT12D
- P0.11 – D3 of HT12D
- P0.16 – VT of HT12D
- P1.16 – LED 1
- P1.17 – LED 2
Source Code – RF Module Interfacing with LPC2148
Transmitter – RF Module Interfacing with LPC2148
Transmitter side we are connecting two switches in P1.16 and P1.17. When I press Switch 1 (P1.16), it will transmit 0x01 via RF Transmitter. When I press Switch 2 (P1.17), it will transmit 0x02 via RF Transmitter. If no switches were pressed, it will transmit 0x00 through RF Transmitter.
#include<lpc214x.h> #define bit(x) (1<<x) #define TE bit(4) void delay(); void main() { IO0DIR = 0XfffffFFF; //Port 0 is now acting as a output pin IO1DIR = 0x0; //Port 1 is now acting as a input pin while(1) { if((IO1PIN & bit(16)) ==0) { //Checking 16th pin of Port 1 (switch1) IOSET0 = 0X01; //send 1 to P0. This will transmit via RF IOCLR0 = TE; //TE = Low (Transmit starts) delay(); } else if ((IO1PIN & bit(17)) ==0) { //Checking 17th pin of Port 1 (switch2) IOSET0 = 0X02; //send 2 to P0. This will transmit via RF IOCLR0 = TE; //TE = Low (Transmit starts) delay(); }else { IOCLR0 = 0X0f; delay(); } } } void delay() { unsigned int i; for(i=0;i<60000;i++); }
Receiver – RF Module Interfacing with LPC2148
Whenever the Receiver receives anything from the transmitter, the VT Pin of the Decoder should go high. This pin is connected to P0.16 which is External interrupt 0. It executes the ISR when the VT pin goes high. The received data is copied to P0.8 – P0.11. Then we compare that data. If it is 0x01 we will ON the first LED (P1.16). If it is 0x02 we will ON the second LED (P1.17). If it is 0x00 or anything we will clear that both LEDs.
#include<lpc214x.h> #define bit(x) (1<<x) void ex0(void)__irq; unsigned int rec; int main() { PINSEL1=0x1; IO1DIR=0xffff0000; IO0DIR=0x000; VICVectCntl5=(1<<5)|14; VICVectAddr5=(unsigned int)ex0; VICIntEnable=(1<<14); INTWAKE=0x1; EXTMODE=0x01; //edge EXTPOLAR=0x01; //raising edge EXTINT&=0xfe; while(1); } void ex0(void)__irq { rec=IO0PIN & 0x00000f00; rec= rec>>8; if(rec==0x01) { IO1SET = bit(16); IO1CLR = bit(17); } else if(rec==0x02) { IO1SET = bit(17); IO1CLR = bit(16); } else { IO1CLR = bit(17) | bit(16); } VICVectAddr=0x0; EXTINT=0x01; }
This is the simple LED Control using RF Communication. You Can implement it for any type of application. Instead of Grounding all Address Lines in Encoder and Decoder, you can try different combinations.
In our next tutorial, we will see how to interface the IR sensor with LPC2148 (ARM7). If you want to use FreeRTOS on LPC2148, then please refer FreeRTOS series.
You can also read the below tutorials.

Embedded Software | Firmware | Linux Devic Deriver | RTOS
Hi, I’m SLR. I am a tech blogger and an Embedded Engineer. I am always eager to learn and explore tech-related concepts. And also, I wanted to share my knowledge with everyone in a more straightforward way with easy practical examples. I strongly believe that learning by doing is more powerful than just learning by reading. I love to do experiments. If you want to help or support me on my journey, consider sharing my articles, or Buy me a Coffee! Thank you for reading my blog! Happy learning!