Simple Home Automation With Android App

by Kitu Singh in Circuits > Raspberry Pi

4984 Views, 9 Favorites, 0 Comments

Simple Home Automation With Android App

home2.png
Screenshot_2017-07-11-14-32-44.png
Screenshot_2017-07-11-14-33-01.png

This project will provide you the simplest way to design Android app+python code for home control from anywhere in the world using Thinkspeak IOT platform.

here I code only for one room control...u can code similarly for other rooms as per your need...

I am just giving u idea how to start with home IOT using Raspberry pi+android app.

What You Need...

Cloud 4G Star_20170711_143516.jpg

HARDWARE

1.Raspberry pi

2.Android mobile

-LEDs, male to female wire.

SOFTWARE

1.Android Studio

2.python in Raspberry pi

Python Code

GFDG.png
import httplib, urllib
import re import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) led1=23 led2=24 GPIO.setup(led1,GPIO.OUT) GPIO.setup(led2,GPIO.OUT)
while 1:
    datafromwebsite=urllib.urlopen("https://api.thingspeak.com/channels/284381/feeds.json?api_key=GFSE7RB782RDLS3Z&results=2")#COPY FROM 'GET A CHANNEL FEED'
    select=repr(datafromwebsite.read())
    select=select[350:]
    pick=re.search('field1":"(.+?)",',select)
    if pick:
        print pick.group(1)
    #select=select[400:]
    pick1=re.search('field2":"(.+?)"}]}',select)
    if pick1:
        print pick1.group(1)
    time.sleep(3)
    if pick.group(1)=="1":
        GPIO.output(led1, 1)
    else:
        GPIO.output(led1, 0)
    if pick1.group(1)=="1":
        GPIO.output(led2, 1)
    else:
        GPIO.output(led2, 0)
sleep(3)

Downloads

Android APP 'Home Control'

Untitled.png
nn.png

App is developed using Android studio.

In this two activities are made and code for only bedroom is done rest coder can do as per his/her need.

App opens with different room controls, on selecting room app read the the status of channels on thinkspeak and according to status update the switch used in next activity.

web link for android code:

https://github.com/kulwinderss/IOT.git