pyaler is a WSGI application to control your arduino devices via a RESTful api.
- Website: http://www.pyaler.org
- Demo: http://play.pyaler.org
- Sources: http://forge.bearstech.com/trac/wiki/Pyaler
- Pypi: http://pypi.python.org/pypi/pyaler/
- Python.org documentation: http://packages.python.org/pyaler/
$ pyaler conf.yaml
from pyaler import pyaler
application = pyaler.make_app({}, config='conf.yaml')
Create a config file:
[server:main]
use = egg:Paste#http
host = 0.0.0.0
port = 8000
[app:main]
use = egg:pyaler
config = %(here)s/conf.yaml
Then run:
$ paster serve config.ini
Or create a mod_wsgi file:
from paste.deploy import loadapp
application = loadapp('config:%s' % '/path/to/config.ini')
pyaler is based on bottle. You can use the bottle api to extend your pyaler service. Here is a simple example:
# -*- coding: utf-8 -*-
from pyaler import app
@app.route('/')
def index():
return '<html><title>live</title></html>'
Then create your WSGI application like this:
from pyaler import pyaler
application = pyaler.make_app({}, config='conf.yaml', app='yourappmodule')
Led on / led off example. First, C source:
int incomingByte = 0;
int ledPin = 13;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
incomingByte = Serial.read();
if (incomingByte > 49) {
digitalWrite(ledPin, HIGH);
Serial.println('LED turned ON');
} else {
digitalWrite(ledPin, LOW);
Serial.println('LED turned OFF');
}
}
}
Then you can run with this matching yaml configuration
arduinos:
arduino1: /dev/tty.usbserial-A800eIR3
arduino2: /dev/tty.usbserial-A800eIho
read_actions:
write_actions:
ledon: 42
ledoff: 0
Contents: