Skip to content

Commit 82b86ca

Browse files
committed
Clarified pin use, fixed missing setup
1 parent 4f8716d commit 82b86ca

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

library/envirophatplus/gas.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""Read the MICS6812 via an ads1015 ADC"""
22

3+
import atexit
34
import ads1015
45
import RPi.GPIO as GPIO
56

6-
MICS6812_EN_PIN = 24
7+
MICS6812_HEATER_PIN = 24
78

89

910
ads1015.I2C_ADDRESS_DEFAULT = ads1015.I2C_ADDRESS_ALTERNATE
@@ -40,11 +41,18 @@ def setup():
4041

4142
GPIO.setwarnings(False)
4243
GPIO.setmode(GPIO.BCM)
43-
GPIO.setup(MICS6812_EN_PIN, GPIO.OUT)
44-
GPIO.output(MICS6812_EN_PIN, 1)
44+
GPIO.setup(MICS6812_HEATER_PIN, GPIO.OUT)
45+
GPIO.output(MICS6812_HEATER_PIN, 1)
46+
atexit.register(cleanup)
47+
48+
49+
def cleanup():
50+
GPIO.output(MICS6812_HEATER_PIN, 0)
4551

4652

4753
def read_all():
54+
"""Return gas resistence for oxidising, reducing and NH3"""
55+
setup()
4856
ox = adc.get_voltage('in0/gnd')
4957
red = adc.get_voltage('in1/gnd')
5058
nh3 = adc.get_voltage('in2/gnd')

0 commit comments

Comments
 (0)