/droiduino

Control your house via Internet using your Android phone with Python and Arduino!

Primary LanguagePython

Droiduino = Android + Arduino + Python

Introduction

This is a project in which you can control a cooler velocity via Internet. But with this code-base you can control any machine you have using your Android phone, via Internet.

The code is splitted in 3 parts:

  • Android: runs on top of Scripting Layer for Android (aka SL4A), using Python, HTML, CSS and JavaScript to communicate with an Web application (the Django Web application cited below).
  • Arduino: control the relays and other things you want based on the requests you made using your phone. Arduino get the status will want to your machines from the Django Web application (the same Android uses to change the status of the machines, cited above).
  • Django: the Web application in which Android will post the new statuses you want to your machines and in which Arduino will get these statuses.

See the next sections to know how to run the project.

Android Code

To do (Tatiana will, of course ;-).

Arduino Code

Arduino needs to get information about which should be the statuses of the machines you are controlling. It can be made in two methods:

USB

You need to have a computer connected via USB with Arduino and run permanently the script arduino/update_status.py, so the computer will get the information in the Django website and pass it through USB to Arduino.

To run this method you need to:

  • Configure the URL of Django app and Arduino USB port in arduino/update_status.py;
  • Configure the ports you are using in the Arduino at arduino/droiduino.ino;
  • Upload arduino/droiduino.ino to your Arduino;
  • Plug your Arduino in one USB port;
  • Run arduino/update_status.py (it was tested on GNU/Linux only, but is supposed to work in Windows and Mac OS with little changes. You need Python and PySerial installed to run this script.

Obviously, you need also the Django Web application running in the configured URL.

With this method Arduino talks directly with the Django Web application and gets the statuses. Note: Arduino code for this method is not finished yet since my Ethernet Shield is not working. Sorry :-(

Django Code

To run the Web application you need to install Django. The code available here (at django/) is for a Django project (called myproject) with only one Django app (called droiduino).

Using virtualenv

You can use virtualenv and virtualenvwrapper if don't need to install Django in your system:

mkvirtualenv droiduino
cdvirtualenv 
pip install django
cp -r /path/to/this/repository/django/myproject .

Running the tests

You can run the Web application tests with these commands:

cd django/myproject
./manage.py test

Running the Web application

To run this Web application you need a Web server that supports WSGI. I'm using the hosting company WebFaction and am very happy with the service (but you can use any company you choose).

Lectures About This Project

This project was presented by Tatiana Al-Chueyr and Álvaro Justen at PythonBrasil[7] in the talk "Controlando de LEDs a eletrodomésticos com Python, Android e Arduino" (Portuguese for "Controlling from LEDs to appliances with Python, Android and Arduino").

The talk was made on 2011-10-01 and we showed an example controlling our Coding Dojo traffic light (it was supposed to be a fan but some electronic components of the relay-drive circuit was not working).

License

This project is licensed under the GNU General Public License (aka GPL).

Copyright © Tatiana Al-Chueyr and Álvaro Justen 2011.