I'm having difficulty reading MQ136 and MQ138 sensors with a ESP32 devkit v1. Debugging, my circuit correctly reads voltages applied to where the sensor Aout signals enter, and the sensors when breadboarded in isolation and stimulated with test gases (butane, acetone and smoke) respond with reasonable-looking voltages, but when I plug the sensors into the circuit, the ESP32 returns 4095 from each to the Thonny IDE. Also the ESP32 returns 4095 when the sensors are unplugged, when I'd expect to see values close to zero, ie, no input. I'd really appreciate thoughts about where my mistake is/are.
Test code:
Code: Select all
from machine import Pin, ADC
from time import sleep
mq136 = ADC(Pin(32))
mq138 = ADC(Pin(35))
mq136.width(ADC.WIDTH_12BIT)
mq138.width(ADC.WIDTH_12BIT)
mq136.atten(ADC.ATTN_11DB)
mq138.atten(ADC.ATTN_11DB)
while True:
mq136_value = mq136.read()
mq138_value = mq138.read()
print("mq136: " + str(mq136_value) + chr(9) + "mq138: " + str(mq138_value))
sleep(1)