Android Based Home Automation Via Internet and Ethernet
by lun9501 in Circuits > Remote Control
3719 Views, 38 Favorites, 0 Comments
Android Based Home Automation Via Internet and Ethernet
This is a project to assist elderly and handicapped people to live more independent.
My project provide few features which is control home appliances using android smartphone through the internet and also Ethernet. That mean they do not move to the switch, then they can access and control the home appliances anywhere and anytime without anyone help.
The project also allow user to control some home appliances switch on/off at certain time. The user do not need repeat control the home appliances which need to on and off every day and certain time.
Besides, user also can trigger the alarm by using voice, because handicapped and elderly people may facing emergency situation alone at home. They may did not reach to phone. So they can simply trigger the alarm ask for help by using voice.
Materials
- PIC18F4550
- ENC28J60
- DS1307
- PIC10F222
- ROUTER
- ANDROID PHONE
- LM35
- DC TO AC CONVERTOR
- VOICE SENSOR
- BT136
- MOC3021
- 4N25
- RJ45 CONNECTOR
- Some passive electronic component
PCB Broad Design (i'm Just a Beginner, and Don't Have Time to Spend on It)
AC Appliances Control Circuit
This is the basic circuit i used to control the AC appliances.
The reason that i use TRIAC and optocoupler, to prevent relay spark noise.
I used relay before, and it make the system unstable.
But the Triac also have some weakness, i'm not professional, wait professional to answer it.
Actually, the Circuit that i control the speed of wall fan, also design based on the TRIAC circuit.
A circuit as a switch, 3 circuit control 3 speed of wall fan, and only one is on at one time.
Controlled Light Dimmer
This one i copy from here.
Thanks to diy_bloke
Read it, very detail
Software (Android Apps by Apps Inventor, Firmware by MPLAB)
#include "fileheader.h"
const char main_page[]="C%0";
const char time_page[]="T%1";
char debug[7];
int32 http_get_page(char *file_str)
{
int32 file_loc=0;
int8 i=0;
int8 days=0;
int8 month=0;
int8 year=0;
int8 hour=0;
int8 min=0;
int8 second=0;
int8 dow=0;
static char dimmer[] ="/D";
static char fan[] ="/F";
static char powersocket[] ="/S";
static char alarmsystem[] ="/A";
static char magneticlock[] ="/L";
static char statecheck[] ="/C";
static char rtc_io[] ="/T";
debug[0]=file_str[0];
debug[1]=file_str[1];
debug[2]=file_str[2];
debug[3]=file_str[3];
debug[4]=file_str[4];
//dimmer control
if (stricmp(file_str[1],dimmer[1])==0)
{
i=(file_str[2] & 0b11001111)* 100 + (file_str[3]&0b11001111) * 10 + (file_str[4]&0b11001111);
bulb_brightness(i);
file_loc=label_address(main_page);
}
//alarm control
if (stricmp(file_str,alarmsystem)==0)
{
toggle_alarm_state();
file_loc=label_address(main_page);
}
//rtc_io
if (stricmp(file_str[1],rtc_io[1])==0)
{
if(file_str[2]=='s') //set time
{
days = (file_str[3] & 0b11001111)* 10 + (file_str[4]&0b11001111);
month = (file_str[5] & 0b11001111)* 10 + (file_str[6]&0b11001111);
year = (file_str[7] & 0b11001111)* 10 + (file_str[8]&0b11001111);
dow = (file_str[9] & 0b11001111);
hour = (file_str[10] & 0b11001111)* 10 + (file_str[11]&0b11001111); min = (file_str[12] & 0b11001111)* 10 + (file_str[13]&0b11001111);
second = (file_str[14] & 0b11001111)* 10 + (file_str[15]&0b11001111); ds1307_set_date_time(days,month,year,dow,hour,min,second);
file_loc=label_address(time_page);
}
if(file_str[2]=='g') //get time
{ file_loc=label_address(time_page); }
if(file_str[2]=='r') //configuration rtc io
set_rtc_io(on/off , which i/o, hr to on, min to on, hr to off , min to off)
{ set_rtc_io(file_str[3] & 0b11001111, file_str[4] & 0b11001111, (file_str[5] & 0b11001111)* 10 + (file_str[6]&0b11001111), (file_str[7] & 0b11001111)* 10 + (file_str[8]&0b11001111) , (file_str[9] & 0b11001111)* 10 + (file_str[10]&0b11001111) , (file_str[11] & 0b11001111)* 10 + (file_str[12]&0b11001111)); file_loc=label_address(time_page); } }
//for fan if (stricmp(file_str[1],fan[1])==0 ) { if(stricmp(file_str[2],'1')==0) {fan_speed1();} if(stricmp(file_str[2],'2')==0) {fan_speed2();} if(stricmp(file_str[2],'3')==0) {fan_speed3();} if(stricmp(file_str[2],'o')==0) {fan_off();} if(stricmp(file_str[2],'r')==0) {fan_rotate_toggle();} file_loc=label_address(main_page); }
//for magnetic lock if (stricmp(file_str,magneticlock)==0) { toggle_magnetic_lock_state(); file_loc=label_address(main_page); }
//for power socket if (stricmp(file_str[1],powersocket[1])==0 ) { if(stricmp(file_str[2],'1')==0) {toggle_power_socket1_state();} if(stricmp(file_str[2],'2')==0) {toggle_power_socket2_state(); } if(stricmp(file_str[2],'3')==0) {toggle_power_socket3_state();} file_loc=label_address(main_page); }
//for state check if (stricmp(file_str,statecheck)==0 ) { file_loc=label_address(main_page); }
return(file_loc); }
int8 http_format_char(int32 file, char id, char *str, int8 max_ret) { char new_str[50]; int8 len=0;
*str=0;
switch(id) {
case '0': sprintf(new_str,"%2d%2d%2d%3d%d%d%d%d%d%d%d%d%d%d%d%s",hr,min,get_temperature(), get_bulb_brightness(), input_state(speed1), input_state(speed2), input_state(speed3), input_state(rotate), input_state(magnetic_lock_signal),input_state(power_socket_signal1),input_state(power_socket_signal2),input_state(power_socket_signal3),input_state(voice_sensor_signal),input_state(alarm_signal),T,debug); len=strlen(new_str); break;
case '1': sprintf(new_str,"%2d%2d%1d%1d%1d%2d%2d%2d%2d%2d%2d%2d%2d%2d%2d%2d%2d",hr,min,rtc.io0,rtc.io1,rtc.io2,hr_on_io0,min_on_io0,hr_off_io0,min_off_io0,hr_on_io1,min_on_io1,hr_off_io1,min_off_io1,hr_on_io2,min_on_io2,hr_off_io2,min_off_io2); len=strlen(new_str); break; } if (len) { if (len>max_ret) {len=max_ret;} memcpy(str,new_str,len); }
return(len); }
void http_exec_cgi(int32 file, char *key, char *val) {;}
void main(void) {
delay_ms(1000);
rtc_io_init();
power_socket_init();
bulb_dimmer_init();
voice_control_alarm_system_init();
magnetic_lock_init();
temperature_sensor_init();
fan_init();
MACAddrInit();
IPAddrInit();
StackInit();
delay_ms(10);
while(TRUE)
{
StackTask();
}
}
Setup Internet Connection
i using port forward technique to connect the microcontroller to internet.
you all can read it. Based on your internet environment, router model, find your way to setup.
Wiring
As shown i used erthernet cable CAT 5 to transmit signal,
haha, i don't know right or wrong.
But it's work.
Done :D
Hurrrgh, tired . if good respond I will update let the tutorial more complete.