Update now power is 36ma. Put CPU at half speed dropped tp 27ma. Plenty of power to run off a good 18650 for day. charging works great using USB C charger.
Happy so far.
Update now power is 36ma. Put CPU at half speed dropped tp 27ma. Plenty of power to run off a good 18650 for day. charging works great using USB C charger.
Happy so far.
Good morning. Can someone tell me how to implement an ON OFF switch when the battery is being used to turn off the ESP32C3?
thank you so much.
I am facing a similar issue, battery is working fine when charging. I have tried on 2 different ESP32C3 xiao modules. They work fine for one day and next day when I remove usb type C, they don’t work on battery. Battery and xiao ESP32C3 is mounted inside an enclosure.
Hi there,
I see several options for Battery’s holder with a switch
News? Can I purchase some of them, or it’s just a waste of money?
Battery is working fine for me. Here is my test script.
Hardware is just a basic lipo battery attached and two buttons connected to gpio 2/3 and gnd
#include "WiFi.h"
#include <PubSubClient.h>
#define DEBUG_ENABLED 0
const char* ssid = "DronesAreWatching";
const char* password = "";
const char* mqtt_server = "blue.home";
const char* mqttUser = "internal";
const char* mqttPassword = "";
void debug(String msg){
if (DEBUG_ENABLED){
Serial.println(msg);
}
}
WiFiClient espClient;
PubSubClient client(espClient);
void setup_wifi() {
delay(10);
// We start by connecting to a WiFi network
debug("Connecting to ");
debug(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
debug(".");
}
debug("WiFi connected");
debug("IP address: ");
// debug(WiFi.localIP());
}
void setup() {
if (DEBUG_ENABLED){
Serial.begin(115200);
delay(100);
}
pinMode(D0, INPUT_PULLUP);
debug("Startup...send message");
setup_wifi();
client.setServer(mqtt_server, 1883);
client.connect("ESP8266Client", mqttUser, mqttPassword);
uint64_t gpio_reason = esp_sleep_get_gpio_wakeup_status();
debug(String(gpio_reason));
int GPIO = 0;
if (gpio_reason > 0){
GPIO = log(gpio_reason)/log(2);
}
debug(String(GPIO));
String GPIOString = String(GPIO);
int str_len = GPIOString.length() + 1;
char char_array[str_len];
GPIOString.toCharArray(char_array, str_len);
client.publish("mouse/trigger", char_array);
esp_deep_sleep_enable_gpio_wakeup((1ULL << 2), ESP_GPIO_WAKEUP_GPIO_LOW); //GPIO2
esp_deep_sleep_enable_gpio_wakeup((1ULL << 3), ESP_GPIO_WAKEUP_GPIO_LOW); //GPIO3
debug("Going to sleep in 5 seconds"); //time to send message
delay(5000);
if (DEBUG_ENABLED){
Serial.flush();
}
esp_deep_sleep_start();
}
void loop() {
}
One way that I have used successfully on boards that don’t have any built-in circuitry to detect the USB is to simply put in a resistor divide by 2 circuit from the 5V pin and connect the centre of the resistor divider to an analog input and read the voltage. A bit of maths lets you work out if the 5V is present. (Note that it might not be exactly 5v depending on diodes, usb supply etc. But there ought to be a significant difference to the voltage sensed this way between when the USB is plugged in or if you are running on a single cell LiPo battery.
Note that you need the resistor divider because the 5V is more than the chip’s inputs can take. Divide by 2 is safe (i.e. 5/2 is less than the 3.7 or so that the pins can take) There is probably a diode from the USB V+ as well that drops the voltage actually seen at the 5V pin.
Good luck!
Hi folks, thanks for this thread. Since no one has mentioned ESP32S3 boards yet in this discussion, I’ll add that my experience is identical to @chipko. When plugged into USB with a battery attached, the charging light blinks and the program runs. But when unplugged, the program halts and does not run, even after manual restarting. This is the sample Arduino Blink program, which does not include any use of Serial.begin()
. I have 3 other boards that all work with this same program and same battery. I think some boards might just be faulty.
I am necro-ing your old post here to say thanks! That worked. Much appreciated…but why did that work?
I was having the same issue; all fine when connected to USB and battery charging, seemingly dead device once USB disconnected.
Turned out to be a software issue. I was waiting for the serial connection, which without USB would never come.
Remove while (!Serial) ;
Calling Serial.whatever()
is fine in my case.
HTH someone
incase you were wondering that code says while serial (!) IS NOT connected
This code is used to hault the program until the user is listening on the serial monitor