This experiment demonstrates how to use the Bus Pirate to scan for I2C devices and communicate with them.
The I2C (Inter-Integrated Circuit) protocol allows for simple, two-wire communication between a controller and one or more devices. The Bus Pirate can act as the controller to scan for devices and communicate with them directly over I2C.
Wire the I2C device to the Bus Pirate as follows:
Open your terminal software, set the baud rate to 115200, and connect to the Bus Pirate’s serial port.
After connecting to the Bus Pirate, set it to I2C mode:
m 4
Activate power and pull-up resistors:
P (Turn on power supplies)
p (Enable pull-up resistors)
Now the Bus Pirate is ready to scan for and communicate with I2C devices.
To identify devices on the I2C bus, use the Bus Pirate’s scanning command:
(1)
This command will scan the bus and display any detected device addresses, helping you confirm that your I2C device is connected and responsive.
Once you've identified the address, use the following syntax to send and receive data. Replace 0x50
with your device's actual address.
0xAB
to register 0x01
:
[0x50 0x01 0xAB]
0x01
:
[0x50 0x01 [ 0x51 r]
In this command, [
starts reading mode, r
reads one byte, and ]
closes communication.
Refer to your device’s datasheet to understand which registers to access.
Some I2C devices may require additional steps or configurations. The Bus Pirate supports various commands, such as:
(2)
- Read raw ADC(3)
- Continuous ADC(4)
- Sniff traffic on the I2C busExperiment with these commands for further insight into I2C communication.
This experiment provides the basics of using the Bus Pirate for I2C communication. From scanning devices to reading and writing data, the Bus Pirate offers extensive functionality for working with I2C components.