Hi ,
I try to create an asynchronous server on Esp32 , however , the esp 32 dont output the IP address for me to access the server . I not sure why , Could you guy give me advise please ?
#include <string.h>
#include <Arduino.h>
#include "temperature.h"
#include "charge.h"
#include "current.h"
#include <Wire.h>
#include <WiFi.h>
#include <ESPAsyncWebServer.h>
#include <AsyncTCP.h>
#include "SPIFFS.h"
// Replace with your network credentials
const char* ssid = "Tp_set";
const char* password = "12345678";
// Create AsyncWebServer object on port 80
AsyncWebServer server(80);
String temperature_text;
String percentage_text;
temperature bms;
charge battery ;
current battery_2;
void setup() {
Serial.begin(115200);
Serial.println("Hello, ESP32!");
// Initialize SPIFFS
if(!SPIFFS.begin()){
Serial.println("An Error has occurred while mounting SPIFFS");
return;
}
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}
// Print ESP32 Local IP Address
Serial.println(WiFi.localIP());
// Route for root / web page
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, "/index.html");
});
server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/plain", temperature_text.c_str());
});
server.on("/percentage", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/plain", percentage_text.c_str() );
});
server.begin();
battery.begin();
bms.begin();
battery_2.begin();
}
void loop() {
String temperature_text = String(temperature_battery,3) ;
String percentage_text = String(percentage_value) ;
bms.calculate_temperature();
battery.pin_multiplexer();
battery.check_voltage();
battery.percentage();
battery_2.check_current();
}