I'm using arduino mega2560 to communicate with 4 i2c devices. 1 liquid crystal lcd, 1rtc, 2 pcf8574
Everything seems to work fine up until it dont. What seems to be happening is sometimes output on the pcf8574 just goes high state again. I'm trying to debug the issue.
My i2c connection is 1ft of 22gua stranded copper wire. The pcf8574 are within an inch from each other. They connect to 4 ch moosfet modules that are controlling solinoids and relays.
Just for testing I hooked up 10 amp inductive loads to the 120v realys and 10 amp inductive 12v loads to the mosfets, when I switch the loads really fast for a long time I didn't get and interference.
Does this sound like it could be interference problem? The arduino never hangs. It pretends as if nothing has changed and continues on
The pcf8574 devices don't have any resitors on the sda,scl lines.
The mosfet boards are using pc817 optocouplers. I have ran the 5v that powers the pcf8574 to the optocouplers and use set output of pcf8574 low to sink current and turn on mosfet.
It seems to just happen randomly. Could I benefit from using and pull up resistors? Do I need decoupling caps on the i2c devices?
I2C needs pullup resistors on SDA and SCL. Some I2C breakout boards include them.
Turn off the power and measure from SDA and SCL to the power supply + terminal
to see if they are there.
that's unual. That is very low. Typical is 4.7k
If you can trace from those terminals to actual resistors that would be a start.
You can't add resistance because it would lower because it would be in parallel.
R(parallel=(R1*R2)/(R1+R2)
The board shows 6x 1K resistors. I guess 3 as pull-up/down for the dip switches, 2 for SCL/SDA pull-ups, and the final one for... pull-up for the INT line perhaps?
1K is much too low/strong for SCL/SDA lines. A bad design.
i have 2 of the pcf8574 with sda scl connected together, i took a brand new out of the the pack and they measure 1k, i think i found the resistor that pulling the sda scl pins up. should i remove them? does each chip need its own or should i just put them at the arduino side?
You don't need to. if you have less than 5 I2C devices they can each have 10k and it should
still work.
(five 10k resistors in parallel =2k)(the low end of the 2k to 10k acceptable range)