New firmware/esp32p4-sensor-node/ ESP-IDF (C, FreeRTOS) project skeleton per docs/superpowers/specs/2026-07-23-esp32-sensor-node-design.md's Workstream I: - Wi-Fi station-mode connect with exponential-backoff reconnect (wifi_manager.c), credentials from a gitignored main/device_config.h the seeker fills in (template: device_config.h.example). - Telemetry HTTP client (telemetry_client.c) POSTing the spec's exact contract shape to /api/device/telemetry with a Bearer token, via esp_http_client + cJSON. - BME280 I2C driver (bme280.c) with Bosch's public double-precision compensation formulas, using ESP-IDF's newer driver/i2c_master.h API. - LD2410 mmWave presence driver (ld2410.c) over UART, chosen over a plain PIR for its distance/motion data richness — its frame-offset parsing is flagged as the least-certain code in the firmware. - sensor_driver_t registry (sensor_driver.h, sensor_registry.c) so new sensors are a new driver file + one array line, no main-loop changes. - README.md: build steps, manual-config walkthrough, wiring/pinouts, and an explicit "what's verified vs. not" section plus a real hardware caveat (ESP32-P4 has no integrated Wi-Fi radio). UNVERIFIED AGAINST REAL HARDWARE per the spec's honesty-policy note — no ESP-IDF toolchain or physical boards available in this environment. Syntax-checked with gcc against hand-written ESP-IDF API stubs (not committed) as a best-effort substitute for a real idf.py build. Workstream J (RTL-SDR experimental module) is explicitly out of scope here; firmware/esp32p4-sensor-node/components/ is left in place for it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
58 lines
1.8 KiB
C
58 lines
1.8 KiB
C
// Bosch BME280 driver (temperature / humidity / pressure) over I2C.
|
|
//
|
|
// Implements the sensor_driver_t interface (see sensor_driver.h) so the
|
|
// registry can init/read it generically. Register map and compensation
|
|
// formulas are transcribed from Bosch's public BME280 datasheet (Rev 1.23,
|
|
// section 4.2.3 "Compensation formulas", double-precision reference
|
|
// implementation) — publicly documented, well-trodden territory, not
|
|
// guesswork. What IS unverified: this has never talked to a real BME280 —
|
|
// see README.md's honesty-policy section.
|
|
//
|
|
// Default wiring (override via `idf.py menuconfig` or by editing the pin
|
|
// macros below before building) — see README.md's wiring section for the
|
|
// full pinout table:
|
|
// BME280 SDA -> GPIO8 (BME280_I2C_SDA_GPIO)
|
|
// BME280 SCL -> GPIO9 (BME280_I2C_SCL_GPIO)
|
|
// BME280 VCC -> 3V3, GND -> GND
|
|
// BME280 CSB -> VCC (selects I2C mode, not SPI)
|
|
// BME280 SDO -> GND selects address 0x76 (default assumed here); tie SDO
|
|
// to VCC instead for address 0x77 and change
|
|
// BME280_I2C_ADDR accordingly.
|
|
|
|
#pragma once
|
|
|
|
#include "esp_err.h"
|
|
#include "sensor_driver.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifndef BME280_I2C_PORT
|
|
#define BME280_I2C_PORT 0
|
|
#endif
|
|
|
|
#ifndef BME280_I2C_SDA_GPIO
|
|
#define BME280_I2C_SDA_GPIO 8
|
|
#endif
|
|
|
|
#ifndef BME280_I2C_SCL_GPIO
|
|
#define BME280_I2C_SCL_GPIO 9
|
|
#endif
|
|
|
|
#ifndef BME280_I2C_ADDR
|
|
#define BME280_I2C_ADDR 0x76 // 0x77 if SDO is tied to VCC instead of GND
|
|
#endif
|
|
|
|
#ifndef BME280_I2C_CLK_HZ
|
|
#define BME280_I2C_CLK_HZ 100000 // 100kHz standard mode; BME280 supports up to 3.4MHz
|
|
#endif
|
|
|
|
// sensor_driver_t-compatible entry points.
|
|
esp_err_t bme280_init(void);
|
|
esp_err_t bme280_read(sensor_reading_t *out, size_t max_out, size_t *out_count);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|