Hello everyone. i want to read data from a humidity sensor, but the variable 'val' that is suposed to have the data from the sensor is allways stuck at 0.
this is my code:
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled 2"
https://create.arduino.cc/cloud/things/56d9394e-9ef0-43f1-9e0f-d922ec934975
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
int val;
Variables 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.
*/
#include "thingProperties.h"
#define sensorPin 15
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(115200);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// 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();
// Your code here
//get the reading from the function below and print it
val = analogRead(sensorPin);
Serial.print("Analog output: ");
Serial.println(val);
delay(1000);
}