You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/pins/pins.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,11 +96,13 @@ The Analog class provides only static functions. It is not instantiated.
96
96
97
97
The following example samples an analog temperature sensor, converting the result to celsius degrees. The ESP8266 NodeMCU board has a single analog input pin, analog pin number 0.
98
98
99
-
let temperature = (Analog.read(0) / 1024) * 330;
99
+
let temperature = (Analog.read(0) / 1023) * 330 - 50;
100
100
trace(`Temperature is ${temperature} degrees celsius\n`);
101
101
102
102
The example works with a widely-available low-cost [temperature sensor](https://learn.adafruit.com/tmp36-temperature-sensor/overview).
103
103
104
+
Caution: The output voltage range of the TMP36 temperature sensor is 0.1V to 2.0V and the input voltage range of the analog to digital converter on the ESP8266 is 0V to 1.0V. To avoid damaging the ESP8266 a voltage divider should be used to reduce the magnitude of the TMP36 output voltage. The ESP8266 NodeMCU board has a voltage divider for this purpose. Other boards may not have a voltage divider.
105
+
104
106
### read(pin)
105
107
106
108
The `read` function samples the value of the specified pin, returning a value from 0 to 1023.
0 commit comments