IPhone remote controlled lamp

This project uses the iPhone and a raspberry pi to remote control the lamp. Both the iPhone and the raspberry pi are connected to the wifi router. The lamp on/off commands are sent from iPhone and received by the raspberry pi embedded system. Then the raspberry pi triggers the IO to control the lamp through a relay. The lamp can be replaced by other home appliances. The software is written in Python and it can be easily port to other devices.

Step 1: System diagram

IPhone remote controlled lamp

The system diagram is shown in this figure. The data flow is straightforward. The iPhone is connected to the wifi router wirelessly while the Raspberry pi is connected to the wifi router through a lan cable (this can change to wireless with a wifi adapter installed in the Raspberry pi). One of the Raspberry pi's IO is connected to a relay board. Since the relay board control voltage is 5V and the Raspberry pi output voltage is 3.3V, a transistor is used to perform the voltage transition; the detail will be introduced in step 3. Then the lamp can be controlled through the relay board.

Both the iPhone and the Raspberry pi need to run a software for communication. In this project, Python is used as the programming language. In iPhone, Pythonista is installed and run the script, a UI is also designed. In Raspberry pi, a Python script is run automatically after booting the system. The communication is based on socket TCP mode.

Step 2: Electronics

IPhone remote controlled lamp
IPhone remote controlled lamp
IPhone remote controlled lamp
IPhone remote controlled lamp
IPhone remote controlled lamp
IPhone remote controlled lamp
IPhone remote controlled lamp
Show All 7 Items

Here are the electronics parts.

1. A Raspberry pi board

2. A relay board

3. A universal board for connecting the Raspberry pi and the relay board

4. A lamp

5. A wireless router

6. A USB charger for powering up the Raspberry pi

7. A transistor 8050

8. Two resistor (1K ohm)

9. Lan cable and USB cable and

10. Of course an iPhone as the remote control

Step 3: Circuit

IPhone remote controlled lamp

Since the output voltage of the Raspberry pi is 3.3V and the control signal voltage of the relay board is 5V, we need to change the 3.3V signal to 5V signal. A voltage converter circuit is shown in this picture. A 8050 transistor is used to perform the transition. When the output GPIO of the Raspberry pi is low, the relay board input signal is high, and the relay is on, the lamp will turn on. When the output GPIO of the Raspberry pi is high, the relay board input signal is low, and the relay is off, the lamp will turn off.

Step 4: Software-Raspberry Pi

Some modification of the Raspberry pi is needed to perform this project's task.

1. Auto login

2. Static IP

3. Auto-run script

4. GPIO control

5. Socket server

Details are list below:

1. Auto login

edit /etc/inittab, change

"1:2345:respawn:/sbin/getty --noclear 38400 tty1" into

"1:2345:respawn:/bin/login -f pi tty1 /dev/tty1 2>&1"

ref: http://elinux.org/RPi_Debian_Auto_Login

2. Static IP

set the IP as "192.168.1.200"

edit /etc/network/interfaces, change

"iface eth0 inet dhcp" into

"iface eth0 inet static

address 192.168.1.200

netmask 255.255.255.0

network 192.168.1.0

broadcast 192.168.1.255

gateway 192.168.1.1"

ref: https://www.modmypi.com/blog/tutorial-how-to-give-...

3. Auto-run script

edit .bashrc, add at the bottom:

"sudo python server_5.py"

server_5.py is the script to serve the lamp control command

ref: http://www.raspberrypi.org/forums/viewtopic.php?f=...

4. GPIO control

in order to contol the IO, RPi.GPIO is installed,

ref: http://openmicros.org/index.php/articles/94-ciseco...

note: the version is changed to the latest one

5. Socket server

the Raspberry pi is acting as a socket server

the Python script is attached as server_5.py.

ref: http://www.binarytides.com/python-socket-programmi...

All the modified files are attached.

IPhone remote controlled lamp
server_5.py1 KB
IPhone remote controlled lamp
interfaces282 bytes
IPhone remote controlled lamp
.bashrc3 KB
IPhone remote controlled lamp
inittab2 KB

Step 5: Software-iPhone

IPhone remote controlled lamp
IPhone remote controlled lamp
IPhone remote controlled lamp

Pythonista is installed in the iPhone to run the Python script, it also provides an UI design function.. The script is attahed as lamp.py.

Introduction of Pythonista can be found here: http://omz-software.com/pythonista/

IPhone remote controlled lamp
lamp.py862 bytes

Step 6: Connection and Testing

IPhone remote controlled lamp
IPhone remote controlled lamp
IPhone remote controlled lamp
IPhone remote controlled lamp
IPhone remote controlled lamp
IPhone remote controlled lamp
Show All 7 Items

1. modify the lamp, break the live wire and connect into the relay board, one end connect to the com port, and another end connect to the normal open port.

2. use the GPIO 11 of the Raspberry pi to control the relay

3. connect the iPhone and the Raspberry pi to the wifi router

4. the screen of the iPhone is captured after running the script, there will be pop-up notifications after press On and Off buttons.

5. two demo videos are also embedded

It can be easily modified to control other home appliances. And it is quite convenient since you can control it everywhere when you can receive the wifi signal.

 
 

Tag cloud

make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel