Yet Another WebIOPi+
Main Page
Related Pages
Packages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Macros
Pages
examples
clients
webiopi-client.py
Go to the documentation of this file.
1
from
webiopi.clients
import
*
2
from
time
import
sleep
3
4
# Create a WebIOPi client
5
client =
PiHttpClient
(
"192.168.1.234"
)
6
#client = PiMixedClient("192.168.1.234")
7
#client = PiCoapClient("192.168.1.234")
8
#client = PiMulticastClient()
9
10
client.setCredentials(
"webiopi"
,
"raspberry"
)
11
12
# RPi native GPIO
13
gpio =
NativeGPIO
(client)
14
gpio.setFunction(25,
"out"
)
15
state =
True
16
17
# DAC named "dac1"
18
dac =
DAC
(client,
"dac1"
)
19
20
# ADC named "adc1"
21
adc =
ADC
(client,
"adc1"
)
22
value = 0.0
23
24
# Temperature sensor named "temp0"
25
temp =
Temperature
(client,
"temp0"
)
26
27
while
True
:
28
# toggle digital state
29
state =
not
state
30
gpio.digitalWrite(25, state)
31
32
# increase analog value
33
value += 0.01
34
if
value > 1.0:
35
value = 0.0
36
dac.writeFloat(0, value)
37
38
# DAC output 0 is wired to ADC input 1
39
val = adc.readFloat(1)
40
print(
"Analog = %.2f"
% val)
41
42
# Retrieve temperature
43
t = temp.getCelsius()
44
print(
"Temperature = %.2f Celsius"
% t)
45
46
sleep(1)
webiopi.clients.DAC
Definition:
__init__.py:152
webiopi.clients.NativeGPIO
Definition:
__init__.py:135
webiopi.clients.ADC
Definition:
__init__.py:139
webiopi.clients.Temperature
Definition:
__init__.py:179
webiopi.clients.PiHttpClient
Definition:
__init__.py:79
webiopi.clients
Definition:
__init__.py:1
Generated on Sat Sep 10 2016 09:36:13 for Yet Another WebIOPi+ by
1.8.8