hello, i'm a beginner and i'm trying to make a gps tracker with esp32 and a gps module. it basically shows the coordenates (lat and long) on a web server, and shows a maps link of your location. i'm connecting to my phone's hotspot since it's faster than my wifi
i'm gonna power supply them with a 3.7v 2800mAh battery and a stepup that regulates the voltage to 5v. i have regulated it some time ago, and the output was 5v, tested it with a multimeter.
i have tried my gps tracker just with my usb as i update code and it works fine, yet yesterday i tried it with the battery and my esp32 wasn't connecting to wifi. i've read a lot of people that say the problem is current but this stepup (mt3608) can provide 2A.
i measured the voltage of my battery and it's 4v (it's charged, i have tried with another charged 3.7v battery too) but the output of my stepup is around 3.7 and 3.9v? i thought i just had to regulate it again but after many turn pots it barely moved 0.2 v maybe. is it fried?? i have the same problem with another stepup i have. i have checked multiple times, the vin and the out pins are not inverted.
i have soldered wires to these stepups multiple times, maybe i fried the pins this way?
also, could i just power supply my esp32 and my neo6m gps module with my battery charged to 4v?
We're only making assumptions about your setup based on the information you've provided. Please post an annotated schematic so we can better understand your question. Keep in mind that the ESP32 operates at 3.3V, not 5V, and applying 5V directly to it can cause damage. This advice is based on the fact that you mentioned the ESP32 itself and not a specific module.
I don't know much about ESP32 boards but it might be important to know which exact board you have (and have selected).
If your board uses native USB for communication with a PC and you have a while(!Serial) in setup() your code will stop there till you establish a communication channel with a host (e.g. PC). In that case, comment out the while(!Serial).
I'll leave the electronics part to those more clever than me in that area.
I think you need a power supply for the GPS and a separate for the Arduino. Use at least 2 better is 3 batteries in series and a step down buck converter. I actually like to also use a LDO VR after the buck with appropriate voltages.
as for the connections between the esp32 and the gps
rx > gpio 17
tx > gpio 16
as i said, i have regulated the stepup to 5v a while ago, but now i have measured the output voltage and less than 4, which is the voltage my battery currently has.
i can't do that. my project is supposed to be small, as it's a prototype for a gps pet tracker, so i can use 1 battery max and my battery holder already uses a lot of space. i have thought on buying a 9v battery but i don't think it will provide enough current to my gps and my esp32 when connecting to wifi.
i have a stepdown, lm2596, but my batteries are 18650 with 4.1v max when charged.
how do i do that? i'm a newbie on programming so i'm not sure what's the problem in my code.
here it is:
#include <WiFi.h>
#include <WebServer.h>
#include <TinyGPS++.h>
// WiFi network data - Fill in
const char* ssid = "moto g(20)"; // SSID
const char* password = "testing1234"; // password
// Initializing web server on port 80
WebServer server(80);
// Initializing GPS
TinyGPSPlus gps;
HardwareSerial ss(1); // Using the serial port 1 of the ESP32
static const uint32_t GPSBaud = 9600;
// Variables for saving latitude and longitude
double latitude = 0.0;
double longitude = 0.0;
void setup() {
// Initialize serial communication
Serial.begin(115200);
delay(1000); // Small delay to make sure the serial connection is ready
Serial.println("Iniciando ESP32...");
// Run GPS
ss.begin(GPSBaud, SERIAL_8N1, 16, 17); // Pines RX 16, TX 17
Serial.println("Initializing GPS...");
// Connection to WiFi network
Serial.print("Connecting to WiFi: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
// Wait for WiFi connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Successful connection confirmation
Serial.println("\nConnected to WiFi network");
Serial.print("ESP32 IP: ");
Serial.println(WiFi.localIP());
// Run web server
server.on("/", handleRoot); // Define main route
server.begin();
Serial.println("Web server initialized, waiting connections...");
}
void loop() {
// Process the GPS data in a non-blocking manner
while (ss.available() > 0) {
gps.encode(ss.read());
}
// Just update the latitude and longitude if they're valid
if (gps.location.isValid()) {
latitude = gps.location.lat();
longitude = gps.location.lng();
}
// Manage the petitions of the web server
server.handleClient();
}
// Function to manage the root of the web server
void handleRoot() {
String message = "<html><body><h1>ESP32 GPS data</h1>";
if (gps.location.isValid()) {
message += "<p>Latitud: " + String(latitude, 6) + "</p>";
message += "<p>Longitud: " + String(longitude, 6) + "</p>";
message += "<a href=https://www.google.com/maps?q=" + String(latitude, 6) + "," + String(longitude, 6) + ">See the exact location of your pet</a>";
} else {
message += "<p>GPS not valid or found.</p>";
}
message += "</body></html>";
// Send the response to browser
server.send(200, "text/html", message);
}
sorry if something on the comments doesn't make much sense, i tried to translate it from spanish.
#include <WiFi.h>
#include <WebServer.h>
#include <TinyGPS++.h>
// WiFi network data - Fill in
const char* ssid = "moto g(20)"; // SSID
const char* password = "testing1234"; // password
// Initializing web server on port 80
WebServer server(80);
// Initializing GPS
TinyGPSPlus gps;
HardwareSerial ss(1); // Using the serial port 1 of the ESP32
static const uint32_t GPSBaud = 9600;
// Variables for saving latitude and longitude
double latitude = 0.0;
double longitude = 0.0;
void setup() {
// Initialize serial communication
Serial.begin(115200);
delay(1000); // Small delay to make sure the serial connection is ready
Serial.println("Iniciando ESP32...");
// Run GPS
ss.begin(GPSBaud, SERIAL_8N1, 16, 17); // Pines RX 16, TX 17
Serial.println("Initializing GPS...");
// Connection to WiFi network
Serial.print("Connecting to WiFi: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
// Wait for WiFi connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Successful connection confirmation
Serial.println("\nConnected to WiFi network");
Serial.print("ESP32 IP: ");
Serial.println(WiFi.localIP());
// Run web server
server.on("/", handleRoot); // Define main route
server.begin();
Serial.println("Web server initialized, waiting connections...");
}
void loop() {
// Process the GPS data in a non-blocking manner
while (ss.available() > 0) {
gps.encode(ss.read());
}
// Just update the latitude and longitude if they're valid
if (gps.location.isValid()) {
latitude = gps.location.lat();
longitude = gps.location.lng();
}
// Manage the petitions of the web server
server.handleClient();
}
// Function to manage the root of the web server
void handleRoot() {
String message = "<html><body><h1>ESP32 GPS data</h1>";
if (gps.location.isValid()) {
message += "<p>Latitud: " + String(latitude, 6) + "</p>";
message += "<p>Longitud: " + String(longitude, 6) + "</p>";
message += "<a href=https://www.google.com/maps?q=" + String(latitude, 6) + "," + String(longitude, 6) + ">See the exact location of your pet</a>";
} else {
message += "<p>GPS not valid or found.</p>";
}
message += "</body></html>";
// Send the response to browser
server.send(200, "text/html", message);
}