Overview
- 10 uA deep sleep current
- USB and external DC battery power inputs (3.3V - 5V)
- battery charging from USB external DC
- TP4056 Li-Ion battery charger
- RT9080 Low Drop out Linear Regulator
- supported by platformio (
board=firebeetle32
)
PINS
- LED : (IO2)
- VBAT : (A0 - 36 - SENSOR_VP) measure ratio = 0.5
- Another caveat is the usage of pin 36 A0 which conflicts with wifi. To avoid that, in the program below, the battery is measured before the wifi is activated.
Gallery
Links
Related products
Applications
Config
{
"mqtt" : {
"host":"10.0.0.42",
"port":1883,
"client_id":"esp_firebeetle_1"
},
"base_topic":"esp/firebeetle_1",
"deep_sleep_sec":10
}
Main
main.cpp
#include "Arduino.h"
#include <WiFi.h>
#include <ArduinoJson.h>
#include "freertos/FreeRTOS.h"
#include <WiFi.h>
#include <MQTT.h>
#include <esp_wifi.h>
#include "json_file.h"
#include "battery.h"
#include "wifi_secret.h"
DynamicJsonDocument config(1*1024);//5 KB
MQTTClient mqtt(1*1024);// 1KB for small messages
WiFiClient wifi;//needed to stay on global scope
void setup() {
Serial.begin(115200);
uint32_t vref = bat_init();
Serial.printf("eFuse Vref:%u mV\n", vref);
float battery_f = bat_get_voltage();
battery_f /=1000;
pinMode(LED_BUILTIN, OUTPUT);
blink(100);
WiFi.begin(ssid, password);
load_config(config,true);
timelog("config loaded");
if(connect()){
mqtt_publish_status(battery_f); timelog("=>status");
mqtt.loop();
}
Serial.println("ESP going to deep sleep");
Serial.flush();
blink(100);
esp_wifi_stop();
uint32_t deep_sleep_sec = config["deep_sleep_sec"];
esp_deep_sleep(deep_sleep_sec*1000000);
esp_deep_sleep_start();
}
void loop() {
//no loop
}
Build info...
PACKAGES:
- framework-arduinoespressif32 3.10004.201016 (1.0.4)
- tool-esptoolpy 1.30000.201119 (3.0.0)
- toolchain-xtensa32 2.50200.80 (5.2.0)
...
Dependency Graph
|-- <WiFi> 1.0
|-- <ArduinoJson> 6.16.1
|-- <MQTT> 2.4.7
|-- <FS> 1.0
|-- <SPIFFS> 1.0
| |-- <FS> 1.0
Details...
[env]
board = firebeetle32
framework = arduino
lib_deps =
WiFi
ArduinoJson@6.16.1
617@2.4.7 #MQTT 256dpi/arduino-mqtt
lib_ldf_mode = deep+
[env:firebeetle32]
platform = espressif32
monitor_speed = 115200