#include #include #include #include ESP8266WiFiMulti WiFiMulti; // WiFi parameters const char* ssid = "ESP8266 Wifi Test"; const char* password = "1234Test"; const char* serverNameBoard = "http://192.168.4.2/board"; const char* serverNameRSSI = "http://192.168.4.2/rssi"; String Board; String rssi; unsigned long previousMillis = 0; const long interval = 5000; void setup() { Serial.begin(115200); WiFi.mode(WIFI_STA); // Setting as a Station WiFi.begin(ssid, password); // Connecting to specified WiFi network // Coomunicate with user through Serial port to notify of connection status Serial.print("Connecting"); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(" "); Serial.print("Connected to "); Serial.println(ssid); Serial.print("IP Address: "); Serial.println(WiFi.localIP()); } // Function that handles requests to the server - Copied from https://randomnerdtutorials.com/esp8266-nodemcu-client-server-wi-fi/ String httpGETRequest(const char* serverName) { WiFiClient client; HTTPClient http; // Your IP address with path or Domain name with URL path http.begin(client, serverName); // Send HTTP POST request int httpResponseCode = http.GET(); String payload = "--"; if (httpResponseCode>0) { Serial.print("HTTP Response code: "); Serial.println(httpResponseCode); payload = http.getString(); } else { Serial.print("Error code: "); Serial.println(httpResponseCode); } // Free resources http.end(); return payload; } void loop(){ if(millis() - previousMillis >= interval) { // Check WiFi connection status if ((WiFiMulti.run() == WL_CONNECTED)) { Board = String(httpGETRequest(serverNameBoard));; rssi = String(httpGETRequest(serverNameRSSI));; Serial.println("Board: " + Board + " | Signal Strength: " + rssi + "db"); previousMillis = millis(); } } }