Help with the PCA9685

I’m attempting to chain 5 PCA9685 breakout boards together to run LEDs. I have confirmed that the boards are not defective. They work individually. I have them chained together and have soldered the jumpers as per the tutorial. I have made separate objects for each board within the code. When I have all 5 connected and wired correctly, they stop working.

I am using a Arduino Mega.

Any help would be greatly appreciated!

Thank you!

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwm0 = Adafruit_PWMServoDriver(0x40, Wire);
Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x41, Wire);
Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(0x42, Wire);
Adafruit_PWMServoDriver pwm3 = Adafruit_PWMServoDriver(0x43, Wire);
Adafruit_PWMServoDriver pwm4 = Adafruit_PWMServoDriver(0x44, Wire);

void setup() {
  Serial.begin(9600);
  Serial.println("GPIO test!");

  pinMode(LED_BUILTIN, OUTPUT);

  pwm0.begin();
  pwm1.begin();
  pwm2.begin();
  pwm3.begin();
  pwm4.begin();

  pwm0.setPWMFreq(1000);  // Set to whatever you like, we don't use it in this demo!
  pwm1.setPWMFreq(1000);  // Set to whatever you like, we don't use it in this demo!
  pwm2.setPWMFreq(1000);  // Set to whatever you like, we don't use it in this demo!
  pwm3.setPWMFreq(1000);  // Set to whatever you like, we don't use it in this demo!
  pwm4.setPWMFreq(1000);  // Set to whatever you like, we don't use it in this demo!
 
  // if you want to really speed stuff up, you can go into 'fast 400khz I2C' mode
  // some i2c devices dont like this so much so if you're sharing the bus, watch
  // out for this!
  Wire.setClock(400000);
}

void loop() {
  //set state

digitalWrite(LED_BUILTIN, HIGH);
pwm0.setPWM(0, 4096, 0); //ON
delay(500);

digitalWrite(LED_BUILTIN, LOW);
pwm0.setPWM(0, 0, 4096); //OFF
delay(500);

digitalWrite(LED_BUILTIN, HIGH);
pwm0.setPWM(1, 4096, 0); //ON
delay(500);

digitalWrite(LED_BUILTIN, LOW);
pwm0.setPWM(1, 0, 4096); //OFF
delay(500);

digitalWrite(LED_BUILTIN, HIGH);
pwm0.setPWM(2, 4096, 0); //ON
delay(500);

digitalWrite(LED_BUILTIN, LOW);
pwm0.setPWM(2, 0, 4096); //OFF
delay(500);

digitalWrite(LED_BUILTIN, HIGH);
pwm0.setPWM(3, 4096, 0); //ON
delay(500);

digitalWrite(LED_BUILTIN, LOW);
pwm0.setPWM(3, 0, 4096); //OFF
delay(500);

}

Where is the power for the LEDs coming from ?

UKHeliBob:
Where is the power for the LEDs coming from ?

Thank you for the response!

I am using these (Youngneer DC 5V-36V 15A(Max 30A) 400W MOS Transistor Driving Controller Dual High-Power 0-20KHz FET Trigger Switch Driver Module Adjustable PWM Switch Control Board for Motor Speed Lamp Brightness) connected to a power supply but like I said, the LEDs and board are working when I only have one of them hooked up.

slashmarx:
but like I said, the LEDs and board are working when I only have one of them hooked up.

No, you said:

When I have all 5 connected and wired correctly, they stop working.

So which is it? Do 2, 3, and 4 connected work, or not.

PaulRB:
No, you said:So which is it? Do 2, 3, and 4 connected work, or not.

Thank you for the response.
I currently have 4 LEDs installed on board 0. All 4 LEDs work when board 0 is the only board connected. When I connect another board that is "jumpered" to be the next in line as board 1, board 0 does not power the LEDs anymore. I have tested board 1 as board 0 and it works as well.
Does that make sense?

It would help if a schematic,not a frizzy thing was posted showing all power and ground connections including power supplies.

gilshultz:
It would help if a schematic, not a frizzy thing was posted showing all power and ground connections including power supplies.

Thank you for the response.
Currently the only thing hooked up to the Arduino is the PCA9685 (Ground, VCC (5V), SDA, and SCL). and again, it does work when there are no other boards chained to it. I just checked the voltages and grounds on the additional boards and they all show the same voltages and all of the grounds all ohm out.

When board 0 is connected by itself, I can see the voltage jump on the correct pin. When the other 4 boards are connected (the only variable change in the equation), there is no voltage jump on the same pin on board 0.

Someone suggested a pull up resistor for the I2c. I just don't know how to go about doing that.

Have you tried the i2c scanner sketch? Try one board at a time with no leds connected. Check you get a different address detected for each of the boards. Then try connecting 2, 3, 4, 5 boards at the same time and after adding each board check that the scanner still sees each of the attached boards with their expected addresses.

If the scanner can't see more than one board, try those pull-up resistors. 4K7 between SCL and 5V and another between SDA and 5V.

PaulRB:
Have you tried the i2c scanner sketch? Try one board at a time with no leds connected. Check you get a different address detected for each of the boards. Then try connecting 2, 3, 4, 5 boards at the same time and after adding each board check that the scanner still sees each of the attached boards with their expected addresses.

If the scanner can't see more than one board, try those pull-up resistors. 4K7 between SCL and 5V and another between SDA and 5V.

Awesome, thank you so much, I'll give that a try!

I have them chained together

No you haven’t. You have connected them in parallel to the I2C bus. A chain is where the output of one chip goes into the input of the next. Like the way you connect shift registers.

have soldered the jumpers as per the tutorial.

What tutorial?

Do you have 0.1uF decoupling capacitors between power and ground on each board?

Grumpy_Mike:
No you haven’t. You have connected them in parallel to the I2C bus. A chain is where the output of one chip goes into the input of the next. Like the way you connect shift registers.
What tutorial?

Do you have 0.1uF decoupling capacitors between power and ground on each board?

That was the culprit! Thanks for the response!

slashmarx:
That was the culprit!

Which of those things Mike suggested was the culprit? For the sake of others searching the forum for help with a similar problem, please explain what you did wrong and how you corrected it.

I would imagine the modules containing the pca chips would already have decoupling caps.

PaulRB:
Which of those things Mike suggested was the culprit? For the sake of others searching the forum for help with a similar problem, please explain what you did wrong and how you corrected it.

I would imagine the modules containing the pca chips would already have decoupling caps.

Sorry, it was the capacitors. Too much noise on the I2C line I'm guessing.

I get it, you are hitting “Quote” every time you post, instead of hitting “REPLY”. It’s better to use REPLY unless there is a specific part of some post you want to refer to, or it would be confusing or ambiguous if you did not use Quote. Look how Mike and I have been using it.

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