Analog package provides drivers for analog converter and PWM drivers.
ADC interface provide analogRead functions to read analog inputs.
Returns the analog channel count.
REST API : GET /devices/name/analog/count
Returns the analog resolution (bit count).
REST API : GET /devices/name/analog/count
Returns the analog maximum integer value.
REST API : GET /devices/name/analog/maximum
Returns the Voltage reference for a full scale.
REST API : GET /devices/name/analog/vref
Returns the integer value of the given analog channel.
REST API : GET /devices/name/analog/channel/integer
Returns the float value of the given analog channel, from 0.0 to 1.0.
REST API : GET /devices/name/analog/channel/float
Returns the voltage value of the given analog channel.
REST API : GET /devices/name/analog/channel/volt
Returns a list containing all analog channels integer value.
REST API : GET
/devices/name/analog/*
/integer
Returns a list containing all analog channels float value.
REST API : GET
/devices/name/analog/*
/float
Returns a list containing all analog channels voltage value.
REST API : GET
/devices/name/analog/*
/float
from webiopi import deviceInstance
from webiopi.devices.analog import ADS1015, MCP3208
ads = ADS1015(...) # setup a ADS1015 I2C ADC
# or
ads = deviceInstance("ads") # retrieve device named "ads" in configuration file
ads.analogCount() # returns ADS1015 analog channel count
ads.analogMaximum() # returns ADS1015 maximum integer value
ads.analogRead(0) # returns ADS1015 analog channel 0 as integer
ads.analogReadFloat(0) # returns ADS1015 analog channel 0 as float
ads.analogReadVolt(0) # returns ADS1015 analog channel 0 as volt
mcp = MCP3208(...) # setup a MCP3208 SPI ADC
mcp.analogCount() # returns MCP3208 analog channel count
mcp.analogMaximum() # returns MCP3208 maximum integer value
mcp.analogRead(0) # returns MCP3208 analog channel 0 as integer
mcp.analogReadFloat(0) # returns MCP3208 analog channel 0 as float
mcp.analogReadVolt(0) # returns MCP3208 analog channel 0 as volt
HTTP GET /devices/ads/analog/0/integer # returns "ads" analog channel 0 as integer
HTTP GET /devices/ads/analog/0/float # returns "ads" analog channel 0 as float
HTTP GET /devices/ads/analog/0/volt # returns "ads" analog channel 0 as volt
DAC interfaces extends ADC to add analogWrite functions.
Write an integer value to the given analog channel.
REST API : POST /devices/name/analog/channel/integer/value
Write a float ratio value to the given analog channel.
REST API : POST /devices/name/analog/channel/float/value
Write a voltage value to the given analog channel.
REST API : POST /devices/name/analog/channel/volt/value
from webiopi.devices.analog import MCP4725
mcp = MCP4725(...) # setup a MCP4725 I2C DAC
mcp.analogCount() # returns MCP4725 analog channel count
max = mcp.analogMaximum() # returns MCP4725 maximum integer value
mcp.analogWrite(0, max) # set 100% on MCP4725 analog channel 0
mcp.analogWriteFloat(0, 0.5) # set 50% on MCP4725 analog channel 0
mcp.analogWriteVolt(0, 0.0) # set 0V on MCP4725 analog channel 0
mcp.analogRead(0) # returns MCP4725 analog channel 0 as integer
mcp.analogReadFloat(0) # returns MCP4725 analog channel 0 as float
mcp.analogReadVolt(0) # returns MCP4725 analog channel 0 as volt
HTTP POST /devices/mcp/analog/0/integer/0 # send 0 to "mcp" analog channel 0
HTTP POST /devices/mcp/analog/0/float/0.0 # send 0 to "mcp" analog channel 0
HTTP POST /devices/mcp/analog/0/volt/0.0 # send 0 to "mcp" analog channel 0
HTTP GET /devices/mcp/analog/0/integer # returns "mcp" analog channel 0 as integer
HTTP GET /devices/mcp/analog/0/float # returns "mcp" analog channel 0 as float
HTTP GET /devices/mcp/analog/0/volt # returns "mcp" analog channel 0 as volt
PWM interface provides pwmWrite functions to output duty-cycle ratio PWM.
Returns the PWM channel count.
REST API : GET /devices/name/pwm/count
Returns the PWM resolution (bit count).
REST API : GET /devices/name/pwm/resolution
Returns the PWM maximum integer value.
REST API : GET /devices/name/pwm/maximum
Write an integer value to the given PWM channel.
REST API : POST /devices/name/pwm/channel/integer/value
Write a float duty-cycle ratio value to the given PWM channel.
REST API : POST /devices/name/pwm/channel/float/value
Write a servo angle value to the given PWM channel.
REST API : POST /devices/name/pwm/channel/angle/value
Returns the integer value of the given PWM channel.
REST API : GET /devices/name/pwm/channel/integer
Returns the float duty-cycle ratio value of the given PWM channel.
REST API : GET /devices/name/pwm/channel/float
Returns the servo angle value of the given PWM channel.
REST API : GET /devices/name/pwm/channel/angle
Returns a list containing all PWM channels integer value.
REST API : GET /devices/name/pwm/*
/integer
Returns a list containing all PWM channels float duty-cycle ratio value.
REST API : GET /devices/name/pwm/*
/float
Returns a list containing all PWM channels servo angle value.
REST API : GET /devices/name/pwm/*
/angle
Returns a list containing all PWM channels value.
REST API : GET /devices/name/pwm/*
from webiopi import deviceInstance
from webiopi.devices.analog import PCA9685
pca = PCA9685(...) # setup a PCA9685 I2C PWM
# or
pca = deviceInstance("pca") # retrieve device named "pca" in configuration file
pca.pwmCount() # returns PCA9685 pwm channel count
max = pca.pwmMaximum() # returns PCA9685 maximum integer value
pca.pwmWrite(0, max) # set 100% on PCA9685 pwm channel 0 (integer value)
pca.pwmWriteFloat(0, 0.5) # set 50% on PCA9685 pwm channel 0 (float value)
pca.pwmWriteAngle(0, 0.0) # set 0° on PCA9685 pwm channel 0 (servo angle value)
pca.pwmRead(0) # returns PCA9685 pwm channel 0 as integer
pca.pwmReadFloat(0) # returns PCA9685 pwm channel 0 as float
pca.pwmReadAngle(0) # returns PCA9685 pwm channel 0 as angle
HTTP POST /devices/pca/pwm/0/integer/0 # set 0% on "pca" pwm channel 0 (integer value)
HTTP POST /devices/pca/pwm/0/float/0.0 # set 0% on "pca" pwm channel 0 (float value)
HTTP POST /devices/pca/pwm/0/angle/0.0 # set 0° on "pca" pwm channel 0 (servo angle value)
HTTP GET /devices/pca/pwm/0/integer # returns "pca" pwm channel 0 as integer
HTTP GET /devices/pca/pwm/0/float # returns "pca" pwm channel 0 as float
HTTP GET /devices/pca/pwm/0/angle # returns "pca" pwm channel 0 as servo angle