For a lot of projects you need a lot of I/O ports. The GrovePi has 15 I/O ports but even those may be less for some of the projects. The big advantage with the GrovePi is that you can use multiple GrovePi’s together with a small change in the firmware and software.
We are releasing a script which should let you use multiple GrovePi’s, as many as 5 currently but you can use a lot more.
The GrovePi uses I2C to communicate with the Raspberry Pi. The good thing about I2C is that it uses different addresses to differentiate between devices. So to use multiple GrovePi’s together, we are going to burn each GrovePi with a different firmware and use a library that works with that firmware.
Here are the steps to use multiple GrovePi’s with the Pi:
- The first thing to do to use multiple GrovePi’s is to install the firmware and software individually on each of them.Slide the first GrovePi on the Raspberry Pi and power it on.
- Update the GrovePi repository and goto multi_grovepi_installer folder:
cd Desktop/GrovePi/Script/multi_grovepi_installer/
- Make the install script executable:
sudo chmod +x multi_installer.sh
- Run the script:
sudo ./multi_installer.sh
- You will see the menu as above. Select an address at which the GrovePi will be programmed. The default address that GrovePi’s come with is 0x04 so you can choose any of the other address.
- The installer will burn the firmware and also update the library
- If you can see the GrovePi being detected on the address that you have selected, then the process is completed. Make a not of the address on the GrovePi so that you do not forget which address if for which GrovePi.
- Once you are done updating the software and firmware on each GrovePi individually. Stack them together and run:
sudo i2cdetect -y 1
- The installer also installed a library which should work for each individual GrovePi. So for the GrovePi on address 0x03, you would have a library called grovepi3.
- Now you can simply use the libraries to use all the GrovePi’s together. Here is an example to get you started:import time
import time import grovepi #GrovePi with address 4 import grovepi3 #GrovePi with address 3 led = 4 grovepi.pinMode(led,"OUTPUT") grovepi3.pinMode(led,"OUTPUT") while True: grovepi.digitalWrite(led,1) # Send HIGH to switch on LED on the GrovePi with addr 4 grovepi3.digitalWrite(led,1) # Send HIGH to switch on LED on the GrovePi with addr 3 time.sleep(1) grovepi.digitalWrite(led,0) # Send LOW to switch off LED on the GrovePi with addr 4 grovepi3.digitalWrite(led,0) # Send LOW to switch off LED on the GrovePi with addr 3 time.sleep(1)
- Similarly, you can modify the other scripts to make them work
Have a question or a suggestion? Post it on the forums and we’ll help you out.