Programming, compiling and uploading the code to Arduino
Programming, compiling and uploading the code to Arduino
On the main screen of Arduino Web Editor, click on the button NEW SKETCH to create a new sketch:

Arduino Web Editor assigns the name of the new sketch automatically. The name consists of the word sketch, an underscore, and six alphanumeric characters (the first three letters of the month, two digits for the day and a sequential letter: a, b, c, etc.).
We change the name of the new sketch to green-spaces following the steps shown in the figure:

Now we copy the following code and paste it in the code area on the right:
/*****************************************/
#include <ArduinoHttpClient.h>
#include <WiFi101.h>
#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
/////// WiFi Settings ///////
char ssid[] = SECRET_SSID;
char pass[] = SECRET_PASS;
const char serverAddress[] = "maker.ifttt.com"; // server address
int port = 80;
WiFiClient wifi;
HttpClient client = HttpClient(wifi, serverAddress, port);
int status = WL_IDLE_STATUS;
const int sensorPin = A0;
float sensorValue;
float voltageOut;
float temperatureC;
void setup() {
pinMode(sensorPin, INPUT);
Serial.begin(9600);
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid); // print the network name (SSID);
// Connect to WPA/WPA2 network:
status = WiFi.begin(ssid, pass);
}
}
void loop() {
sensorValue = analogRead(sensorPin);
voltageOut = (sensorValue * 5000) / 1024;
// calculate temperature for LM35
temperatureC = voltageOut / 10;
/********** POST to maker.ifttt.com ***/
// assemble the path for the POST message:
String iftttName = "Sensor01";
String path = "/trigger/" + iftttName + "/with/key/PsyIA63fO9W6vGY_4ilmv";
String contentType = "application/json";
// assemble the body of the POST message:
String postData = "{\"value1\":\"";
postData += temperatureC;
postData += "\"}";
Serial.println("making POST request");
// send the POST request
client.post(path, contentType, postData);
// print to console
Serial.print("Temperature(ºC): ");
Serial.print(temperatureC);
Serial.print(" Voltage(mV): ");
Serial.println(voltageOut);
// wait for 1 hour
delay(3600000);
}
Code available on: https://pastebin.com/QUWeKDNP
Next, we click on the button Verify
and Save. Arduino Web Editor will verify the integrity of the code (that it
does not have errors) and will save it in the cloud under the assigned name:
