Skip to content

Commit dff7a50

Browse files
fivdimkellner
authored andcommitted
doc: fix tmp36 conversion algorithm #32
1 parent 9b9f51f commit dff7a50

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

documentation/pins/pins.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ The Analog class provides only static functions. It is not instantiated.
9696

9797
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.
9898

99-
let temperature = (Analog.read(0) / 1024) * 330;
99+
let temperature = (Analog.read(0) / 1023) * 330 - 50;
100100
trace(`Temperature is ${temperature} degrees celsius\n`);
101101

102102
The example works with a widely-available low-cost [temperature sensor](https://learn.adafruit.com/tmp36-temperature-sensor/overview).
103103

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+
104106
### read(pin)
105107

106108
The `read` function samples the value of the specified pin, returning a value from 0 to 1023.

0 commit comments

Comments
 (0)