Hi all, I have been working on a weather IOT Station, and I am trying to use the messenger widget in the IOT Cloud dashboard to send me a message when temperature/humidity/light intensity/pH get either too high or too low. However, I have been having troubles executing it. The if statements successfully work for one variable, but do not respond to the other.
Here is my code:
// DHT sensor library - Version: Latest
#include <DHT.h>
#include <DHT_U.h>
// Adafruit NeoPixel - Version: Latest
#include <Adafruit_Sensor.h>
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/b3722b54-8d53-4029-ad54-e89e684ac0d2
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
String message;
float humidity;
float pHVal;
float temperature;
int blueVal;
int greenVal;
int light;
int redVal;
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"
int greenPin=2;
int redPin=3;
int bluePin=4;
int PHPIN= A1;
int lightPin=A2;
float Voltage;
int Offset=0;
#define DHTPIN 1
#define DHTTYPE DHT11
DHT dht (DHTPIN,DHTTYPE);
void setup() {
// Initialize serial and wait for port to open:
pinMode(lightPin,INPUT);
Serial.begin(9600);
dht.begin();
pinMode(lightPin,INPUT);
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
analogWrite(greenPin,greenVal);
analogWrite(redPin,redVal);
analogWrite(bluePin,blueVal);
light=analogRead(lightPin);
Voltage= analogRead(PHPIN);
float volt=Voltage*5.0/1024;
pHVal=3.5*volt+Offset;
temperature=dht.readTemperature();
humidity=dht.readHumidity();
Serial.print("greenVal=");
Serial.print(greenVal);
Serial.print(", redVal=");
Serial.print(redVal);
Serial.print(", blueVal=");
Serial.print(blueVal);
Serial.print(", pH = ");
Serial.print(pHVal);
Serial.print(", Temperature = ");
Serial.print(temperature);
Serial.print(", Humidity = ");
Serial.print(humidity);
Serial.print(", Light = ");
Serial.println(light);
if (light<150) {
message = "LIGHT BELOW LIMIT OF 150";
}
else{
if (light>900) {
message = "LIGHT ABOVE LIMIT OF 900";
}
else{
message = "LIGHT NORMAL";
}
}
}
/*
Since GreenVal is READ_WRITE variable, onGreenValChange() is
executed every time a new value is received from IoT Cloud.
*/
void onGreenValChange() {
// Add your code here to act upon GreenVal change
}
/*
Since RedVal is READ_WRITE variable, onRedValChange() is
executed every time a new value is received from IoT Cloud.
*/
void onRedValChange() {
// Add your code here to act upon RedVal change
}
/*
Since BlueVal is READ_WRITE variable, onBlueValChange() is
executed every time a new value is received from IoT Cloud.
*/
void onBlueValChange() {
// Add your code here to act upon BlueVal change
}
/*
Since PHVal is READ_WRITE variable, onPHValChange() is
executed every time a new value is received from IoT Cloud.
*/
void onPHValChange() {
// Add your code here to act upon PHVal change
if (pHVal>7) {
message = "pH is more than" + String(7);
}
}
/*
Since Message is READ_WRITE variable, onMessageChange() is
executed every time a new value is received from IoT Cloud.
*/
void onMessageChange() {
// Add your code here to act upon Message change
}
/*
Since Light is READ_WRITE variable, onLightChange() is
executed every time a new value is received from IoT Cloud.
*/
void onLightChange() {
// Add your code here to act upon Light change
if (light <150) {
message = "BELOW INTENSITY LIMIT OF" + String(100);
}
}
I want it to do this below, except for all 4 variables.

Hope you can help me out thank you
