You have no items in your shopping cart.

Subtotal: 0.00

Abstract

This paper presents wireless Relay control application i.e. Either by  Bluetooth, Zigbee or WI-FI. We have numerous applications using relay control project. The system is based on the embedded system and it can act as a security guard of the home. It can be used to control the electrical appliances at home. Bluetooth technology handles the wireless part of the communication channel; it transmits and receives data wirelessly between these devices. It delivers the received data and receives the data to be transmitted to and from a host system through a host controller interface (HCI). The most popular host controller interface today is either a UART or a USB .The whole system is a cheaper one, but it provides the full-scale device control function.

Concept

This project is mainly based on mobile phone communication with the Microcontroller through Bluetooth. Connect the Bluetooth Module with microcontroller using the serial port communication. Then dump the following code in flash memory of controller and connect the Bluetooth module 2 with PC and open the HyperTerminal open select the com – port and set the baud rate or select restore default. Then start pairing the Bluetooth module from PC side, transfer the message from transmitter and in the receiver side the message will be displayed on LCD. There is a controlling application also added in this project we can ON/OFF the device from Transmitter side. From Bluetooth module 1 start entering the message whenever the message ‘3’ is entered and sent the relay will be switched ON and if we send ‘4’ Relay is switched OFF. Using the Relay we can switch ON /OFF the electrical device.

Block diagram



Block diagram

Introduction to Bluetooth EVK

PS-Bluetooth EVK is powered by LM TECH-LM400 and Parani-ESD210 is Class 2 type of Compact Embedded Bluetooth Serial Modules for RS-232 cable replacement. By default, they support 30 meters of wireless transmit distance. The Parani-ESD210 has an extension option so that users can extend the transmit distance up to 300 meters using optional antennas. Users may configure the LM Tech-LM400 Series by using easy-to-use Windows-based utility software or by using standard AT command set.

Connect the Bluetooth device to the Microcontroller

To connect the Bluetooth, you will need to find the Rx and TX pins on your microcontroller. Make sure that you cross the wires by connecting the Rx pin from your Bluetooth device to the TX pin on the microcontroller, and the TX pin from your Bluetooth device to the Rx pin on the microcontroller. Install the Bluetooth SPP software in Android based Mobile and pair the device and start the communication between Mobile and Microcontroller Bluetooth SPP provides Bluetooth connectivity for all android apps:

Hardware requirements

Software requirements

  • Programming Language: Embedded C
  • KEIL U Vision IDE
  • Flash magic
  • Orcad 16.3

Bluetooth Module setting with PC


Bluetooth Module setting with PC

Bluetooth Module setting with ARM 7


Bluetooth Module setting with ARM 7

Source Code

#define CR 0x0D
#include 
#define BUZZ 7
#define LED 1
void init_serial (void);
int putchar (int ch);
int getchar (void);
void lcd_initialize (void);
void delay (unsigned int);
void lcd_cmd (unsigned char);
void lcd_data (unsigned char);
unsigned char test;
const unsigned char msg[] = ("PS­ARM EVB KIT "); //msg
const unsigned char msg1[]= (" ::LCD DEMO:: "); //msg1
const unsigned char cmd[4] = {0x38,0x0c,0x06,0x01}; //lcd commands
unsigned char ch, I = 0;
//­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
// LCD Initialize
//­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
void lcd_initialize (void)
{
int i;
for(i=0;i<4;i++)
{
IOCLR0 = 0x00FF0000;
lcd_cmd (cmd[ I ]);
delay(15);
}
}
//­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
// LCD Command Send
//­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
void lcd_cmd(unsigned char data)
{
IOPIN0 = data << 16;
IOCLR1 |= 0x100000; //RS
IOCLR1 |= 0x200000; //RW
IOSET1 |= 0x400000; //EN
delay(15);
IOCLR1 |= 0x400000; //EN
}
//­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
// LCD Data Send
//­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
void lcd_data(unsigned char data)
{
IOPIN0 = data << 16;
IOSET1 |= 0x100000; //RS
IOCLR1 |= 0x200000; //RW
IOSET1 |= 0x400000; //EN
delay(15);
IOCLR1 |= 0x400000; //EN
}
//­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
// LCD Display Msg
//­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
void lcd_display(void)
{
char i;
/* First line message */
IOCLR0 = 0x00FF0000;
lcd_cmd(0x80);
delay(15);
i=0;
while(msg[i]!='\0')
{
IOCLR0 = 0x00FF0000;
lcd_data(msg[i]);
i++;
delay(15);
}
delay(15);
}
//­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
// Delay Routine
//­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
void delay(unsigned int n)
{
int i,j;
for(i=0;i>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
int main(void)
{
char *Ptr = "*** UART0 Demo ***\n\n\rType Characters to be echoed!!\n\n\r";
PINSEL0 = 0;
PINSEL1 = 0;
IODIR0 = 0XFFFFFFFF; //PORT [P0.16­­P0.31] output
IODIR1 = 0X00Ff0000; //PORT [P1.20­­P1.23] output
IODIR0 |= 0xFF << LED; //Configure P1.24 ­ P1.31 as
Output
delay(10);
lcd_initialize(); //Initialize LCD
delay(10);
VPBDIV = 0x02; //Divide Pclk by two
init_serial();
delay(15);
lcd_display();
delay(15);
while(1)
{
while (*Ptr)
{
putchar(*Ptr++);
}
ch=getchar();
switch(ch)
{
case 0x33: IOSET1 |= 0x30080; break;
case 0x34: IOCLR1 |= 0x30080; break;
}
lcd_cmd(0xC0 + i++);
if(i==16) i=0;
lcd_data(ch);
}
}
//<<<<<<<<<<<<<<<<<<<<<<<<< Serial Initialization
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void init_serial (void) /* Initialize Serial Interface */
{
PINSEL0 = 0x00000005; /* Enable RxD0 and TxD0 */
U0LCR = 0x00000083; /* 8 bits, no Parity, 1 Stop bit */
U0DLL = 0x000000C3; /* 9600 Baud Rate @ 30MHz VPB Clock */
U0LCR = 0x00000003; /* DLAB = 0 */
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<< Putchar Function
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
int putchar (int ch) /* Write character to Serial Port */
{
if (ch == '\n') {
while (!(U0LSR & 0x20));
U0THR = CR; /* output CR */
}
while (!(U0LSR & 0x20));
return (U0THR = ch);
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<< Getchar Function
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
int getchar (void) /* Read character from Serial Port */
{
while (!(U0LSR & 0x01));
return (U0RBR);
}

Conclusion

Wireless relay control is an application which can be used for multiple applications. It can be used to control the electrical appliances through Bluetooth or with Mobile. The whole system is a cheaper one, but it provides the full-scale device control function. We think this product have high potential for marketing in the future.