bearstech

Welcome to pyaler’s documentation!

pyaler is a WSGI application to control your arduino devices via a RESTful api.

Installation

With easy_install:

$ easy_install -U pyaler

With pip:

$ pip install pyaler

Usage

$ pyaler conf.yaml

Deploy

With mod_wsgi

from pyaler import pyaler

application = pyaler.make_app({}, config='conf.yaml')

With PasteDeploy

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')

Extending pyaler

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')

Example usage

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:

Indices and tables

Table Of Contents

This Page