ESP32-C3 Multi-Board Design
GPIO4 -> I2C SDAGPIO5 -> I2C SCLGPIO1 -> TMP117 ALERTGPIO0 -> LIS2DW12 INT1GPIO6 -> Charger status inputGPIO9 -> BOOT strapTXD0 / RXD0 -> pogo UART programming/debugCpp
#include <WiFi.h> #include <esp_now.h> #include <Wire.h> #include <Adafruit_TMP117.h> #include <SparkFun_LIS2DW12.h> static const int PIN_I2C_SDA = 4; static const int PIN_I2C_SCL = 5; static const int PIN_TMP_ALERT = 1; static const int PIN_ACCEL_INT = 0; static const int PIN_CHG_STAT = 6; Adafruit_TMP117 tmp117; LIS2DW12 accel; uint8_t peerAddress[] = {0x24, 0x6F, 0x28, 0x00, 0x00, 0x00}; // TODO: replace struct Payload { float temperature_c; float ax_g; float ay_g; float az_g; uint8_t charging_active; }; void onDataSent(const wifi_tx_info_t *info, esp_now_send_status_t status) { (void)info; Serial.print("ESP-NOW send status: "); Serial.println(status == ESP_NOW_SEND_SUCCESS ? "OK" : "FAIL"); } void setupEspNow() { WiFi.mode(WIFI_STA); if (esp_now_init() != ESP_OK) { Serial.println("ESP-NOW init failed"); return; } esp_now_register_send_cb(onDataSent); esp_now_peer_info_t peerInfo = {}; memcpy(peerInfo.peer_addr, peerAddress, 6); peerInfo.channel = 0; peerInfo.encrypt = false; if (!esp_now_is_peer_exist(peerAddress)) { if (esp_now_add_peer(&peerInfo) != ESP_OK) { Serial.println("Failed to add ESP-NOW peer"); } } } void setupSensors() { Wire.begin(PIN_I2C_SDA, PIN_I2C_SCL); if (!tmp117.begin()) { Serial.println("TMP117 not found"); } if (!accel.begin()) { Serial.println("LIS2DW12 not found"); } else { accel.setMode(LIS2DW12_MODE_LOW_POWER); accel.setDataRate(LIS2DW12_ODR_50HZ); accel.setRange(LIS2DW12_RANGE_2G); } pinMode(PIN_TMP_ALERT, INPUT); pinMode(PIN_ACCEL_INT, INPUT); pinMode(PIN_CHG_STAT, INPUT_PULLUP); } void setup() { Serial.begin(115200); delay(200); setupSensors(); setupEspNow(); } void loop() { Payload payload{}; payload.temperature_c = tmp117.readTemperature(); payload.ax_g = accel.x; payload.ay_g = accel.y; payload.az_g = accel.z; payload.charging_active = digitalRead(PIN_CHG_STAT) == LOW ? 1 : 0; esp_now_send(peerAddress, reinterpret_cast<const uint8_t*>(&payload), sizeof(payload)); Serial.print("T="); Serial.print(payload.temperature_c); Serial.print(" C, A="); Serial.print(payload.ax_g); Serial.print(", "); Serial.print(payload.ay_g); Serial.print(", "); Serial.print(payload.az_g); Serial.print(", CHG="); Serial.println(payload.charging_active); delay(1000); }
Target
Pin map from schematic
Arduino-style starter sketch
Bring-up checklist