Hello, I'm new here, but I would like some help if possible, I'm trying to create a code that sends data from sensors to monitor the water level in the Arduino cloud, but every time I try to compile it shows an error
#include <WiFi.h>
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
const char SSID[] = "WIFI";
const char PASS[] = "PASS_WIFI";
void setup() {
// Inicialize a conexão Wi-Fi
WiFi.begin(SSID, PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
}
// Inicialize o Arduino IoT Cloud
ArduinoCloud.setThingId("THING_ID"); // Substitua pelo ID do seu Thing no Arduino Cloud
ConnectionHandler.attachConnectionHandler();
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
}
void loop() {
ArduinoCloud.update();
readSensorData();
sendToArduinoCloud();
delay(5000); // Enviar dados a cada 5 segundos
}
void readSensorData() {
int sensor1Value = analogRead(A0);
int sensor2Value = analogRead(A1);
int sensor3Value = analogRead(A2);
int consolidatedSensorData = 0;
if (sensor1Value < 500) {
consolidatedSensorData = 25;
} else if (sensor1Value < 500 && sensor2Value < 500) {
consolidatedSensorData = 50;
} else if (sensor1Value < 500 && sensor2Value < 500 && sensor3Value < 500) {
consolidatedSensorData = 75;
} else {
consolidatedSensorData = 0;
}
ArduinoCloud.update(THINGS[0], consolidatedSensorData);
}
the code consists of reading 3 float-type sensors and depending on whether their condition was reached, a single value is returned showing whether it is at 25%, 50% or 75% of the value.
Can anyone help me? I intend to use just one ESP32