File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 11"""Read the MICS6812 via an ads1015 ADC"""
22
3+ import atexit
34import ads1015
45import RPi .GPIO as GPIO
56
6- MICS6812_EN_PIN = 24
7+ MICS6812_HEATER_PIN = 24
78
89
910ads1015 .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
4753def 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' )
You can’t perform that action at this time.
0 commit comments