Manual Mercury V1
Descubra como voar rapidamente com facilidade, conecte seu altímetro para fazer upload para o site Altimeter Cloud e todas as funcionalidades avançadas também. Se você está com dificuldades ou apenas começando, este é o lugar certo para estar.

Exemplo de código: Iniciando comunicação I2C

PDF

Os pinos I2C estão conectados ao IMU, sensor de pressão e portas de expansão.
SDA está no pino 21 e o pino SCL 22. Estes são definidos no arquivo Mercury_pins.h para que você possa apenas usar o nome SDA e SCL.
Wire.begin(SDA, SCL);

O código abaixo ativa a alimentação do sensor, inicia o I2C e verifica dispositivos disponíveis a cada 10 segundos.
Conecte um monitor serial após reiniciar o Mercury uma vez compilado e carregado para visualizar a saída. 

Usando Arduino IDE? Nosso programador online inclui Mercury_Pins.h por padrão, portanto os nomes dos pinos funcionam sem problemas. Se você estiver usando Arduino IDE ou outro programador, copie o conteúdo da aba Mercury_Pins.h e cole-o no topo do seu programa.
/*
 * Mercury I2C Scanner
 * Verifica o barramento I2C e relata todos os dispositivos conectados.
 * Útil para verificar endereços de sensores após montagem.
 */

#include "Wire.h"
#include "Mercury_Pins.h"

void setup() {
    Serial.begin(115200);
    delay(1000);

    Serial.println("Mercury I2C Scanner");
    Serial.println("====================");

    // Ligam o trilho de sensor
    pinMode(VACC, OUTPUT);
    digitalWrite(VACC, HIGH);
    delay(100);  // Permitir que os sensores se estabilizem

    // Iniciar I2C nos pinos 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