# Understanding Dividing Voltage

I am attempting to get an ESP8266 to read temp from an analog temp sensor (TMP36). The ESP is on the Adafruit HUZZAH ESP8266 breakout. The board has a single analog pin that I believe will allow me to do this. The description of the board says the analog input has a 1.8v max voltage. I will be supplying the TMP36 with 3.3v.

Do I need to divide the output of the TMP36 to get a proper reading? How should this division be done? Once it is done, do I also then multiply the reading from the TMP36 by they same amount it was divided?

"To use, connect pin 1 (left) to power (between 2.7 and 5.5V), pin 3 (right) to ground, and pin 2 to analog in on your microcontroller. The voltage out is 0V at -50°C and 1.75V at 125°C.

The supply voltage can vary but the output stays in the range 0 - 1.75V (very close to your 1.8V max input) so no need for a divider.

• I did exactly that, and have a reading that is way too high. I am using a code example from Adafruit: learn.adafruit.com/tmp36-temperature-sensor/… Why are they multiplying the sensor reading by 5v or by 3.3v depending on the input? – Roger May 6 '15 at 14:58
• Ok, I stopped multiplying by the 3.3 and there it is, a good reading: 735.00 reading, 0.72 volts, 21.78 degrees C, 71.20 degrees F I don't understand why their code example has you multiply by your input voltage. Maybe there is a difference with the ESP and an actual Arduino board? – Roger May 6 '15 at 15:08
• the adafruit example multiplies by 5, because the output of analogRead gives a number between 0 and 1023 (0 for 0volts, 1023 for 5volts), they multiply the 0-1023 range by 5 to get a voltage (0mV to 5115mV), see arduino.cc/en/Reference/AnalogRead – Weboide Jan 27 '16 at 2:16

The TMP36 has a voltage output of 0V at -50°C and 1.75V at 125°C, so you should be able to connect it directly.

I believe that the ESP8266 runs from 3.3V, so you should have no worries if the TMP36 is also powered from that supply (if the ESP8266 supply was lower there might be a concern).

Edit: The ESP8266 SOC apparently has an internal ADC with a range of 0-1.00V. You can thus only use the ADC with direct connection if you do not wish to measure temperatures greater than 50°C. If you want to go to higher temperatures you can divide the voltage (for example, by two) and multiply after conversion, however your resolution will be reduced to half (about 2mV rather than 1mV, which translates to 0.2 degrees C rather than 0.1 degree C).

This also explains the problem you had with the code. The multiplier is not really the power supply, it's the ADC reference voltage (which happens to equal the power supply in the Arduino). In the case of the ESP8266, the reference is 1.0V.

• Ok, thank you. That makes so much more sense. I did not understand that the reading was based on reference voltage. Still don't completely understand reference voltage, seeing as the ESP is able to provide 3.3v to the sensor. Is it possible to check the exact ref voltage on the ESP with a meter? – Roger May 6 '15 at 15:52
• I don't think so, but you can measure the input voltage and work out from the count what the internal reference must be. – Spehro Pefhany May 6 '15 at 17:24
• You didn't actually explain how to divide the voltage. – GDorn Feb 17 '19 at 6:22