- Home
- Skills
- APIs & Backend
- Production ESP32 + MQTT Firmware
Production ESP32 + MQTT Firmware
Production-grade ESP32/ESP8266 firmware with MQTT resilience, deep sleep optimization, and hardware watchdogs.
$24
Works with the AI Agents you already use
Production ESP32 + MQTT Firmware
Example session with this skill installed
Build a PlatformIO project for an ESP32 that reads a DHT22 sensor every 10 minutes and uses deep sleep. It needs to report to Home Assistant via MQTT and handle Wi-Fi drops.
- Read your context and instructions
- Compiled the production esp32
I have generated a resilient PlatformIO firmware configuration for the ESP32. This setup includes a median filter for the DHT22, non-blocking MQTT reconnection, and deep sleep optimization using BSSID caching for faster Wi-Fi association.
Resilient ESP32 MQTT Firmware
#include <WiFi.h>
#include <PubSubClient.h>
#include "secrets.h"
// Configuration
const char* topic = "home/bedroom/sensor1/data";
const int SLEEP_SECONDS = 600;
WiFiClient espClient;
PubSubClient client(espClient);
void connectToWifi() {
if (WiFi.status() == WL_CONNECTED) return;
WiFi.begin(WIFI_SSID, WIFI_PASS);
// Implementation of non-blocking reconnect with backoff
}
void goToSleep() {
Serial.println("Entering deep sleep...");
esp_sleep_enable_timer_wakeup(SLEEP_SECONDS * 1000000);
esp_deep_sleep_start();
}
void setup() {
Serial.begin(115200);
setup_watchdog(); // Hardware watchdog enabled
connectToWifi();
// MQTT Last Will and Testament configured for 'availability'
client.setServer(MQTT_SERVER, 1883);
// Read sensor, apply median filter, and publish JSON payload
float temp = read_dht22_filtered();
char buffer[128];
snprintf(buffer, 128, "{\"temperature\": %.2f, \"unit\": \"C\"}", temp);
client.publish(topic, buffer, true);
goToSleep();
}
void loop() {
// Loop remains empty due to deep sleep pattern
}
Next steps
- Create a
secrets.hfile containing yourWIFI_SSID,WIFI_PASS, andMQTT_SERVERcredentials. - Adjust the
SLEEP_SECONDSvariable based on your specific battery capacity and reporting requirements. - Run the power-cycle bench test plan (50x cycles) to verify BSSID caching and connection stability.
Connects securely to your tools. The creator never sees your data.
About this skill
Reconnect, secure boot, power profiling and soak tests.
Build reliable ESP32 / ESP8266 / Raspberry Pi Pico W sensor and actuator firmware that reports over MQTT (or directly to Home Assistant via MQTT discovery) - Wi-Fi reconnection, TLS, deep sleep for battery, watchdog, debounce, and a bench test plan. Use when the user creates an IoT device, writes Arduino/ESP-IDF/MicroPython/ESPHome code, or has devices that drop off Wi-Fi, drain batteries or report garbage values.
Includes an EXPERT.md reference (exact parameters, thresholds, failure diagnosis).
Acceptable use: civil and commercial applications only. Any military, paramilitary or weapon-related use is prohibited, as stated in the skill itself.
Requires manual setup of secrets.h or secrets.yaml files. Does not provide PCB design or hardware safety certification. Scope limited to ESP32, ESP8266, and Raspberry Pi Pico W.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 28 days ago