Michael Olafusi
Published © CERN-OHL

Home Automation for Africa

Most home automation solutions do not work in Africa because they do not factor in our epileptic power supply and user behavior. This does.

AdvancedWork in progress5,783
Home Automation for Africa

Things used in this project

Story

Read more

Schematics

Circuit Diagram of the first version

Hackspace 3

Code

PIC C Code for the first version

C/C++
#include <18f4455.h>
#use delay(clock=12000000)
#use rs232(baud=9600, xmit=PIN_C6,rcv=PIN_C7)
#fuses HS,NOWRT,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP,NOCPD,NODEBUG
#use fast_io(A)// enhances self i/o settings
#use fast_io(B)
#use fast_io(C)
#include <string.h>// header file
#include <input.c>
int i,u,a,b,counter=1,toggle;
char data[20],data1[20],data2[20],data3[20],test[12],mem[12],req[12];
void main()
{
set_tris_c(128);
set_tris_b(0);
output_b(255);
set_tris_d(0);
output_d(0);
delay_ms(500);
printf("at+cmgf=1;+cnmi=2,3,2,2,1\r"); /* This puts the phone in text
mode and enables notification sending */
i=getch(); // \
u=getch(); // \
gets(data); // \
// |-Extract and silent the initial sent instruction
i=getch(); // /
u=getch(); // /
gets(data1);// /
back:
if(kbhit()) //Run the subsequent codes when there is a new data
{
welcome:
if(counter==200) // \_ Re-initialise the counter
counter=0; // /
gets(data2);
62
gets(data3);
b=0;
for(a=1;a<=6;a++)
{
req[b]=data3[a];
b++;
}
strncpy(mem,req,4);
strcpy(test,"RING"); /* The control string which the phone sends when
there is a phone call */
if(strncmp(mem,test,4)==0) //check if the notification is for phone
ringing
{
counter++; //Increment the counter
toggle=counter%10;
if(toggle==5)
{
output_high(PIN_D4); //put 5V on the D4 pin
printf("at+cmgs=\"08064702218\"\r");
printf("appliance is switched on");
putc(26);
}
if(toggle==0)
{
output_low(PIN_D4); //set pin D4 to 0V
//delay_ms(5);
printf("at+cmgs=\"08064702218\"\r");
//delay_ms(50);
printf("appliance is switched off");
putc(26);
//delay_ms(10);
}
}
goto welcome;
}
goto back;
}

Credits

Michael Olafusi

Michael Olafusi

1 project • 7 followers
A tech enthusiast.

Comments