- Parent Category: Mod's
Arduino I2C multiple slaves
Connecting more than 1 I2C device to an Arduino is simple, if you follow some basic rules.
The I2C bus is designed to be a multipoint serial connection system.
So it was always intended to use with multiple devices.
But how can they share the same Pins on the Arduino?
Here is a simple layout:
The µC Master is the Arduino, with multiple I2C Slaves connected over the SDA and SCL Lines.
The Trick is within the 2 pullup Resistors Rp!
I2C pullup resistors
They are needed to help the devices with getting the slew rates it needes. Depending on the i2c bus speed different rise times are needed.
In Standard mode with 100khz a maximum rise time of 1000ns is ok, for fast mode with 400khz the rise time should not exceed 300ns.
If want to just get it going, take 4.7k and it will work when you have just 1 slave.
But we want to make it right or?
The size is depending from the total capacitance in the circuit, so you will have to look to the datasheets and sum up the capacitance to get our Cb, next look up the formula:
Rp(max) = tr/0.8473 x Cb
Where tr is our allowed rise time for the signal, take this with 1µs or 300ns depending on your bus speed.
See also the TI Application note: SLVA689 I2C Bus Pullup Resistor Calculation
So what? What happens when the resistor is wrong?
I2C wrong pullup resistor
if the resistor is to high the signal rises to slow, that will cause missing bits -> trouble.
But also to low values get you trouble, they will draw too much current, do not go below 1k.
Good practice is to first make the calculations, then hook up a oscilloscope and verify your values.
I2C bus slave address conflict
Every slave must have a unique address, so check your datasheets and ensure that the devices all have unique addresses!
I2C Bus with mixed Voltages
mixing 5V and 3V devices is possible, but dont just connect them together!
It needs a bidirectional level shifter, common practice is to use Mosfets with clamping diodes.
Take a look at the Application Note 10441 from NXP it is about "Level shifting techniques in I2C-bus design"
Also the old Application Note AN97055 "Bi-directional level shifter for I2C-bus and other systems." is a more in depth read about it.
- Parent Category: Mod's
Arduino Battery Tester
a small project to test 1S Lipo batterys used in micro Helicopters with the help of a Arduino.
An Arduino shield with mosfets switches big load resistors until the Lipo is drained,
and transmitts the current voltage over the USB Port to the PC.
Sourcecode, Diagramms and more after the break!