Dev #26

Open
overseer wants to merge 65 commits from dev into main
2 changed files with 49 additions and 33 deletions
Showing only changes of commit 2fb73ec8c4 - Show all commits
+25 -16
View File
@@ -9,16 +9,16 @@
; (TX/RX) (RX16/TX17)
;
; Build:
; pio run -e esp8266-camera (ESP8266 D1 Mini — camera bridge)
; pio run -e esp32-mqtt (ESP32 Dev Board — MQTT bridge)
; pio run -e esp8266-camera (ESP8266 — GoPro camera bridge)
; pio run -e seeed_xiao_esp32c6 (XIAO ESP32-C6 — MQTT bridge)
;
; Upload:
; pio run -e esp8266-camera --target upload
; pio run -e esp32-mqtt --target upload
; pio run -e seeed_xiao_esp32c6 --target upload
;
; Filesystem:
; pio run -e esp8266-camera --target uploadfs
; pio run -e esp32-mqtt --target uploadfs
; pio run -e seeed_xiao_esp32c6 --target uploadfs
[common]
lib_deps =
@@ -43,25 +43,34 @@ build_flags = ${common.build_flags}
board_build.flash_mode = dio
board_build.f_cpu = 160000000L
build_src_filter =
+<../lib/>
+<esp8266-camera-bridge.cpp>
-<*.cpp>
+<esp8266-camera-bridge.cpp>
+<../lib/>
; ── ESP32: MQTT Bridge ─────────────────────────────────────
; Flashed onto ESP32 Dev Board. Connects to travel router,
; publishes MQTT to Pi hub. Reads camera status from ESP8266
; over UART2 (RX16/TX17). No direct camera communication.
; ── XIAO ESP32-C6: MQTT Bridge ─────────────────────────────
; Flashed onto a Seeed Studio XIAO ESP32-C6. Connects to the
; travel router, publishes MQTT to the Pi hub. Reads camera
; status from the ESP-01S over UART (Serial1: RX=D7, TX=D6).
; No direct camera communication.
;
; ESP32-C6 requires the pioarduino fork of platform-espressif32
; (mainline espressif32 lagged on the Arduino-core 3.x the C6
; needs). USB-CDC-on-boot is required for Serial over native USB.
;
; Upload fallback if it can't connect: hold B (BOOT), tap
; R (RESET), release B, then re-run upload.
[env:esp32-mqtt]
platform = espressif32
board = esp32dev
[env:seeed_xiao_esp32c6]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
board = seeed_xiao_esp32c6
framework = arduino
monitor_speed = 115200
upload_speed = 921600
lib_deps = ${common.lib_deps}
build_flags = ${common.build_flags}
-D CONFIG_ARDUINO_LOOP_STACK_SIZE=8192
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1
build_src_filter =
+<../lib/>
+<esp32-mqtt-bridge.cpp>
-<*.cpp>
+<esp32-mqtt-bridge.cpp>
+<../lib/>
+24 -17
View File
@@ -19,10 +19,10 @@
* ESP32 → ESP8266: {"type":"cmd","command":"ping"}\n
*
* Hardware:
* - ESP32 Dev Board (or D1 Mini ESP32)
* - UART2: RX=GPIO16, TX=GPIO17 (connected to ESP8266)
* - Seeed Studio XIAO ESP32-C6
* - Serial1: RX=D7, TX=D6 (crossed to the ESP-01S TX/RX)
* - Shared GND between boards
* - LiPo → 3.3V buck → VIN on both boards
* - 5V rail → XIAO 5V/VIN; ESP-01S on its own 3.3V buck
*/
#include <Arduino.h>
@@ -80,13 +80,19 @@ bool saveConfig() {
}
// ────────────────────────────────────────────
// UART to ESP8266 (HardwareSerial2)
// UART to ESP-01S (HardwareSerial1)
// ────────────────────────────────────────────
// ESP32 UART2: RX=GPIO16, TX=GPIO17
// Connect: ESP32 RX(16) ← ESP8266 TX
// ESP32 TX(17) → ESP8266 RX
// XIAO ESP32-C6 Serial1: RX=D7, TX=D6 (Serial = native USB CDC)
// Connect: XIAO RX(D7) ← ESP-01S TX
// XIAO TX(D6) → ESP-01S RX
#define UART_ESP8266 Serial2
#define UART_ESP8266 Serial1
#define UART_RX_PIN D7
#define UART_TX_PIN D6
// Camera-online indicator → green channel of the RGB STAT LED.
// (Full RGB/OLED status-panel bring-up is not implemented yet.)
#define STAT_LED_PIN D1
void sendCmdToESP8266(const String& command) {
JsonDocument doc;
@@ -187,7 +193,8 @@ bool connectMQTT() {
JsonArray caps = doc["capabilities"].to<JsonArray>();
caps.add("start_stop"); caps.add("status");
String payload; serializeJson(doc, payload);
mqtt.publish("remoterig/cameras/announce-" + clientID(), payload.c_str(), true);
String announceTopic = "remoterig/cameras/announce-" + clientID();
mqtt.publish(announceTopic.c_str(), payload.c_str(), true);
Serial.println("[MQTT] Announced for registration");
}
@@ -204,14 +211,14 @@ void setup() {
Serial.println("\n[BRIDGE] ESP32 MQTT Bridge v1.0");
bootMs = millis();
pinMode(2, OUTPUT); // built-in LED
digitalWrite(2, LOW);
pinMode(STAT_LED_PIN, OUTPUT); // RGB STAT LED — green = camera online
digitalWrite(STAT_LED_PIN, LOW);
loadConfig();
// UART to ESP8266
UART_ESP8266.begin(115200, SERIAL_8N1, 16, 17); // RX=16, TX=17
Serial.println("[UART] ESP8266 link on RX16/TX17 @ 115200");
// UART to ESP-01S
UART_ESP8266.begin(115200, SERIAL_8N1, UART_RX_PIN, UART_TX_PIN);
Serial.println("[UART] ESP-01S link on Serial1 (RX=D7, TX=D6) @ 115200");
// Connect to travel router — the ONLY network we touch
Serial.printf("[WIFI] Connecting to: %s\n", cfg.wifi_ssid.c_str());
@@ -278,7 +285,7 @@ void loop() {
if (online != cameraOnline) {
cameraOnline = online;
digitalWrite(2, online ? HIGH : LOW);
digitalWrite(STAT_LED_PIN, online ? HIGH : LOW);
}
if (cfg.camera_id.length() > 0) {
@@ -297,13 +304,13 @@ void loop() {
}
}
else if (type == "ack") {
Serial.printf("[UART] ESP8266 ack: %s\n", (doc["cmd"] | "?").c_str());
Serial.printf("[UART] ESP8266 ack: %s\n", doc["cmd"] | "?");
}
else if (type == "pong") {
Serial.printf("[UART] ESP8266 pong (uptime=%d)\n", doc["uptime_ms"] | 0);
}
else if (type == "error") {
Serial.printf("[UART] ESP8266 error: %s\n", (doc["msg"] | "?").c_str());
Serial.printf("[UART] ESP8266 error: %s\n", doc["msg"] | "?");
}
}