trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

WebIOPi 0.6 release, with UART/SPI/I2C support

Wed Mar 27, 2013 9:02 pm

As said in the subject, WebIOPi 0.6 is now alive, with new exciting features.
UART, SPI, I2C support provide on consistent way to access most commons devices, including ADC, DAC, and sensors.
It relies on a self written library, and not on existing serial/spidev/i2cdev libraries.
With a common abstraction, it becomes more easy to use this interfaces on the RPi instead on relying on multiples libraries.
And unlike i2c smbus wich is not available on Python 3.2, WebIOPi is fully compatible with both Python 2.7 and Python 3.2.

See my blog post for explanation on all new features : http://trouch.com/2013/03/27/webiopi-0- ... pi-to-iot/
As usual, everything is documented and available on both google code : https://code.google.com/p/webiopi/
For headed Pi, WebIOPi 0.6 can also be found on the Pi Store.

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

Re: WebIOPi 0.6 release, with UART/SPI/I2C support

Sun Mar 31, 2013 6:37 pm

in case you missed it, WebIOPi 0.6 supports more than 30 devices natively, including most used ADC, DAC, and sensors.
see https://code.google.com/p/webiopi/wiki/DEVICES for a full list.
you can use webiopi drivers in your python script or with webiopi to access them through the REST API.

Python example :

Code: Select all

# Analog package contains ADC, DAC, PWM drivers
from webiopi.devices.analog import MCP3008, ADS1015, MCP4922, MCP4725
# Digital package contains GPIO expanders
from webiopi.devices.digital import MCP23017
# Sensor package contains several Temperature, Luminosity and Pressure sensors
from webiopi.devices.sensor import BMP085, DS18B20

# Setup SPI analog components
adc0 = MCP3008(chip=0) # MCP CS wired to Pi CE0
dac0 = MCP4922(chip=1) # MCP CS wired to Pi CE1

# Setup I2C analog components
adc1 = ADS1015(slave=0x40)
dac1 = MCP4725(slave=0x62)

# Setup I2C GPIO expander
gpio1 = MCP23017(slave=0x20)

# Setup sensors
tmp = DS18B20()
bmp = BMP085()

# Output HIGH on GPIO expander channel 0
gpio1.setFunction(0, GPIO.OUT)
gpio1.digitalWrite(0, GPIO.HIGH)

# Read ADC
print adc0.analogRead(0)       # Channel 0 as integer
print adc0.analogReadFloat(1)  # Channel 1 as float (0.0 to 1.0)
print adc0.analogReadVolt(2)   # Channel 2 as volt

# Write on DAC
dac0.analogWrite(0, 1023)      # Output 100% on Channel 0
dac0.analogWriteFloat(0, 0.5)  # Output  50% on Channel 0
dac0.analogWriteVolt(0, 3.3)   # Output 3.3V on Channel 0

# Retrieve sensor data
print tmp.getCelsius()
print bmp.getCelsius()
print bmp.getHectoPascal()

REST Example :

Code: Select all

HTTP GET /devices/adc0/analog/0/float
HTTP POST /devices/dac0/analog/0/float/1.0

HTTP GET /devices/gpio0/0/value
HTTP GET /devices/gpio0/0/function
HTTP POST /devices/gpio0/0/value/1

HTTP GET /devices/tmp/sensor/temperature/c
HTTP GET /devices/bmp/sensor/temperature/f
HTTP GET /devices/bmp/sensor/pressure/hpa
You can also use the Javascript client library to quickly build customs web UI or the Python client library for some Pi-2-Pi interaction.

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

legend1066
Posts: 2
Joined: Thu Feb 21, 2013 9:21 am

Re: WebIOPi 0.6 release, with UART/SPI/I2C support

Fri Apr 19, 2013 10:15 am

great work! thank you very much

Return to “Interfacing (DSI, CSI, I2C, etc.)”