/* The following variables are automatically generated and updated when changes are made to the Thing properties int ldr; int pot; Properties which are marked as READ/WRITE in the Cloud Thing will also have functions which are called when their values are changed from the Dashboard. These functions are generated with the Thing and added at the end of this sketch. */ int sendCount = 0; #define potPin 1 #define ldrPin 2 #define ledPin 6 #include "thingProperties.h" WiFiSSLClient client; char server[] = "maker.ifttt.com"; void setup() { Serial.begin(9600); delay(1500); pinMode(6, OUTPUT); // Defined in thingProperties.h initProperties(); // Connect to Arduino IoT Cloud ArduinoCloud.begin(ArduinoIoTPreferredConnection); /* The following function allows you to obtain more information related to the state of network and IoT Cloud connection and errors the higher number the more granular information you’ll get. The default is 0 (only errors). Maximum is 4 */ setDebugMessageLevel(2); ArduinoCloud.printDebugInfo(); } void loop() { ArduinoCloud.update(); pot = analogRead(1); ldr = analogRead(2); Serial.println("pot = " + String(pot) + " ldr = " + String(ldr)); if (pot < 100) { digitalWrite(ledPin, HIGH); if (sendCount == 0) { iftttSend(pot); sendCount = 1; } } else { digitalWrite(ledPin, LOW); sendCount = 0; } delay(1000); } void iftttSend(int val) { String str_val = String(val); Serial.println("Alarm triggered ! Potentiometer value is: " + str_val); String data = "{\"value1\":\"" + str_val + "\"}"; // Connexion au serveur IFTTT Serial.println("Starting connection to server..."); if (client.connectSSL(server, 443)) { Serial.println("Connected to server IFTTT, ready to trigger alarm..."); // Make a HTTP request: client.println("POST /trigger/potentiometer_low/with/key/<YOUR-KEY> HTTP/1.1"); // Replace "<YOUR-KEY>" by your own IFTTT key client.println("Host: maker.ifttt.com"); client.println("Content-Type: application/json"); client.print("Content-Length: "); client.println(data.length()); client.println(); client.print(data); Serial.println("IFTTT alarm triggered !"); } else { Serial.println("Connection at IFTTT failed"); } }