## Resistors required?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
ZKDMun
Posts: 42
Joined: Thu Nov 24, 2016 2:34 pm
Location: Hamburg

### Resistors required?

(Maybe a genearal question for all kind of boards)

I read a lot of tutorials for the ESP8266. In some tutorials they used for wiring some kinds of resistors - in other tutorials they didn't use any resistors and only used direct connections to the board.

First I thought it has something to do with the modules and so on, but then I compared tutorials with same modules... and for example one guy used for a DHT22 a 4,7k ohm resistor for the data-connection, the next one didn't.

In this Tutorial from Adafruit about the HUZZAH Board you can read, that you should use any resistor between 560 and 3k ohm, because you can damage the LED or the board if you don't. In many other tutorials they don't say anything about resistors. (btw.: a normal led use ~2V by 20mA, the HUZZAH delivers 3,3V... (3,3-2,0)/0,02 = 65 ohm... why should I use 560 and more?))

In some tutorials I read that you should always connect everything with a 1k resistor.

In the tutorials without any resistors the experiments always worked, why should I need any resistors and how can I find out which resistor is the best choice?

I am very confused because of the different tutorials...

pythoncoder
Posts: 4471
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

### Re: Resistors required?

Your calculation of the LED resistor value suggests you understand why it is required. I would assume a value of 1.7V for a red LED rather than 2V, but the aim is to design for a current within the ratings of the LED and the driving pin. An ESP8266 pin can sink 20mA so in principle a minimum value of (3.3-1.7)/20 = 80 ohms could be used. A cautious person might opt for a slightly higher value to accommodate variation in the voltage values.

A substantially higher value will save power with some loss of brightness. I have a project which uses 1.2K: the reason being that it's battery operated and I can accept the low brightness.
Peter Hinch

deshipu
Posts: 1374
Joined: Thu May 28, 2015 5:54 pm

### Re: Resistors required?

Most examples will work without the resistors or capacitors when you try them, but will:
• risk damaging your board or other components,
• including wear damage over long time,
• use more power than needed,
• heat more,
• stop working when longer wires are used (especially with I2C),
• randomly stop working when some seemingly unrelated change is made,
• give worse results.
It's best to always refer to the part's datasheet and follow the manufacturer's recommendations listed there.

ZKDMun
Posts: 42
Joined: Thu Nov 24, 2016 2:34 pm
Location: Hamburg

### Re: Resistors required?

Thank you very much!

Further question:
Can I use the voltage divider methode in any case?
For example if I can not finde any information about the electric current...

For red LED:

Vout = Vin * (R2/(R1+R2))

Vin = 3.3V
Vout = 1.7V
=> any two resistors with the same ohm will solve this task? (for example: R1 = 1k ohm, R2 = 1k ohm)

and for a potentiometer which need 1V as Vout:
R1 = 220, R2 = 100; or
R1 = 2.2k, R2 = 1k
...

or is there any error in reasoning?

ZKDMun
Posts: 42
Joined: Thu Nov 24, 2016 2:34 pm
Location: Hamburg

### Re: Resistors required?

ok, maybe I don't net a voltage divider for the AO on the NodeMCU.

My first test was with a voltage divider R1 = 220, R2 = 100 and a potentiometer... and the highest value was 340...

without any resistor the highest value is 1024.

My wiring:
NodeMCU -> potentiometer
GND -> GND
3V3 -> Vcc
AO -> Vout

I thought AO is just for 1V?

deshipu
Posts: 1374
Joined: Thu May 28, 2015 5:54 pm

### Re: Resistors required?

The nodemcu board already includes a voltage divider.

pythoncoder
Posts: 4471
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

### Re: Resistors required?

@ZKDMun A voltage divider is not an effective way to drive an LED. The problem you are trying to solve is this. An MCU pin, when driven low, is linked to 0V via a MOSFET. This device is rated to be capable of sinking a maximum of 20mA (in the case of EP8266), so you have to ensure that this condition is met.

An LED is (to a first approximation) a constant voltage device: a red LED will drop about 1.7V whether you put 1mA or 20mA through it. So if the LED anode is connected to 3.3V its cathode will be at (3.3 - 1.7 = 1.6V). A single resistor between the cathode and the pin determines the current while ensuring that all the current flows through the LED.

An LED will also have a maximum current rating, but typically this will be higher than 20mA. If so, its rating is irrelevant.

If you tried to use a voltage divider much of the current would flow through the two resistors rather than through the LED. It would also be needlessly critical of component values: if the voltage divider produced 1.6V across the LED rather than 1.7V it would probably barely light at all.

I would suggest getting a book (or online course) on basic electronics. It's difficult to cover the subject effectively in a forum such as this. Perhaps someone knows a good one?
Peter Hinch