Files
AeroAlign/firmware/slave/src/config.h
T

144 lines
4.4 KiB
C

// SkyLogic AeroAlign - Slave Node Configuration
//
// This file contains all configuration parameters for the Slave node:
// - Master MAC address (for ESP-NOW pairing)
// - GPIO pin assignments
// - ESP-NOW parameters
// - IMU configuration
// - System constants
#ifndef CONFIG_H
#define CONFIG_H
#include <Arduino.h>
// ========================================
// ESP-NOW Configuration
// ========================================
// Master node MAC address
// **IMPORTANT**: Set this to your Master's actual MAC address in config.cpp
// To find Master MAC:
// 1. Flash Master firmware
// 2. Connect Master to USB, open serial monitor (115200 baud)
// 3. Master prints MAC at boot: "Master MAC: 24:6F:28:12:34:56"
// 4. Copy MAC into firmware/slave/src/config.cpp, then reflash Slave
extern uint8_t master_mac[6];
// Slave node ID (unique identifier for this Slave)
// Default: 0x02 (first Slave)
// For multi-sensor systems, use NODE_ID from platformio.ini build flag
// slave1: 0x02, slave2: 0x03, ..., slave8: 0x09
#ifndef NODE_ID
#define NODE_ID 0x02
#endif
// WiFi channel (must match Master's WiFi AP channel)
// See Master config.h for WIFI_CHANNEL value
#define WIFI_CHANNEL 6
// ESP-NOW packet transmission interval (ms)
// 100ms = 10Hz update rate (balances latency and power consumption)
#define ESPNOW_SEND_INTERVAL_MS 100
// ESP-NOW packet size (16 bytes: node_id + device_type + pitch + roll + yaw + battery + checksum)
#define ESPNOW_PACKET_SIZE 16
// ========================================
// GPIO Pin Definitions
// ========================================
#if defined(CONFIG_IDF_TARGET_ESP32S3)
// ESP32-S3 defaults
#define IMU_I2C_SDA 4 // GPIO4 (SDA)
#define IMU_I2C_SCL 5 // GPIO5 (SCL)
#define IMU_I2C_FREQ 100000 // 100kHz for better signal margin on jumper wires
#define BATTERY_ADC_PIN 1 // GPIO1 (ADC1), avoids GPIO0 boot strap
#define BATTERY_MONITOR_ENABLED 1
#define STATUS_LED_PIN -1 // Board-dependent on S3 modules, disabled by default
#define HARDWARE_MODEL "ESP32-S3"
#else
#define IMU_I2C_SDA 4 // GPIO4 (SDA)
#define IMU_I2C_SCL 5 // GPIO5 (SCL)
#define IMU_I2C_FREQ 400000 // 400kHz (fast mode)
#define BATTERY_ADC_PIN 0 // GPIO0 (ADC1_CH0)
#define BATTERY_MONITOR_ENABLED 1
#define STATUS_LED_PIN 10 // GPIO10 (built-in LED on some boards)
#define HARDWARE_MODEL "ESP32-C3"
#endif
// Battery monitoring (ADC)
// Voltage divider: LiPo+ -> 10kΩ -> BATTERY_ADC_PIN -> 10kΩ -> GND
#define BATTERY_VOLTAGE_DIVIDER 2.0 // 10kΩ + 10kΩ = 2:1 ratio
// Power control (optional, for deep sleep)
#define POWER_ENABLE_PIN -1 // Not used (always on)
// ========================================
// IMU Configuration
// ========================================
// IMU sampling rate (Hz)
// 100Hz provides smooth real-time updates while balancing power consumption
#define IMU_SAMPLE_RATE_HZ 100
// IMU I2C address (MPU6050 default: 0x68, BNO055: 0x28)
#define IMU_I2C_ADDRESS 0x68
// Complementary filter coefficient (0.0-1.0)
// Higher value = trust gyro more (responsive but drifts)
// Lower value = trust accel more (stable but noisy)
// Recommended: 0.98 for static measurement
#define COMPLEMENTARY_FILTER_ALPHA 0.98
// IMU calibration samples (average N readings at startup)
#define IMU_CALIBRATION_SAMPLES 100
// ========================================
// System Constants
// ========================================
// Battery voltage thresholds (for LiPo 1S)
#define BATTERY_VOLTAGE_MIN 3.0 // Empty (0%)
#define BATTERY_VOLTAGE_MAX 4.2 // Fully charged (100%)
#define BATTERY_WARNING_PERCENT 20 // Show warning at 20%
// Serial debug baud rate
#define SERIAL_BAUD_RATE 115200
// Firmware version
#define FIRMWARE_VERSION "1.0.0"
// System name
#define SYSTEM_NAME "SkyLogic AeroAlign Slave"
// ========================================
// Debug Configuration
// ========================================
// Enable verbose serial logging (comment out for production)
#define DEBUG_SERIAL_ENABLED
// Enable ESP-NOW packet logging
#define DEBUG_ESPNOW_PACKETS
// Enable IMU debug output
// #define DEBUG_IMU_READINGS
// ========================================
// Power Management
// ========================================
// Deep sleep configuration (optional, for future power optimization)
#define DEEP_SLEEP_ENABLED false
#define DEEP_SLEEP_TIMEOUT_MS 60000 // Sleep after 60 seconds of inactivity
// Low battery threshold (shut down to protect LiPo)
#define LOW_BATTERY_SHUTDOWN_PERCENT 5
#endif // CONFIG_H