Hey, I am working on a automatic watering with the arduino IoT cloud.
It seems like the var isNumber is not declared in the function onMessageChange(), but it clearly is.
The arduino web editor marks this line:
isNumber = TRUE;
thats my error:
Start verifying
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino: In function 'void onMessageChange()':
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:62:14: error: 'TRUE' was not declared in this scope
isNumber = TRUE;
^
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:64:23: error: 'Message' was not declared in this scope
for (int i = 0; i < Message.length; i++) {
^
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:66:18: error: 'FALSE' was not declared in this scope
isNumber = FALSE;
^
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:74:13: error: 'Message' was not declared in this scope
timer = Message.toInt();
^
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:91:37: error: invalid use of 'void'
if ((message.toLowerCase().compareTo("stop")) == 0) {
^
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:94:31: error: 'FALSE' was not declared in this scope
wateringSuccess = FALSE;
^
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:119:5: error: expected '}' at end of input
}
^
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:119:5: error: expected '}' at end of input
Error during build: exit status 1
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino: In function 'void onMessageChange()':
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:62:14: error: 'TRUE' was not declared in this scope
isNumber = TRUE;
^
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:64:23: error: 'Message' was not declared in this scope
for (int i = 0; i < Message.length; i++) {
^
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:66:18: error: 'FALSE' was not declared in this scope
isNumber = FALSE;
^
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:74:13: error: 'Message' was not declared in this scope
timer = Message.toInt();
^
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:91:37: error: invalid use of 'void'
if ((message.toLowerCase().compareTo("stop")) == 0) {
^
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:94:31: error: 'FALSE' was not declared in this scope
wateringSuccess = FALSE;
^
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:119:5: error: expected '}' at end of input
}
^
/tmp/606627402/Untitled_mar17a/Untitled_mar17a.ino:119:5: error: expected '}' at end of input
Error during build: exit status 1
and thats my code:
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/6eb14f19-2a6f-4f0e-b2db-0fe1b122b32e
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
String message;
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 timer;
unsigned long currentMillis;
bool isNumber;
bool wateringSuccess;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// 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();
pinMode(16, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
}
void loop() {
ArduinoCloud.update();
// Your code here
}
/*
*/
void onMessageChange() {
// check if String is a number
isNumber = TRUE;
for (int i = 0; i < Message.length; i++) {
if (not Message[i].isDigit()) {
isNumber = FALSE;
break;
}
}
// code if mesage is a number
if (isNumber) {
// convert message to number
timer = Message.toInt();
// start loop, activate led and pin
currentMillis = millis();
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(16, HIGH);
wateringSuccess = TRUE;
while (currentMillis > timer * 1000 + currentMillis) {
yield();
// check if changed message is string
for (int i = 0; i < Message.length; i++) {
if (not Message[i].isDigit()) {
// if you send the stop message
if ((message.toLowerCase().compareTo("stop")) == 0) {
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(16, LOW);
wateringSuccess = FALSE;
break;
}
}
}
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(16, LOW);
//send back succes message
if (wateringSuccess) {
message = "watered successfully";
}
else {
message = "stopped successfully";
}
/* if message is no number
if(not isNumber){
if(message.compareTo("HI") == 0){
message = "HI";
}
}*/
}
Could you please help me fixing this?
Thanks!