Scans for I2C devices and performs read/write operations based on commands from the Serial Monitor.
- ⚪ White: A4 - SDA
- 🟡 Yellow: A5 - SCL
- ⚫ Black: GND
scan- checks for connected devices.connect- checks if a device is available at the specified address. If it is, the address is saved and used for further data exchange.write byte- sends one byte to a device.read bytes- requests a specified number of bytes from the device.
- Open Serial Monitor:
===============================================
I2C Tester
- scan
- connect
- write byte
- read bytes
===============================================
Input command:
- Enter
scan:
Input command: `scan`
Scanning...
I2C device found at address: 0x55
Done.
- Enter
connect:
Input command: `connect`
Input address, or press Enter (leave empty) to exit:
- Enter
0x55:
Input command: `connect`
Input address, or press Enter (leave empty) to exit: 0x55
Connecting to: 0x55
Connection successful.
Executing the connect command is optional - if no address has been saved, the program will automatically prompt you to enter one before any read or write operation.
- Enter
write byte - Enter
0x08- for example, the Voltage() command of the BQ28Z610 Gas Gauge Device:
Input command: `write byte`
Input byte value to write, or press Enter (leave empty) to exit: 0x08
Writing byte 0x08 to 0x55
ok
- Enter
read bytes:
Input command: `read bytes`
Input number of bytes to read, press Enter (leave empty) for 1:
- Enter
2to read a word:
Input command: `read bytes`
Input number of bytes to read, press Enter (leave empty) for 1: 2
Reading 2 byte(s) from 0x55:
[ C9 1A ]
Actual read: 2
[ C9 1A ]= 0x1AC9 (Little Endian) = 6857 (mV)
As an example, here is the sequence for reading the Chemical ID of the BQ28Z610 device:
write byte0x3eor0x00
Input command: `write byte`
Input byte value to write, or press Enter (leave empty) to exit: 0x00
Writing byte 0x00 to 0x55
ok
write byte0x06
Input command: `write byte`
Input byte value to write, or press Enter (leave empty) to exit: 0x06
Writing byte 0x06 to 0x55
ok
write byte0x00
Input command: `write byte`
Input byte value to write, or press Enter (leave empty) to exit: 0x00
Writing byte 0x00 to 0x55
ok
write byte0x3e
Input command: `write byte`
Input byte value to write, or press Enter (leave empty) to exit: 0x3e
Writing byte 0x3e to 0x55
ok
read bytes36
Input command: `read bytes`
Input number of bytes to read, press Enter (leave empty) for 1: 36
Reading 36 byte(s) from 0x55:
[ 06 00 52 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 94 06 ]
Actual read: 36
Where:
06 00- Input Command 0x0006 (for verification)52 13= ChemID 1352- last two bytes
94 06:- 0x94 - checksum: 0x94 = 0xFF - (0x06 + 0x00 + 0x52 + 0x13)
- 0x06 - length: two bytes for command, two bytes for result, two bytes for checksum and length
- i2c_tester.ino - main Arduino sketch
- utils.h - util functions header
- utils.cpp - util function implementation
- Custom Driver for Gas Gauging Device BQ28Z610 - A driver for Arduino that provides functions to interface with the BQ28Z610 battery gas gauge device over I2C protocol.
- JBL XTREME 2 BMS - Arduino sketches to analyse and emulate BMS microchip of the Battery Pack for the JBL XTREME 2 Bluetooth Speaker.