mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-10-25 01:42:36 +00:00
1.1 KiB
1.1 KiB
I2C bus scanner
What it does
This example scans the i2c bus in a loop and prints out a table with the addresses of the found i2c devices.
Wiring
Connect SCL and SDA pins to the following pins with appropriate pull-up
resistors.
| Name | Description | Defaults |
|---|---|---|
CONFIG_EXAMPLE_I2C_MASTER_SCL |
GPIO number for SCL |
"5" for esp8266, "6" for esp32c3, "19" for esp32, esp32s2, and esp32s3 |
CONFIG_EXAMPLE_I2C_MASTER_SDA |
GPIO number for SDA |
"4" for esp8266, "5" for esp32c3, "18" for esp32, esp32s2, and esp32s3 |
Example output
Three devices found on a bus: 0x38, 0x60 and 0x77
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- 77