diff --git a/.gitignore b/.gitignore index 1bc6e73..a2cde9a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /schema/*/*-backups /.metadata/ +/ESP32/wifi-credentials.h diff --git a/ESP32/vehicle-monitor.cpp b/ESP32/vehicle-monitor.cpp index a6410ff..cf79120 100644 --- a/ESP32/vehicle-monitor.cpp +++ b/ESP32/vehicle-monitor.cpp @@ -3,15 +3,48 @@ #include #include +#include "wifi-credentials.h" + +AsyncWebServer server(80); + +const char index_html[] PROGMEM = R"rawliteral( + + + + ESP Web Server + + +

Hello world!

+ + +)rawliteral"; + void setup() { Serial.begin(115200); + + // Connect to Wi-Fi + WiFi.begin(wifi_ssid, wifi_password); + while (WiFi.status() != WL_CONNECTED) + { + delay(1000); + Serial.println("Connecting to Wifi..."); + } + + // Print ESP Local IP Address + Serial.print("Wifi connected, ip="); + Serial.println(WiFi.localIP()); + + server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) + { + request->send(200, "text/html", index_html); + }); + + server.begin(); + Serial.println("HTTP server started"); } void loop() { - Serial.printf("ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision()); - Serial.printf("This chip has %d cores\n", ESP.getChipCores()); - - delay(3000); + delay(1000); } diff --git a/ESP32/wifi-credentials.h.template b/ESP32/wifi-credentials.h.template new file mode 100644 index 0000000..7fe3fd9 --- /dev/null +++ b/ESP32/wifi-credentials.h.template @@ -0,0 +1,7 @@ +// To avoid saving your wifi credentials in the git repository, wifi-credentials.h.template is ignored by git + +// Copy this file and name it wifi-credentials.h +// Then edit your wifi SSID and password + +const char* wifi_ssid = "REPLACE_WITH_YOUR_SSID"; +const char* wifi_password = "REPLACE_WITH_YOUR_PASSWORD";