I am using a waterflow sensor and it shows the data reading in the serial monitor however the wigedt doesn't move
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled 2"
https://create.arduino.cc/cloud/things/dbcc0687-bcd0-48d6-8194-a52daa18c81c
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
int wATER_FLOW;
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 sensor 2
const byte sensors = 4;
const byte sensorPins[sensors] = {2, 3, 18, 19};
volatile unsigned long flow_frequency[sensors] = {0, 0, 0, 0}; // Measures flow sensor pulsesunsigned
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(115200);
pinMode(sensor, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(sensor), flow1, RISING);
// 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
onWATERFLOWChange(0);
waterflow = ENV.read
}
/*
Since WATERFLOW is READ_WRITE variable, onWATERFLOWChange() is
executed every time a new value is received from IoT Cloud.
*/
void onWATERFLOWChange(byte s) {
// Add your code here to act upon WATERFLOW change
static unsigned long l_hour = 0;
static unsigned long flow_freq = 0;
noInterrupts();
flow_freq = flow_frequency[s];
flow_frequency[s] = 0; // this is used so that the reading of the water flow returns to 0 whenver it stops spinning and not stacking the reading
interrupts();
// Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.
l_hour = (flow_freq * 60 / 7.5); // (Pulse frequency x 60 min) / 7.5Q = flowrate in L/hour
Serial.print("WaterFlow: ");
Serial.println(s+1);
Serial.print(l_hour); // Print litres/hour
Serial.println(" L/hour");
delay(150);
}
void flow1() { // interrupt function
flow_frequency[0]++; // this will increment the array flow_frequency[s]
}