RF-Based Multiple Device Control Using Microcontroller
RF-Based Multiple Device Control Using Microcontroller
MICROCONTROLLER
Here we describe how to control electrical and electronic gadgets from a remote location using
radio frequency (RF) transmission. An RF interface is used instead of infrared (IR) to avoid the
drawbacks of an IR interface. Besides, RF has a longer range. The signal is transmitted by an RF
transmitter and received by an RF receiver to switch on or switch off the desired device. This
system can be used to control up to fifteen devices.
Fig. 1 shows the block diagram for RF-based multiple device control using
microcontroller. Signals from the keypad are fed to microcontroller AT89C2051, which, in turn,
is interfaced to the RF transmitter through encoder HT12E. The microcontroller continuously
reads the status of the keys on the keypad.
When any key is pressed, data is passed to the encoder and then to the RF transmitter from where
it is transmitted. The RF receiver receives this data and gives it to the RF decoder. The decoder
serially converts the serial bit data into four-bit data at a port of microcontroller AT89C51. The
microcontroller energises the corresponding relay through a relay driver. Devices are connected
to normally-open (N/O) contacts of the relays.
HT12EandHT12D
HT12E and HT12D are CMOS ICs with a working voltage range of 2.4V to 12V. Encoder
HT12E has eight address lines and four address/data lines. The data set on these twelve lines
(address and address/data lines) is serially transmitted when transmit-enable TE pin (pin 14) is
low. The data output appears serially on DOUT pin. Data is transmitted four times in succession.
The frequency of the pulses of data transmission may lie between 1.5 kHz and 7 kHz depending
on the resistor value used between oscillator pins 15 and 16.
Fig. 2: Transmitter circuit with SM TX-433 RF module (TX1)
Decoder HT12D receives data from HT12E on its DIN pin serially. If the transmitted address
matches the address of the decoder four times in succession, valid transmission pin (VT)
becomes high. The data from pins AD8 through AD11 of the HT12E appears on pins D8 through
D11 of the HT12D.
Transmitter unit
Fig. 2 shows the transmitter circuit with SM TX-433 RF module (TX1). TX1 is an AM/ASK
transmitter module operating at 433 MHz. AT89C2051 is a low-voltage, high-performance
CMOS 8-bit microcontroller. It has 2 kB of Flash, 128 bytes of RAM, 15 input/output (I/O)
lines, two 16-bit timers/counters, a five-vector two-level interrupt architecture, a full-duplex
serial port, a precision analogue comparator, on-chip oscillator and clock circuitry.
Power-on reset is provided by the combination of resistor R3 and capacitor C1. Switch S17 is
used for manual reset. A 12MHz crystal along with two 33pF capacitors provides the basic clock
frequency for operation.
The receiver address to be transmitted can be set with the help of 8-way DIP switch S18. Port
pins P1.0 through P1.7 of the microcontroller are interfaced with the keypad. Pins P3.0 and P3.2
through P3.5 are interfaced with TE pin and data inputs AD8 through AD11 of encoder HT12E.
Receiver unit
Fig. 3 shows the receiver circuit with SM RX-433 RF module. AT89C51 is a low-power, high-
performance CMOS 8-bit microcontroller. It has 4 kB of Flash, 128 bytes of RAM, 32 I/O lines,
two 16-bit timers/counters, five-vector two-level interrupt architecture, a full-duplex serial port,
on-chip oscillator and clock circuitry.
Power-on reset is provided by the combination of resistor R5 and capacitor C6. Switch S20 is
used for manual reset. A 12MHz crystal along with two 33pF capacitors provides the basic clock
frequency to microcontroller AT89C51.
Address lines of the encoder (IC1) and the decoder (IC4) should be identical for data reception in
the receiver. Here addresses are made identical through switches S18 and S19. When any of the
keys on the keypad is closed, the corresponding data pin of the decoder goes low. When any data
is received, valid transmission pin (VT) goes high as indicated by LED2.
Data outputs D8 through D11 of HT12D are connected to port pins P0.0 through P0.3 of the
microcontroller. The microcontroller receives the decoded data and controls the corresponding
relay through relay drivers ULN2003 and ULN2803. The device to be controlled is connected to
the relay contacts. Unregulated power supply is used for relays.
Power supply
The 230V AC mains is stepped down by transformer X1 to deliver a secondary output of 6V,
500 mA. The transformer output is rectified by a full-wave rectifier comprising diodes D6
through D9, filtered by capacitor C8 and regulated by IC 7805 (IC8). Capacitor C7 bypasses the
ripples present in the regulated supply. LED3 acts as the power indicator and R6 limits the
current through LED3.
Software
Programs for the microcontrollers are written in BASIC and compiled using BASCOM Basic
compiler for 8051 family. These are supported by Windows OS. The microcontrollers of the
transmitter and receiver units are programmed with source programs ‘Remote.bas’ and
‘Receiver.bas,’ respectively. The bas codes are converted into hex codes using the above
compiler. The hex codes are burnt into the respective microcontrollers using a suitable
programmer.
After assembling the transmitter, receiver and relay sections on the respective PCBs, pull pin 1
of both HT12E and HT12D to ground. LED2 connected to VT pin of the decoder should glow,
indicating that a valid signal has been received. 255 sets of transmitter-receiver pairs can be used
within the same area, each with a unique address. Alternately, we can also control 255 receivers
with a remote control by changing the address. Now your RF-based multiple device control
system is ready for use.