Reading analog temperature from LM35 sensor
-
I have M5Stack Core 2. I connected the LM35 sensor to Gnd, Vcc and SDL ports using a grove connector cable. The I am reading the sample using analogRead(32). I am getting values around 1163 which does not seem to change at lower temperature. Without connection there is a different consultant value. Please help.
-
Hello @ankurj77
according to the M5Core2 schematic, GPIO32 and GPIO33, both already have a 5.1 k pull-up resistor in place, since Groove port A normally is meant to be used for I2C.
That said, I don't have an LM35 to test myself, but most likely this pull-up resistor has an influence on the final value read from the analog output of the LM35.
Thanks
Felix -
Does it mean that analog inputs cannot be read from grove ports on Core 2? Do I need to enable the Port A first somehow or do I need to enable the clock (port 33). The documentation is quite sleek and I cannot wrap my head around this.
-
Hello @ankurj77
Short answers:
- no, most likely analog signals cannot be read from M5Core2 port A due to the two pull-up resistors.
- no, port A doesn't need to be enabled first. It is already enabled.
- no, analog signals don't need a clock. The clock is used for I2C.
Note: as mentioned before, I don't own an LM35 and cannot test this myself, so my conclusions, solely drawn from reading the schematic, could be incorrect.
Long answer:
M5Stack has defined three Groove ports A, B and C.- A (red) is by default used for I2C (found on M5Core2)
- B (black) is by default used for DAC / ADC (found on M5GO Bottom2)
- C (blue) is by default used for UART (found on M5GO Bottom2)
There are exceptions to the above where a function can be setup and used on a port not meant for that. In case of port A in M5Core2 there are this two pull-up resistors already in place (which are required for I2C to function) but they also might or might not influence other usage.
Given that in your case you are reading the same value independent of the actual temperature, I assume that yes, the pull-up resistor messes with the analog signal from the LM35 and therefore port A most likely cannot be used for the LM35.
Your best bet would probably be to get an M5GO Bottom2 and then use port B (ADC) for the LM35. Or you could get an EnvIII Sensor (temperature and humidity air pressure) which uses I2C and works on port A.
Thanks
Felix -
You will find in another post interesting information given by ROBALSTONA
https://community.m5stack.com/topic/3782/waterproof-temperature-probe/5