Scan using M5 Unified for IC2 devices for a M5Dial fails
-
I've an M5 Dial v1.0 (i.e., https://shop.m5stack.com/products/m5stamp-esp32s3-module) with a number of IC2 modules such as:
- Grove Temperature Sensor (https://www.seeedstudio.com/Grove-Temperature-Sensor.html)
- Grove-Wio-E5 Wireless Module - STM32WLE5JC (https://www.seeedstudio.com/Grove-LoRa-E5-STM32WLE5JC-p-4867.html)
- Buzzer v1.3
I can't access the IC2 devices on port A or B using the M5 Unified library. Why? I'm using latest Arduino IDE on Windows 10 Pro, with latest libraries & board files.
Here's the code I'm testing with (partially from the M5 support AI) that runs "fine", but never detects a device connected via a M5 Grove cable to port A (G15 = SCL, G13 = SDA) or B (G1 = SCL, G2 = SDA).
#include <M5Unified.h> // Use M5Dial's external I2C bus (Port A pins 15=SCL, 13=SDA) #define SCAN_BUS m5::Ex_I2C // (Port B uses 21=SCL, 22=SDA per Copilot) - or rather G1 = SCL and G2= SDA per M5Dial documentation) // Port B can be used as an alternative I2C bus // #define SCAN_BUS m5::Ex_I2C_PortB // to scan the M5 Dial's internal ports, use m5::I2C // #define SCAN_BUS m5::I2C void setup() { // Initialize M5Dial with default configuration auto cfg = M5.config(); M5.begin(cfg); // Configure round display for I2C scanner M5.Display.setTextSize(2); M5.Display.setTextColor(TFT_WHITE, TFT_BLACK); // M5.Display.fillScreen(TFT_BLACK); M5.Display.setCursor(20, 60); M5.Display.println("M5Dial I2C Scanner"); M5.Display.drawLine(20, 50, 220, 50, TFT_WHITE); } void loop() { M5.update(); M5.Display.setCursor(20, 80); M5.Display.println("Scanning bus..."); byte address; int nDevices = 0; int yPos = 120; // Scan all valid I2C addresses (0x08 to 0x77) for (address = 1; address < 127; address++) { // Skip reserved addresses 0-7 to prevent bus lockups if (address < 8) continue; // display progress indicator, every 4 addresses if (address % 4 == 0) { M5.Display.setCursor(50, 100); M5.Display.printf("Scanning: %d, 0x%02X", address, address); M5.update(); delay(75); // brief delay to allow display update } // Use M5Unified's built-in scanID method for reliable detection bool deviceFound = SCAN_BUS.scanID(address); if (deviceFound) { M5.Display.setCursor(20, yPos); M5.Display.printf("0x%02X", address); Serial.printf("Device %d is at address 0x%02X\n", nDevices, address); delay(2000); nDevices++; yPos += 25; if (yPos > 210) break; // Stop if we run out of screen space } } // Show scan summary M5.Display.setCursor(20, 180); if (nDevices == 0) { M5.Display.println("No devices found"); Serial.println("No I2C devices found"); } else { M5.Display.printf("%d device(s) found", nDevices); Serial.printf("Successfully found %d I2C devices\n", nDevices); } // Wait for button press to rescan M5.Display.setCursor(20, 200); M5.Display.println("Press BtnA: rescan"); while (!M5.BtnA.wasPressed()) { M5.update(); delay(10); } M5.Display.fillScreen(TFT_BLACK); M5.Display.setCursor(20, 80); M5.Display.println("M5Dial I2C Scanner"); M5.Display.drawLine(20, 50, 220, 50, TFT_WHITE); }I presume M5Dial handles the required pull-up voltage on the pins.
Other things to check? I don't have other M5 devices, but lots of XIAO trinkets...
-
Hello @VashJuan
well, it looks to me that none of the listed devices are actually I2C devices.
- Grove Temp. Sensor: has an analog out pin (the other is NC) which means it directly sends an analog value
- Grove Wireless Mod: has RX and TX which means it has an UART interface
- Buzzer: well, my guess would be that it is not I2C either
Thanks
Felix
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login