Search code examples
pythonnodemcumicropythonesplorer

Access Multiple Sensors Value using Micropython in NodeMCU?


I am trying to gather inputs from five sensors and simply print the same but the return values always seem to return 1 or 0 regardless to change in the inputs to the sensors.

The code used by me is as follows

from machine import pin
p0 = Pin(0,Pin.IN)
p2 = Pin(2,Pin.IN)
print(p0.value())
print(p0.value())

Outputs:
1
1
or  0 0 or 1 0

etc depending if sensor is active or not but I am unable to get the exact value read by the sensor ie if I have pulse rate sensor connected it just shows 1 if its in use rather than providing the pulse rate.


Solution

  • A NodeMCU like all ESP8266 based systems has only one (rather limited) analog input. All other GPIO ports are digital. They deliver 0 or 1 only.

    To read analog values you will need additional hardware like an ADS1115.