#include int sensor = 32; unsigned long previousMillis = 0; const long interval = 1500; const char* ssid = "Iaac-Wifi"; const char* password = "EnterIaac22@"; const char* host = "maker.ifttt.com"; const char* apiKey = "fM6cXYr9NICYM9v31SQ7_NH1230HqzuvWTvZVG24Kl3"; bool sended = false; void setup() { // initialize digital pin LED_BUILTIN as an output. Serial.begin(9600); pinMode(13, OUTPUT); // Connect to Wi-Fi WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); pinMode(sensor, INPUT); } void loop() { int lectura = analogRead(sensor); if ((lectura < 1800) || (lectura > 2100)) { digitalWrite(13, LOW); if (sended == false) { sendEmail(); sended = true; } } else { sended = false; digitalWrite(13, HIGH); } Serial.println(analogRead(sensor)); delay(100); } void sendEmail(){ //Send email Serial.print("connecting to "); Serial.println(host); WiFiClient client; const int httpPort = 80; if (!client.connect(host, httpPort)) { Serial.println("connection failed"); return; } String url = "/trigger/door_sensor/with/key/"; url += apiKey; Serial.print("Requesting URL: "); Serial.println(url); client.print(String("POST ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: 13\r\n\r\n" + "value1=" + "The door is open" + "\r\n"); }