Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to control room lights via microcontroller and PC

Status
Not open for further replies.

heavenearth

Newbie level 2
Joined
Apr 27, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,300
Hi,

I am computer science student and i want to control the room lights via sms sent from remote mobile through gsm modem AT commands send to PC and is further forwarded to microcontroller ATMEGA8 but i donot have any idea how to start with.Can any one give me some circuit diagram based on this microcontroller circuit for controlling room lights through commands sent from pc to microcontroller. I want to connect microcontroller with PC via RS232. For the time being i just want to control one light using one relay. I shall be really thankful if anyone can send me the circuit diagram.

Thanks for help in advance.
 
Last edited:

I did't get your flow.
You want send SMS to activate relay or use PC to activate relay?
For controlling by GSM, use GSM Modem and interface using UART throught hardware MAX232. GSM Code.
For controlling by PC, use USB converter either USB-to-RS232 (then you need MAX232) or USB-to-UART. One way is, use program Visual Basic to controlling external device. VB Serial code.
For interface both, it's need more programming (software UART). So, you take step interface one-by-one first.
 

USB Relay Controller - as a COM port

If you want to control Lights through PC then the best option is to use a USB Relay Controller like this **broken link removed**. This appears as a virtual COM port so no special programming skills are needed. If you can do serial port programming then thats all you will need.

Hope thats helpful.
 

what i understand from your statement, your flow is, sent sms to pc, pc send signal to microcontroller, microcontroller trigger the light via relay. if it was what u mean, actually you can directly trigger the light just by using GSM modem and microcontroller. But if you still need to involve PC in this case, why dont you try this, Your PC send sms using GSM modem, then at the receiver side you can use one more GSM modem to trigger microcontroller then activate the light. it just my suggestion, but the cost will be higher then what you think before.
 

what i understand from your statement, your flow is, sent sms to pc, pc send signal to microcontroller, microcontroller trigger the light via relay. if it was what u mean, actually you can directly trigger the light just by using GSM modem and microcontroller. But if you still need to involve PC in this case, why dont you try this, Your PC send sms using GSM modem, then at the receiver side you can use one more GSM modem to trigger microcontroller then activate the light. it just my suggestion, but the cost will be higher then what you think before.


Sir,
I am working on a home automation project. In that i want to control my home appliances remotely using gsm modem. For that i am using SIM 300 modem and atmega16 microcontroller. I am having a problem with interfacing SIM300 with uc and decoding the recieved msg for relay control.
Please help sir.


Thank you in advance

- - - Updated - - -

I am working on a home automation project. In that i want to control my home appliances remotely using gsm modem. For that i am using SIM 300 modem and atmega16 microcontroller. I am having a problem with interfacing SIM300 with uc and decoding the recieved msg for relay control.
Please help


Thank you in advance
 

Sir,
This is my code to check whether uc is able to communicate with SIM300 or not



#include<avr/io.h>
#include<util/delay.h>
// #include<avr/interrupt.h>




#define LCD_DATA PORTA // lcd data port A
#define ctrl PORTB
#define en PB2
#define rw PB1
#define rs PB0




#define F_CPU 16000000UL
#define USART_BAUDRATE 9600 // Baud Rate value
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)




unsigned char string [40];


void LCD_cmd(unsigned char cmd);
void init_LCD(void);
void LCD_write(unsigned char data);
void LCD_string (unsigned char *str);






void init_LCD (void)
{

LCD_cmd (0x38); //
_delay_ms(10);

LCD_cmd (0x01); //clear LED
_delay_ms(10);

LCD_cmd (0x0E); //cursor ON, blinking
_delay_ms(10);

LCD_cmd (0x80);
_delay_ms(50);

return;
}

void LCD_cmd (unsigned char cmd)
{
LCD_DATA = cmd;
ctrl=(0<<rs)|(0<<rw)|(1<<en);
_delay_ms(10);

ctrl=(0<<rs)|(0<<rw)|(0<<en);
_delay_ms(50);

return;
}

void LCD_write (unsigned char data)
{
LCD_DATA = data;
ctrl=(1<<rs)|(0<<rw)|(1<<en);
_delay_ms(10);

ctrl=(1<<rs)|(0<<rw)|(0<<en);
_delay_ms(50);

return;
}

void LCD_string (unsigned char *str)
{
int i=0;
while (str!='\0')
{
LCD_write (str[i++]);
}
}



void usart_init()
{
UCSRB |= (1 << RXEN) | (1 << TXEN); // Turn on the transmission and reception circuitry
UCSRC |= (1 << URSEL) | (1<<USBS) | (1 << UCSZ0) | (1 << UCSZ1);
// Use 8-bit character sizes

UBRRL = BAUD_PRESCALE;
// Load lower 8-bits of the baud rate value into the low byte of the UBRR register
UBRRH = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value..
// into the high byte of the UBRR register
}

unsigned int usart_ReadChar()
{
while ((UCSRA & (1 << RXC)) == 0);
// Do nothing until data has been received and is ready to be read from UDR
return(UDR); // return the byte
}


void usart_WriteChar(unsigned char data)
{
//Wait untill the transmitter is ready
while ((UCSRA & (1 << UDRE)) == 0); // Do nothing until UDR is ready..
// for more data to be written to it
UDR = data; // Send the byte

}


int main()
{
unsigned char data;

DDRA=0xff; //LCD_DATA port as output port
DDRB=0x07; //signal as out put

init_LCD(); //initialization of LCD

_delay_ms(1);
LCD_string ("HOME");
_delay_ms(100);



usart_init();
// sei(); // Enable global interrupt


usart_WriteChar('A');
usart_WriteChar('T');
usart_WriteChar('\n');
//Check whether response is OK or not
_delay_ms(300);

LCD_cmd(0x01);

data=usart_ReadChar();

LCD_write(data);

}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top