Some sensors give as output a voltage between 0 and 5V. The analog inputs of the NodeMCU require voltages between 0 and 3.3V. I plan to make a voltage divider with two resistors like in this link for compatibility.

To provide the desired voltage the quotient of the values of the resistances is fixed (approx. 1/2 for this case). However, the absolute values of the resistances are not.

Q: How to choose those absolute values? Which are the criteria and why?

I have a good background in electromagnetism but I know very few about electronic Engineering.

I think that low values must work, e.g. 1Ω and 2Ω (and surely greater values). But I am unsure of VERY high resistance values because I suspect that there should be some current intensity requirements.

Thank you.


3 Answers 3


As @Majenko commented, the A0 input has a fixed voltage divider (see NodeMCU Schematics) that connects the A0 input to a 220kOhm resistor, then to the ADC pin of the ESP8266, then to ground via a 100kOhm resistor.

enter image description here

This effectively fixes the resistor values that can be used to scale the input of the NodeMCU. For a 0-5.0V input range (with sufficiently low impedance) you need to scale the ADC pin from 0-1.0V by adding a ~180kOhm resistor between the 5V output and the A0 input of the NodeMCU, creating a 400kOhm-> ADC -> 100kOhm divider like this:


simulate this circuit – Schematic created using CircuitLab

  • what are the trade-off with this compared to adding a parallel resistor between A0 and GND?
    – dandavis
    Jan 21, 2020 at 21:19
  • I don't think there are any trade-offs to be honest. You need to divide your 0-5.0V sensor output by 5 to create a 0-1.0V signal on the ADC pin of the ESP8266 and this is about the simplest and most efficient way to achieve that. The resistor values are sufficiently high as to create very little load on your sensor output. The only drawback I can think of is in the case of very high frequency signals.
    – StarCat
    Jan 21, 2020 at 21:31
  • For digital inputs, do I need to add two resistances, right? Jan 21, 2020 at 21:52
  • 1
    Digital inputs dont’t have an internal voltage divider on the NodeMCU board and accept 3.3V input. To scale from 5V to 3.3V you need a divider 3/5 divider. For example: 5V Input->2.2kOhm->NodeMCU input->3.3kOhm->GND
    – StarCat
    Jan 21, 2020 at 22:03

The low end of the values is limited by how much current your sensor can provide. If you use 1Ω and 2Ω resistors in series then your sensor will need to provide 1.67A to create 5V across the divider. I doubt that your sensor can do that. For most sensors, you would want to use resistors in the kilohm or tens of kilohm range.

The high end is limited by the input impedance of the analog input pin. If your resistor values are large compared to this input impedance then the input impedance of the analog pin will affect how the voltage divider works. If the analog input is multiplexed and the ADC has a sample-and-hold at the input, then very large resistances in the divider will not allow the sampling capacitor to charge fast enough. For most ADC inputs, you would want to use resistors in the tens or hundreds of kilohms.

  • Thank you! There is still something that I do not get about low values: If the sensor works giving an output up to 5V when it is connected to an Arduino, and the sensor cannot provide 1.67A, it implies that there is already an enough large resistor in the Arduino board (or NodeMCU). Doesn't it? In such case, there should not be a problem using small resistances in the divisor. In other words, if the sensor can work with the board without any additional resistance, how can it be that adding resistances forces the sensor to provide greater currents? Excuse if it is a silly question. Thanks. Jan 21, 2020 at 21:09
  • 1
    the less resistance in the divider, the more wasted heat and constant current consumption there is to deal with. Sure a 1ohm pair scales 5v into 2.5v, but it also wastes 2.5W of power and makes enough heat to fry 10 common resistors. If the sensor cannot supply those amps, it will drop the voltage or fry the sensor.
    – dandavis
    Jan 21, 2020 at 21:16
  • 1
    @user1420303 The problem is that the resistance of the divider is in parallel with the input resistance of the microcontroller, not in series. Putting resistances in parallel results in an equivalent resistance that is less than either of the original resistances. Very large currents will flow through your divider. Jan 21, 2020 at 23:28
  • For ATMega based Arduinos the effective resistance seen by the ADC should not be higher than 10kohm for the reason you describe. Since it is the Thevenin resistance that is seen a two to 1 divider using 20kohm resistors would give 10k effective. In general use something between 1k and 10k. Oct 1, 2020 at 21:32

To better understand voltage divider, one can look at this online calculator https://ohmslawcalculator.com/voltage-divider-calculator to see the actual formula and try the calculator to compute the unknown wanted.

It is not well publish the existing voltage divider on the NodeMCU, of course you need to browse the schematic to figure it out.

It goes the same with existing pullup resistor for some GPIO.

@Majenko your explanation is excellent!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.