Change I2C Device Address with PiStorms
Many times you may realize that four sensor ports are just not enough for your project. Because the majority of mindsensors.com devices are I2C, you can put lots of sensors and multiplexors on the same sensor port. However, you may find that some of the sensors use the same I2C address (especially if it is the same type of device). This will cause data collisions and make the information unusable in most cases. To avoid this issue, change the I2C addresses of your devices so that each device has its own unique address. This process can be performed directly fro the PiStorms touchscreen.
Change the Address
Ensure your PiStorms frame is assembled and your PiStorms is properly connected to the PiStorms with the instructions here.
Turn on your PiStorms by clicking the 'GO' button. After a minute or two the Raspberry Pi will boot up and the PiStorms Browser will appear on the screen.
Click the right arrow button on the top right-hand corner of the screenand browse to find the program '09-Change_i2c_addr' (this program is located in '45-Utils' folder)
Click the '09-Change_i2c_addr' button and the program will automatically run.
Follow the instructions on the PiStorms screen to locate the I2C device connected to BAS1 at its current address.
If an I2C device is found, the screen will refresh with new instructions, display the current address, and show the desired address.
If the program does NOT detect that an I2C device is connected to BAS1, 'No Device Found!' will appear on the screen and you will be prompted to exit the program.
Once the device is found, use the left and right arrow buttons in the top corners of the PiStorms touchscreen to choose the new address of the I2C device. Notice the hexadecimal value under 'New Address' will change by increments of two arrow button presses.
After you have chosen the desired address for the I2C device, click the 'Change' button. The program will then execute the change and exit to the main menu. Verify the address has successfully changed with the '09-Explorer' program. Instructions for use of the '09-Explorer' program can be found here.
How can I connect multiple I2C devices on the same port?
mindsensors.com offers a simple solution, the Split-Nx. This device is a port splitter that will allow you to connect up to three I2C devices on a single port. You can also daisy chain multiple Split-Nx devices to add even more sensors. Be sure to check the power consumption of the sensors. If the sensors are consuming more power than the PiStorms can give to that port, you may experience strange behavior.
Why do the I2C devices need seperate addresses to function properly?
The I2C addresses allow the master device to know which data belongs to which slave device. Think of the I2C address as a mailing address. If you and your neighbors all had the same address, the mail carrier would have a hard time figuring out which mail belongs to you. You will receive your neighbors male and they will get your mail. This will cause lots of confusion on your street.
Why is the Explorer program not detecting my device?
There could be many reasons why the program is not detecting your device.
First, make sure your sensor is connected to the correct port (BAS1). The program only enables BAS1 for I2C communication and will read only that port.
Second, make sure the device uses I2C communication. Be sure to check the documentation of the device to make sure it is not analog, UART, CAN, etc. Most LEGO brand devices, Sumoeyes, and many third party devices will not show on the 'Explorer'.
The device may be faulty. If you are using a mindsensors.com I2C device on port BAS1 and you still can not detect anything, please contact firstname.lastname@example.org.
All of the I2C devices are not detected on BAS1 when I use the Split-Nx!
This is normal, the 'Explorer' will only show the first address it detects (usually the lowest numbered address). Disconnect the Split-Nx and attach only one I2C device at a time.
Why does the 'New Address' change by increments of two?
Each I2C device actually has two I2C addresses. One for incoming data and one for outgoing data. So when you choose the I2C address it simply skips the other address. This fact is apparent in 8-bit address format but in the 7-bit format is just understood.