Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AirPi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
julric
AirPi
Commits
19095b0e
Commit
19095b0e
authored
Dec 18, 2013
by
Tom Hartley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added light-blinking on success & failure
parent
a9fa220c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
airpi.py
airpi.py
+12
-3
sensors/dht22.py
sensors/dht22.py
+2
-2
settings.cfg
settings.cfg
+2
-0
No files found.
airpi.py
View file @
19095b0e
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
sys
import
sys
sys
.
dont_write_bytecode
=
True
sys
.
dont_write_bytecode
=
True
import
RPi.GPIO
as
GPIO
import
ConfigParser
import
ConfigParser
import
time
import
time
import
inspect
import
inspect
...
@@ -25,6 +26,8 @@ sensorConfig.read('sensors.cfg')
...
@@ -25,6 +26,8 @@ sensorConfig.read('sensors.cfg')
sensorNames
=
sensorConfig
.
sections
()
sensorNames
=
sensorConfig
.
sections
()
GPIO
.
setwarnings
(
False
)
GPIO
.
setmode
(
GPIO
.
BCM
)
#Use BCM GPIO numbers.
sensorPlugins
=
[]
sensorPlugins
=
[]
for
i
in
sensorNames
:
for
i
in
sensorNames
:
...
@@ -165,7 +168,10 @@ mainConfig.read("settings.cfg")
...
@@ -165,7 +168,10 @@ mainConfig.read("settings.cfg")
lastUpdated
=
0
lastUpdated
=
0
delayTime
=
mainConfig
.
getfloat
(
"Main"
,
"uploadDelay"
)
delayTime
=
mainConfig
.
getfloat
(
"Main"
,
"uploadDelay"
)
redPin
=
mainConfig
.
getint
(
"Main"
,
"redPin"
)
greenPin
=
mainConfig
.
getint
(
"Main"
,
"greenPin"
)
GPIO
.
setup
(
redPin
,
GPIO
.
OUT
,
initial
=
GPIO
.
LOW
)
GPIO
.
setup
(
greenPin
,
GPIO
.
OUT
,
initial
=
GPIO
.
LOW
)
while
True
:
while
True
:
curTime
=
time
.
time
()
curTime
=
time
.
time
()
if
(
curTime
-
lastUpdated
)
>
delayTime
:
if
(
curTime
-
lastUpdated
)
>
delayTime
:
...
@@ -188,7 +194,10 @@ while True:
...
@@ -188,7 +194,10 @@ while True:
working
=
working
and
i
.
outputData
(
data
)
working
=
working
and
i
.
outputData
(
data
)
if
working
:
if
working
:
print
"Uploaded successfully"
print
"Uploaded successfully"
#Blink Green
GPIO
.
output
(
greenPin
,
GPIO
.
HIGH
)
else
:
else
:
print
"Failed to upload"
print
"Failed to upload"
#Blink Red
GPIO
.
output
(
redPin
,
GPIO
.
HIGH
)
time
.
sleep
(
1
)
GPIO
.
output
(
greenPin
,
GPIO
.
LOW
)
GPIO
.
output
(
redPin
,
GPIO
.
LOW
)
sensors/dht22.py
View file @
19095b0e
...
@@ -30,13 +30,13 @@ class DHT22(sensor.Sensor):
...
@@ -30,13 +30,13 @@ class DHT22(sensor.Sensor):
if
(
time
.
time
()
-
tm
)
<
2
:
if
(
time
.
time
()
-
tm
)
<
2
:
t
,
h
=
dhtreader
.
lastData
t
,
h
=
dhtreader
.
lastData
else
:
else
:
t
=
time
.
time
()
t
im
=
time
.
time
()
try
:
try
:
t
,
h
=
dhtreader
.
read
(
22
,
self
.
pinNum
)
t
,
h
=
dhtreader
.
read
(
22
,
self
.
pinNum
)
except
Exception
:
except
Exception
:
t
,
h
=
dhtreader
.
lastData
t
,
h
=
dhtreader
.
lastData
dhtreader
.
lastData
=
(
t
,
h
)
dhtreader
.
lastData
=
(
t
,
h
)
dhtreader
.
lastDataTime
=
t
dhtreader
.
lastDataTime
=
t
im
if
self
.
valName
==
"Temperature"
:
if
self
.
valName
==
"Temperature"
:
temp
=
t
temp
=
t
if
self
.
valUnit
==
"Fahrenheit"
:
if
self
.
valUnit
==
"Fahrenheit"
:
...
...
settings.cfg
View file @
19095b0e
[Main]
[Main]
uploadDelay = 5 ;how long to wait before uploading again
uploadDelay = 5 ;how long to wait before uploading again
redPin=10
greenPin=22
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment