projects
/
EVA-2020-02-2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4f8716d
)
Clarified pin use, fixed missing setup
author
Phil Howard
<phil@gadgetoid.com>
Fri, 7 Jun 2019 09:49:37 +0000
(10:49 +0100)
committer
Phil Howard
<phil@gadgetoid.com>
Fri, 7 Jun 2019 09:49:37 +0000
(10:49 +0100)
library/envirophatplus/gas.py
patch
|
blob
|
blame
|
history
diff --git
a/library/envirophatplus/gas.py
b/library/envirophatplus/gas.py
index 9b213edadaad87b0ff5e7d7bb1f378ef3da76274..4f61940a5eb17feee2196f88f56615e9811cfd0a 100644
(file)
--- a/
library/envirophatplus/gas.py
+++ b/
library/envirophatplus/gas.py
@@
-1,9
+1,10
@@
"""Read the MICS6812 via an ads1015 ADC"""
"""Read the MICS6812 via an ads1015 ADC"""
+import atexit
import ads1015
import RPi.GPIO as GPIO
import ads1015
import RPi.GPIO as GPIO
-MICS6812_
EN
_PIN = 24
+MICS6812_
HEATER
_PIN = 24
ads1015.I2C_ADDRESS_DEFAULT = ads1015.I2C_ADDRESS_ALTERNATE
ads1015.I2C_ADDRESS_DEFAULT = ads1015.I2C_ADDRESS_ALTERNATE
@@
-40,11
+41,18
@@
def setup():
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
- GPIO.setup(MICS6812_EN_PIN, GPIO.OUT)
- GPIO.output(MICS6812_EN_PIN, 1)
+ GPIO.setup(MICS6812_HEATER_PIN, GPIO.OUT)
+ GPIO.output(MICS6812_HEATER_PIN, 1)
+ atexit.register(cleanup)
+
+
+def cleanup():
+ GPIO.output(MICS6812_HEATER_PIN, 0)
def read_all():
def read_all():
+ """Return gas resistence for oxidising, reducing and NH3"""
+ setup()
ox = adc.get_voltage('in0/gnd')
red = adc.get_voltage('in1/gnd')
nh3 = adc.get_voltage('in2/gnd')
ox = adc.get_voltage('in0/gnd')
red = adc.get_voltage('in1/gnd')
nh3 = adc.get_voltage('in2/gnd')