Los pines I2C están conectados al IMU, sensor de presión y puertos de expansión.
SDA está en el pin 21 y el pin SCL en el 22. Estos están definidos en el archivo Mercury_pins.h para que puedas usar simplemente el nombre SDA y SCL.Wire.begin(SDA, SCL);
El código a continuación habilita la energía del sensor, inicia I2C y escanea los dispositivos disponibles cada 10 segundos.
Conecta un monitor serial después de reiniciar el Mercury una vez compilado y cargado para ver el resultado.
¿Usas Arduino IDE? Nuestro programador en línea incluye Mercury_Pins.h por defecto para que los nombres de los pines funcionen sin problemas. Si utilizas Arduino IDE u otro programador, copia el contenido de la pestaña Mercury_Pins.h y pégalo en la parte superior de tu programa.
/* * Mercury I2C Scanner * Escanea el bus I2C e informa de todos los dispositivos conectados. * Útil para verificar direcciones de sensores después del ensamblaje. */ #include "Wire.h" #include "Mercury_Pins.h" void setup() { Serial.begin(115200); delay(1000); Serial.println("Mercury I2C Scanner"); Serial.println("===================="); // Enciende el carril del sensor pinMode(VACC, OUTPUT); digitalWrite(VACC, HIGH); delay(100); // Permite que los sensores se estabilicen // Inicia I2C en los pines Mercury Wire.begin(SDA, SCL); Serial.println("Sensor power: ON"); Serial.println("I2C bus ready (SDA=" + String(SDA) + " SCL=" + String(SCL) + ")"); Serial.println(); } void loop() { int found = 0; Serial.println("Scanning I2C bus..."); for (int row = 0; row < 128; row += 16) { // Row label for (int col = 0; col < 16; col++) { int addr = row + col; // Skip reserved addresses (0x00-0x07 and 0x78-0x7F) if (addr < 0x08 || addr > 0x77) { continue; } Wire.beginTransmission(addr); int result = Wire.endTransmission(); if (result == 0) { found++; } else { } } } Serial.println(); if (found == 0) { Serial.println("No devices found. Check wiring and sensor power."); } else { Serial.println(String(found) + " device(s) found:"); // Second pass to list found devices with common names for (int addr = 0x08; addr <= 0x77; addr++) { Wire.beginTransmission(addr); if (Wire.endTransmission() == 0) { Serial.printf(" 0x%02X", addr); // Identify common sensors switch (addr) { case 0x47: Serial.print(" - BMP581 (Mercury Pressure)"); break; case 0x6B: Serial.print(" - LSM6DSO32 (Mercury IMU)"); break; case 0x77: Serial.print(" - BMP390 (Mercury Pressure)"); break; } Serial.println(); } } } Serial.println(); Serial.println("Next scan in 10 seconds..."); Serial.println("---"); delay(10000); }#pragma once /* * Mercury (ESP32-C6) Pin Definitions * Board-specific GPIO assignments */ // ââ Status LED (NeoPixel) ââ #define LEDPOWER 3 // NeoPixel power (drive HIGH to enable) #define LED 2 // NeoPixel data signal // ââ I2C Bus ââ #define SDA 21 // I2C data #define SCL 22 // I2C clock // ââ Sensor Power ââ #define VACC 20 // Sensor power rail (drive HIGH to enable) // ââ General Purpose Ports ââ #define GP06 6 // GP06 port #define GP07 7 // GP07 port // ââ High Current Output ââ #define OUT1 5 // High current output (e.g. pyro / relay) // ââ Battery Bar LEDs ââ #define BL1 4 // Battery LED 1 (lowest) #define BL2 14 // Battery LED 2 #define BL3 15 // Battery LED 3 #define BL4 18 // Battery LED 4 #define BL5 19 // Battery LED 5 (highest) // ââ Indicators ââ #define DISK 8 // Disk activity LED // ââ Analogue / Detection ââ #define BATIN 0 // Battery voltage (1:1 divider) #define USBDETECT 1 // USB power detect (HIGH = USB present) #define BUTTON 9 // BUTTON on the board, boot button but can be used