Skip to content

feat: initialize ESP32 project with PlatformIO (#1)#6

Open
addidea wants to merge 1 commit intoClawland-AI:mainfrom
addidea:feat/platformio-init
Open

feat: initialize ESP32 project with PlatformIO (#1)#6
addidea wants to merge 1 commit intoClawland-AI:mainfrom
addidea:feat/platformio-init

Conversation

@addidea
Copy link

@addidea addidea commented Feb 16, 2026

Description

Complete ESP32 project initialization with PlatformIO, WiFi, and MQTT stack.

Closes #1

What's Included

Core Firmware (src/main.cpp)

  • WiFi connectivity with auto-reconnect logic
  • MQTT client for upstream reporting to PicClaw/NanoClaw
  • Status publishing (uptime, free heap, WiFi RSSI)
  • Sensor data publishing (placeholder for DHT22/BME280)
  • Command subscription (remote status/restart)
  • Production-ready error handling

Project Structure

  • platformio.ini: ESP32 board config + dependencies (PubSubClient, DHT, Adafruit Unified Sensor)
  • lib/README.md: Custom sensor driver directory with usage guide
  • .gitignore: Build artifacts, IDE files, environment secrets

Documentation (README.md)

Key Features

  • Memory efficient: Runs on ESP32-C3 (400KB RAM, hardware)
  • Configurable: WiFi/MQTT via constants (no recompile for testing)
  • Production-ready: Auto-reconnect, keepalive, command handling
  • MQTT topics:
    • microclaw/status → Agent health metrics
    • microclaw/sensors → Sensor data stream
    • microclaw/commands → Remote control

Testing

  1. Edit src/main.cpp with your WiFi/MQTT credentials
  2. pio run --target upload
  3. pio device monitor → See connection logs
  4. MQTT broker should receive status messages every 30s

Next Steps

Ready for review! 🐾


Note

Medium Risk
Introduces new WiFi/MQTT connection, periodic publishing, and remote command handling in the main firmware loop; connectivity/loop timing issues could affect device stability but changes are contained to startup/telemetry code.

Overview
Bootstraps the ESP32 firmware in src/main.cpp with WiFi setup and an MQTT client: connects/subscribes on startup, auto-reconnects in loop(), publishes periodic placeholder sensor payloads, and emits a JSON status message (uptime/heap/RSSI). It also adds basic command handling over microclaw/commands (request status and restart).

Improves project onboarding by expanding README.md with PlatformIO install/flash instructions (IDE/CLI/manual), troubleshooting, and project structure, adds lib/README.md describing how to add custom sensor drivers, and broadens .gitignore to exclude build artifacts, IDE/OS files, logs, and secret env/header files.

Written by Cursor Bugbot for commit d1ac3bc. This will update automatically on new commits. Configure here.

Closes Clawland-AI#1

Complete PlatformIO project setup includes:

**Core Firmware (src/main.cpp)**:
- WiFi connectivity with auto-reconnect
- MQTT client for upstream reporting
- Status and sensor data publishing
- Command subscription (status, restart)
- Heartbeat and keepalive logic
- Serial logging with emojis for readability

**Project Structure**:
- platformio.ini: ESP32 board config + dependencies
- lib/: Custom sensor driver directory with usage guide
- .gitignore: Build artifacts, IDE files, secrets

**Documentation (README.md)**:
- 3 flashing methods: PlatformIO IDE, CLI, esptool.py
- Step-by-step installation guide
- Troubleshooting section (USB detection, WiFi, MQTT)
- Project structure overview
- Next steps linking to other issues

**Features**:
- Production-ready WiFi/MQTT stack
- Configurable via constants (SSID, broker, topics)
- MQTT topics: status, sensors, commands
- Memory-efficient (runs on ESP32-C3 with 400KB RAM)

Ready to flash and test on hardware! 🚀
@addidea addidea requested a review from Tonyfudecai as a code owner February 16, 2026 07:38
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on March 16

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

}
} else {
mqttClient.loop();
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No WiFi reconnection logic in main loop

High Severity

The loop() only handles MQTT reconnection but never checks or recovers WiFi connectivity. setupWiFi() is called once in setup() and WiFi.setAutoReconnect(true) is never called. ESP32 does not auto-reconnect WiFi by default, so if WiFi drops, the device permanently loses network connectivity. The MQTT reconnect branch will repeatedly call connectMQTT() — which blocks for up to 15 seconds per attempt via PubSubClient's socket timeout — making the device unresponsive with no path to recovery.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: initialize ESP32 project with PlatformIO

1 participant

Comments