Controll 8 leds with pcf8574

"I have 8 LEDs, each measuring 5mm, with specifications of 1.8-2.2v and 20mA. I want to control them using an ESP8266 NodeMCU board with I2C communication.

I purchased a PCF8574 I/O expander and connected it to the 3.3V output from the ESP8266 NodeMCU.

I connected one leg of each LED to the PCF8574 and the other leg to the GND.

However, the brightness of the LEDs is very low, and I can't even see them properly. When I connect the LEDs directly to the NodeMCU with 3.3V and GND, the brightness is significantly higher."

is there another solution to controll 8 led diodes from SCL SDA

someone suggested to connect led to 5v with resistor and use BC547B as NPN transistor , is this a good way or there is better solution

Wrong. The PCF8574 sinks not sources. You connect the LEDs between Vcc and the PCF8574 pin.

In addition to what @6v6gt said

What? No current limiting resistor?

Looks like you have created a near short cicruit and are dragging down the power rail inside the chip.

No, you don't need to do that with a PCF8574.

so can u explain how can i connect

there are so many LED driver ICs - why not just select one IC which is made to drive LEDs?

Just to name a view - available as maker friendly breakout boards to play with:

HT16K33, I2C, up to 128 LEDs in a matrix/display
SX1509, I2C, 16 LEDs, pwm, blink, breath, keypad ...
MAX7219, SPI like, up to 64 LEDs in a matrix/display
TM1637, proprietary on two lines, up to 48 LEDs in a matrix/display, keypad,

1 Like

Google for the PCF8574 data sheet and you could find the following. Look at the LED connected to P0.

The data sheet is your friend.


Is this ok?

Connect annode to 5v with ressistor. And cathode to pcf8574

I see 1k resistor here . Do i need to calculate resistor (5v-2v)/0.020A or there is differwnt formula

Also what if i dont connect 10k ohm resistor to sda slc . Why are they there for

The resistor limits current draw to a safe level.

If 1k gives a reasonable brightness, leave it at 1k.

(5(Vcc) - 2V(Vf LED)) / 1k = 3mA


for 20mA

(5(Vcc) - 2V(Vf LED)) / 20mA = 150Ω

These are pull-up resistors which are needed on the I2C pins for proper signal generation.


BTW

Place a 100nF ceramic decoupling capacitor between and near the chips Vcc to GND pins.

There are many calculators online where you give in a few parameters and they say what series resistor you need for a specific led.
example: LED Series Resistor Calculator | DigiKey Electronics.
Important is that you don't exceed the current rating of the Arduino pi. You may need some information from the data sheet of the LED.

Yes.
It turns out that is about 150Ω. That gives you the full 20mA, but these days, with modern more efficient LEDs, that is normally too much current, and will be quite bright. So you can easily half the current or more. I normally use 470Ω or 510Ω. But it is not too critical.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.