Sure, but it is a short range bus, lots of devices such as your setup imply a fair bit of wire. Opinions vary regarding just what the practical limit on distance actually is.
I rather doubt that I2C issues are causing your artifacting though.
Sure, but it is a short range bus, lots of devices such as your setup imply a fair bit of wire. Opinions vary regarding just what the practical limit on distance actually is.
I rather doubt that I2C issues are causing your artifacting though.
I2C is good to 1 meter (40 inches). I try to keep it below 30 inches. I will be more components on each Arduino.
From what I read, the limiting factors in the length of the I2C bus are wiring capacitance and cumulative pullup resistance, not necessarily wire length. The I2C standard specifies a max bus capacitance of 400 pF. And if the pullup resistance gets too low (from several modules with pullups on each and in parallel) the current required to pull the bus down gets to be more than 3mA.
From what I read, 10K pull up resistors are used on I2C bus, one on SDA and one on SCL lines. I have never placed pull up resistors on the I2C LCD power side. After rewiring the LCDs and not crossing wires, I only get blank screen now.
Come on ! We see so many troubles with the I2C bus on this forum.
If everything is done wrong, then 20 cm is the maximum length.
If 10 devices have each wires of 1 meter, then the I2C bus is 10 meters long.
About 2 meters is reasonable for a good I2C bus.
The bus capacitance is theoretical, the main problem is crosstalk between SDA and SCL and noise from motors.
I wrote that I see nine pullup resistors (nine for SDA and another nine for SCL). I'm serious, I see them
Pullup resistors on the HighSide and LowSide of the voltage level converter, I assume that there are pullup resistors on the displays (I could be wrong), pullup resistors on the Mega board and I forgot the internal pullup resistors of the ATmega chip.
The practical number of devices on the I2C bus can be a dozen or more, it mainly depends on the length of the wires/cable. Sometimes the onboard pullup resistors have to be removed.
The I2C standard says that the maximum sink current (to make SDA or SCL low) is indeed 3mA. It is allowed to sink more (the Arduino Uno can do 10 times more), but some sensors can barely do 3mA.
Troubles are what the forums are for. I have been told many times in 40+ years of doing projects that something can't be done. Usually because no one spent the time to research it. I usually don't buy cheap components.
So I can do 2 meters, if done right.
You are saying pull up resistors for each I2C device. Most schematics have just one set on the bus. What size pull up resistors do you recommend? Most say 10K resistors. I guess I need to look at the specs for the I2C bus pull up resistance size. So far I am at 14 devices. Digikey has 10K resistor arrays. I have 220 and 330 ohm resistor arrays I use on other projects.
One set of pullup resistors is required on the bus. The generally recommended values are 4.7K but one can calculate the pullup value for their use case.
If multiple I2C peripherals have pullups on their boards it doesn't take many before the total pullup resistance is too low. Remove the pullups from all but one device.
The 3mA is the limit. It is about the 3mA.
Normally the Master has 4k7 pullup resistors and all the Slaves have no pullup resistors.
However, many sensor modules and displays have pullup resistors on the modules, so you could have too much pullup. The Arduino Mega has also onboard pullup resistors of 10k.
If you add a I2C level shifter (with mosfets), then you have to calculate the sink current on both sides. Every I2C device that makes SDA or SCL low has to sink both sides of the level shifter.
Did you know that you can measure the sink current in the circuit ?
Make an empty sketch with only Wire.begin();
in setup(). Then measure the shortcut current from SDA to GND and from SCL to GND.
See also my Wiki on Github.
I found a few interesting articles on I2C pull up resistors. I have been looking at I2C Level Shifter with mosfets. I am going on vacation with my wife and children for a few days. It is turning into an interesting project and writeup. I found the Sunfounder I2C LCD specs.
I am back from my trip to Mackinaw City and Mackinaw Island. My wife and children had fun. Now back to work on this project
So still have the 4 I2C LCD screens connected up to the board. I am getting ready to connect the RPI 4B 8GB and 9 Arduino devices together to communication. I started looking at the serial communication. Most projects only allow 2 devices connected together for serial. What would be the best solution to connect all the devices for a larger project using all devices.
you can use RS485 and connect your devices on a serial bus.
Indeed, RA485 is a good way to go, particularly for longer distances; I've got 9 devices on a 60' run right now (the target keeps shifting, for those who may read my RS485 comments elsewhere). I run my loop at 115,200 baud, though I've been advised I can run that up quite a bit as long as I keep the buss length shorter than 100' or so, it all depends on sources of noise and bus performance; the bus is good for a lot longer than that, but you have to start dialing back the baud for best performance. There's A Texas Instruments app note on how to get the best RS485 performance, though I suspect it is a bit long in the tooth. Just like I2C, you have to manage the bus (only one set of termination resistors, for example), but that's just simple electronics.
C
No one told me there were any limits on I2C when I first used it. I got it working over about 30m with no signs that it would not go further. Then I came here and people were being told it would not go more than about half a metre. It will go a lot more than half a metre, one day I might experiment and find out just how far.
Unless someone else picked it up, don't power your Arduino boards from 9V, they are 5V devices, power them at 5V to the fiendishly named '5V' pin.
Yup, I've used that defense as well. There's a world of difference between working within the intended design limits, and pushing the limits. Example: temperature. We mostly play with our Arduinos in our temperature and humidity regulated office/lab space. Would you use an Arduino in an automotive application? I would hope not without considering the full temperature range the device is subjected to, and what the designer tested it to. Why? Because. Just Because. In the same vein, your I2C implementation might perform as @PerryBebbington relates, at room temperature. How will it work in an industrial setting, for example in a -40 or +50 degree temperature range? We don't know. Nor do you, without testing.
Sometimes, people on this forum, and others, get 'uptight' about what things 'will do', vs what they 'may do'. I hope, if your implementing while working beyond the 'design intent', that you'll test thoroughly, but it's still all on you if something fails; even if you do said testing, that doesn't mean the next batch of equipment from a supplier will perform in the same way when outside it's design limits as the previous batch did.
It's an old example, but I can tell you that floppy disks written at -20C were not readable at +20C. BTDT, got the reprimand.
C
It is not Halloween, but let me scare you all
The official standard is the document UM10204.pdf
They mention "10 cm" at page 54, paragraph 54. At 10 cm you already have to know what you are doing.
The reason is that the I2C bus can not deal with crosstalk between SDA and SCL.
Some do everything wrong and their I2C bus fails at only 20 cm length. Some do everything right and can do 2 meters. Some have extra special conditions and can go much further.
One of those special conditions is the Arduino AVR family boards, such as a Arduino Uno and the Arduino Mega. Those microcontrollers have a output slewrate limiter and a input filter for the I2C bus and a extra strong sink current. That really helps. Newer processors, such as on the Arduino MKR Zero, have just normal digital pins and that is noticeable worse for the I2C bus, which is already a weak bus by design.
Well, sorry for the delay in reading and responding. This week my children started 4Y Pre-K and 1st grade. So last weekend was taking them to have fun before school started.
As an B.EE, I tend to spend more time reading spec sheets and design sheets than building stuff. I have seen limits on I2C from 10cm to 1m. With proper hardware extenders 2m. The more I think about it, the more I believe the I2C LCD issues could be bus length.
When we were in Mackinaw on vacation and the kids were at the splash pad and pool, I had time to think and ponder. How can I connect the RPi and 9 Arduino devices to the serial bus to move data from master to slave and slave to master for the space ship project. I have watched the first episode of BattleStar Galactica and keep thinking back to how the ship computer systems were not connected together. I have plans for using servo motors and mounting distance sensors on them to rotate them to pick up objects and record the distances. Another set of sensors for temperature and humidity on another Arduino. I want to be able to utilize all 9 devices and possibly more.
I see a lot of projects using 1-2 Arduino devices but not many with over 5 working together.
I was thinking of turning the RPi into something else along the way. Then I started looking at Turing Pi boards and building a super computer with Samsung 960 or 970 1TB SSD drives. Probably for X-Mas, I will get the 3 channel Siglent power supply to go with my Scope.
Any suggestions or ideas?
These 9V 1A power transformers are designed for the Arduino devices. You can use both 5V and 3.3V rails with them. No issues powering them up from them. My electrician is going to come out in the future to do some more work on the house. I might have him put in two 20A circuits to isolate my Siglent scope from the bench power supply and other stuff. As I move forward to adding more devices to the buses, the Siglent SPD3303X-E is a good place to start.
CH1: Voltage 0 to 32 V
Current 0 to 3.2 A
CH2: Voltage 0 to 32 V,
Current 0 to 3.2 A
CH3: Voltage 2.5/3.3/5.0 V, Current 3.2 A
I can always add a second one later one. They are $399. They have a $549 unit that does 1mA thresholds on setting. $399 does 10mA.
I think you are confusing 2 very different things. Arduino boards run on 5V, some run on 3.3V but have a 5V connection. This is one thing. Another completely separate thing is that someone has designed a 9V power supply and claimed it is for powering Arduino boards. Such a claim makes no difference to the first thing I mentioned. Most* Arduino boards have a tiny linear regulator with an inadequate heat sink for powering them off voltages above 5V. This does not change the fact that the actual circuitry runs on 5V (or 3.3V), not 9V or whatever other voltage you decide to use. My advice** is always use 5V to the 5V pin. If you have to use an external device to get 5V make sure it is a switching regulator not a linear regulator.
*Some have buck converters, which are much more efficient, I don't know off hand which ones these are.
**My advice is my advice, your choice is to take it or ignore it as you see fit.
I am at a complete loss as to how that relates to anything I said.
Using a bench power supply to power components instead of the Arduino will allow more components and options. It will also take the strain off the Arduinos.
I have been doing some checking. Every spec page lists the External power (Vin/power jack) 7V ~ 12V.
I looked at the UART pins of the Mega 2560. I have UNO, UNO, UNO, Mega, Mega, UNO, UNO, UNO, UNO.
I can connect the 3 UNOs on the left to the Mega (4th device) and Mega (5 device) to the 4 UNOs on right side using TX0/RX0, TX1/RX1, TX2/RX2, TX3/RX3 on the Mega 2650s. The Mega devices can connect the I2C bus up to the I2C LCD devices.