#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
// WiFi parameters to be configured
const char* ssid = "ssid"; // Hoofdlettergevoelig
const char* password = "wachtwoord"; // Hoofdlettergevoelig
void setup(void) {
Serial.begin(9600);
Serial.print("Bezig met verbinden");
WiFi.begin(ssid, password); // Connect to WiFi
// while wifi not connected yet, print '.'
// then after it connected, get out of the loop
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Verbonden.
Serial.println("OK!");
// Access Point (SSID).
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// IP adres.
Serial.print("IP: ");
Serial.println(WiFi.localIP());
// Signaalsterkte.
long rssi = WiFi.RSSI();
Serial.print("Signaal sterkte (RSSI): ");
Serial.print(rssi);
Serial.println(" dBm");
Serial.println("");
}
void loop() {
if(WiFi.status()== WL_CONNECTED){ //Check WiFi connection status
HTTPClient http; //Declare object of class HTTPClient
http.begin("http://jsonplaceholder.typicode.com/users"); //Specify request destination
http.addHeader("Content-Type", "text/plain"); //Specify content-type header
int httpCode = http.POST("Hallo Wereld!"); //Send the request
String payload = http.getString(); //Get the response payload
Serial.println(httpCode); //Print HTTP return code
Serial.println(payload); //Print request response payload
http.end(); //Close connection
} else {
Serial.println("Error in WiFi connection");
}
delay(30000); //Send a request every 30 seconds
}