- ox = (ox * 56000) / (3.3 - ox)
- red = (red * 56000) / (3.3 - red)
- nh3 = (nh3 * 56000) / (3.3 - nh3)
-
- return Mics6814Reading(ox, red, nh3)
+ try:
+ ox = (ox * 56000) / (3.3 - ox)
+ except ZeroDivisionError:
+ ox = 0
+
+ try:
+ red = (red * 56000) / (3.3 - red)
+ except ZeroDivisionError:
+ red = 0
+
+ try:
+ nh3 = (nh3 * 56000) / (3.3 - nh3)
+ except ZeroDivisionError:
+ nh3 = 0
+
+ analog = None
+
+ if _adc_enabled:
+ if _adc_gain == MICS6814_GAIN:
+ analog = adc.get_voltage('ref/gnd')
+ else:
+ adc.set_programmable_gain(_adc_gain)
+ time.sleep(0.05)
+ analog = adc.get_voltage('ref/gnd')
+ adc.set_programmable_gain(MICS6814_GAIN)
+
+ return Mics6814Reading(ox, red, nh3, analog)