HI - One Grove base shield has 4 I2C slots. Each slot can also be extended with Grove I2C Hub. Can anyone tell me any limitations to extend I2C slot on one base shield? How many I2C Motor Driver can be connected on one base shield? Can I use it to drive electric solenoid valve, fan and pump? Thanks, Michael
You’ve asked a lot of great questions. I don’t know the answer to all of them, but I think I may be able to provide some general guidance.
It’s great you’re thinking of using the Grove system to communicate with a number of I2C devices. There is a lot of flexibility gained by using I2C devices, and the Grove system provides the means to use a number of configurations, depending on your project’s requirements. So let’s start by discussing some fundamentals of I2C to ensure we touch on some guidelines relevant to designing a robust project…and one that won’t end with a few curls of smoke due to overloaded components.
The I2C bus, also known as the Two Wire Interface (TWI), and in Arduino circles as the Wire interface because of the Wire libraries, is a four signal bus designed to connect one of more microcomputers to one or more smart I/O devices. In most cases, the Arduino’s 328P is the microcontroller. Depending on the I/O devices and the version of the I2C protocol your project uses, it’s theoretically possible to link up over 120 devices or over 1000 devices. Projects that size would require very special hardware and design, just like some of the projects you may be considering.
In most cases, at higher clock rates, the maximum length of an I2C bus may be no more than three meters. This can limit the utility in situations when sensors and actuators may be long distances away. If your project is on a human-size scale, though, a three meter I2C bus may be perfectly fine. Shorter buses will also allow you to use 100KHz or higher clock rates, which may be important for fast sensor updates and precise actuator control.
One of the other things to consider when designing with the I2C bus is how your project will power the sensors and actuators attached to the I2C bus. If your I2C devices are entirely powered by the VCC and GND pins on the I2C bus, then your project can only draw what your power supply can provide. For example, most USB connectors can provide no more than 500mA of current. If your project drew exclusively on the I2C bus, and drew more than that, you will likely experience problems throughout your system, including the possibility of tripping fuses and burning out components. Please be safe at your test bench!
If the actual sensors and actuators and possibly real world devices such as motors, solenoids, and displays, are all powered through a separate supply, then the power drawn by the I2C components, your Arduino, and other components is probably much less. If your system is battery powered, then your project will be limited by how much the batteries can supply.
There are many ways to combine Grove Shields, Arduinos or Seeeduinos, I2C hubs, and Grove cables, perhaps too many to cover in this reply. A simple but powerful combination might consist of the Seeeduino v3, a Grove Branch Cable, and 2 I2c devices. The Seeeduino v3 has an onboard Grove-style socket for the I2c bus. Plug the middle connector of the Grove Branch Cable into the Seeeduino, and the other two ends to the two I2c devices for a low cost prototype.
If your Seeeduino project has more than two I2C devices, you could use one or more I2C hubs. Start by plugging one end of a Grove Cable into the Seeeduino v3 board, and the other into socket J1 of the I2C hub. If you need more than three I2C devices, you can purchase additional I2C hubs. As an example, J1 of I2C hub 1 connects to the Seeeduino, J2 and J3 attach to I2C devices, and J4 connects to the next hub.
For more complicated projects involving additional analog or digital devices, the basic Seeeduino may not be enough, and in that case, you can use a Grove Shield. The Grove Shield stacks on top of your Seeeduino or Arduino-compatible board, and exposed many of the analog and digital pins, as well as the I2C bus. In this configuration, the Grove Shield allows up to four I2C devices to be plugged directly into the Shield. If your project involves more I2C devices, you could use Grove Cables and I2C hubs for additional sockets.
In summary, when building projects with I2C devices:
- Keep the distance between the farthest I2C devices to no more than a few meters
- Try to keep the wire lengths between devices and between a hub and a device as short as feasible
- Consider how your devices are using the power from the I2C bus
- Consider how much current your power supply or batteries can provide
I hope this is helpful.
I’ll think about the rest of your questions and see if I can answer them later.
Thanks. I read your post several times. It helps a lot. Thanks for your time for writing this guideline.
More illustrations for my project:
Several Grove I2C motor shields will be use to control:
- one 12VDC pump
- two computer cooling fans
- two solenoid valves
- two LED strip
- two 9g Mini Servo
The distances of all the wires between devices and shield will be within 70cm.
Each I2C motor shield will be powered by a wall power adapter (12VDC 3A).
Now I need to specific the “address” of each device in the code in order to control them individually.
Setting the address of the I2C motor driver requires changes in both hardware and software. I don’t have a board here to act as a reference, but from reading the specs and wiki pages for the board, it looks like there is a small DIP switch on theboard that is used to set the lower for bits of the board’s address on the I2C Bus. The design forces the upper for bits to be all zeroes. Each board on the same I2C bus needs a unique address, so you must choose a different switch setting on each of the boards you use for your project. The range of the addresses would be from 0x00 through 0x0f. Setting a switch position to ON sets the equivalent address bit to 1. Setting a switch position to OFF sets the corresponding address bit to 0. For example, to set the board’s address to 0x09, set the switch positions to ON OFF OFF ON. Address 0x03 would be OFF OFF ON ON.
Once you’ve set unique addresses for each of the I2C motor drivers, you would use those addresses when using the motor driver library to set the speed and direction of the motors or servos.
It may be helpful to review the sample code and function definitions on this page: seeedstudio.com/wiki/Grove_- … river_V1.3
The I2C address in the sample is set in the definition of I2CMotorDriverAdd. In the sample code the I2C address is set to 0x0f. To make the sample code work with, the motor driver’s address would have to be set to all ON switches.
In order to extend the sample code and use multiple motor drivers in the same sketch, significant changes would have to be made to the sample code I reviewed from seeedstudio.com/wiki/images/ … odeV13.zip
The sample code there assumes a single motor driver. Everywhere there is a reference to the defined constant I2CMotorDriverAdd would have to be replaced with a variable, and probably every function would need a new parameter.
I don’t have any of these motor drivers to test this with, but I’m fairly certain based on my reasons of various resources. I hope this helps.