Hi. Hope you are alright. I’m worried about putting the battery in the esp32’s GPIO to monitor the voltage level, as I don’t know if the current can burn it. My project uses two batteries (one for esp32 and sensors and one for motor and servo) connected to Vin of tp4056 and Vout connected to Vin of step up DC DC. Can you help me? I would like to monitor the battery voltage level.
Hi Marcos.
Can you show me your circuit? To share an image, send a link to Imgur or google drive, for example.
Are you using a step-up DC-DC to step up the voltage to 5V? Did you consider using a low dropout voltage regulator circuit instead?
Regards,
Sara
Hi Sara! Thank you for your attention
Yes, I thought about using LDO, but I couldn’t find the regulator to sell in Brazil
I am very pleased with the ebook tutorial. I tested the voltage divider on the GPIO port and it worked perfectly for both voltage and current reduction. Now I am sure to continue with the project.
I take this opportunity to consult you about the possibility of you making a web server tutorial in HTML that updates the page with continuous readings in the form of a table or graph, like dashboard. I would also like a tutorial to make multiclient communication, with two lora communicating with gateway and this one with a web server. if there is no interest, I would like some reference.
Thanks
Hi.
I’m glad it is working as expected (I saw the photo you sent via email).
As for the other questions, to make a web server that updates the page with continuous readings, you can use server sent events.
In our “Build Web Servers with ESP32 and ESP8266” eBook, we explain in great detail how to do that using tables and charts.
We have a free tutorial that explains how to use server-sent events:
We also have these tutorials about creating charts:
- https://randomnerdtutorials.com/esp32-plot-readings-charts-multiple/
- https://randomnerdtutorials.com/esp32-esp8266-plot-chart-web-server/
For multiclient communication with LoRa, I think you need to use LoraWAN to set up a gateway that receives messages from differentes nodes (Lora senders) and sends those messages to other nodes (ESP32). Unfortunately, we don’t have any LoRaWAN projects. Search for “ESP32 LoraWAN” or “ESP32 TTN Lora”. I think that might help.
Regards,
Sara
I also have a battery monitor circuit I am having issues with ,but don’t want to hijack this post in any way. Found this sketch which will do what I want it to do so why reinvent the wheel ? Pretty simple circuit , voltage divider 10k resistor—47K resistor A0 at junction . Battery neg on 10k and ESP8266 neg A0 to point at 47 and 10k ,+ battery at 47K . Connects to WiFi and shows Battery voltage =0.48 battery dead Or disconnected. If I check battery I get on the post 12.7 and 47K at A0 to 10K . Also neg at A0 common to battery at the 10K ,I know this is not your circuit but was hoping for some direction here, wasn’t able to get the author on this project, Reading at A0 ref to ground2.14 vdc and 10.57 from junction to + of 47k
Thanks
Start your code here
/*****************************************************
* Date: 18 june 2018
* Written by: Usman Ali Butt
* Property off: microcontroller-project.com
* ***************************************************/
#include <ESP8266WiFi.h>
const char* ssid = “*****”;
const char* password = “*********”;
int BAT= A0; //Analog channel A0 as used to measure battery voltage
float RatioFactor=5.714; //Resistors Ration Factor
WiFiServer server(80);
void setup() {
Serial.begin(9600);
delay(10);
Serial.print(“Connecting to “);
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(“.”);
}
Serial.println(“”);
Serial.println(“WiFi connected”);
server.begin(); // Start the server
Serial.println(“Server started”);
// Print the IP address on serial monitor
Serial.print(“Use this URL to connect: “);
Serial.print(“http://”); //URL IP to be typed in mobile/desktop browser
Serial.print(WiFi.localIP());
Serial.println(“/”);
}
void loop() {
int value = LOW;
float Tvoltage=0.0;
float Vvalue=0.0,Rvalue=0.0;
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println(“new client”);
while(!client.available()){
delay(1);
}
// Read the first line of the request
String request = client.readStringUntil(‘\r’);
Serial.println(request);
client.flush();
// Match the request
if (request.indexOf(“/bat=ON”) != -1) {
/////////////////////////////////////Battery Voltage//////////////////////////////////
for(unsigned int i=0;i<10;i++){
Vvalue=Vvalue+analogRead(BAT); //Read analog Voltage
delay(5); //ADC stable
}
Vvalue=(float)Vvalue/10.0; //Find average of 10 values
Rvalue=(float)(Vvalue/1024.0)*5; //Convert Voltage in 5v factor
Tvoltage=Rvalue*RatioFactor; //Find original voltage by multiplying with factor
/////////////////////////////////////Battery Voltage//////////////////////////////////
value = HIGH;
}
// Return the response
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println(“”); // do not forget this one
client.println(“<!DOCTYPE HTML>”);
client.println(“<html>”);
client.println(“Battery Voltage =”);
client.print(Tvoltage);
client.println(“<br>”);
if(value == HIGH) {
client.println(“Updated”);
} else {
client.print(“Not Updated”);
}
client.println(“——–“);
if(Tvoltage<=5){
client.println(“Battery dead OR disconnected”);
}
else if(Tvoltage>5 && Tvoltage<=10){
client.println(“Need Imediate recharge”);
}
else if(Tvoltage>10 && Tvoltage<=12){
client.println(“Recharge”);
}
else{
client.println(“Battery Full”);
}
client.println(“<br><br>”);
client.println(“<a href=\”/bat=ON\”\”><button>Status</button></a><br />”);
client.println(“</html>”);
delay(1);
Serial.println(“Client disonnected”);
Serial.println(“”);
}