Hey, I always get this error:
/usr/local/bin/arduino-cli compile --fqbn esp8266:esp8266:d1_mini_pro:baud=921600,dbg=Disabled,eesz=16M14M,exception=disabled,ip=lm2f,lvl=None____,vt=flash,wipe=none,xtal=80 --libraries /home/builder/opt/libraries/latest --build-cache-path /tmp --output-dir /tmp/843741678/build --build-path /tmp/arduino-build-5AE03CAE92B301D6D7EE4053D2D87096 /tmp/843741678/Untitled_mar17a
Using library arduino_debugutils_1_1_0 at version 1.1.0 in folder: /home/builder/opt/libraries/arduino_debugutils_1_1_0
Using library arduinomqttclient_0_1_5 at version 0.1.5 in folder: /home/builder/opt/libraries/arduinomqttclient_0_1_5
/tmp/843741678/Untitled_mar17a/Untitled_mar17a.ino:20:23: error: expected initializer before 'setup'
bool wateringSuccess;
^
/tmp/843741678/Untitled_mar17a/Untitled_mar17a.ino:24:1: error: expected initializer before 'void'
void setup() {
^
/tmp/843741678/Untitled_mar17a/Untitled_mar17a.ino: In function 'void onMessageChange()':
/tmp/843741678/Untitled_mar17a/Untitled_mar17a.ino:65:38: error: request for member 'length' in 'charsOfMessage', which is of non-class type 'char [(((sizetype)<anonymous>) + 1)]'
for (int i = 0; i < charsOfMessage.length(); i++) {
^
/tmp/843741678/Untitled_mar17a/Untitled_mar17a.ino:66:31: error: request for member 'isDigit' in 'charsOfMessage[i]', which is of non-class type 'char'
if (not charsOfMessage[i].isDigit()) {
^
/tmp/843741678/Untitled_mar17a/Untitled_mar17a.ino:75:13: error: 'Message' was not declared in this scope
timer = Message.toInt();
^
/tmp/843741678/Untitled_mar17a/Untitled_mar17a.ino:93:42: error: request for member 'length' in 'charsOfMessage', which is of non-class type 'char [(((sizetype)<anonymous>) + 1)]'
for (int i = 0; i < charsOfMessage.length(); i++) {
^
/tmp/843741678/Untitled_mar17a/Untitled_mar17a.ino:94:35: error: request for member 'isDigit' in 'charsOfMessage[i]', which is of non-class type 'char'
if (not charsOfMessage[i].isDigit()) {
^
/tmp/843741678/Untitled_mar17a/Untitled_mar17a.ino:96:36: error: invalid use of 'void'
if (message.toLowerCase().compareTo("stop") == 0) {
^
Error during build: exit status 1
I already double checked every bracket and semicolon, but I cant figure out my mistake...
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;
char testForDigit
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);
message = "started right now";
}
void loop() {
ArduinoCloud.update();
// Your code here
}
void onMessageChange() {
// check if String is a number
isNumber = true;
// convert string to char, so you can use .isDigit()
char charsOfMessage[message.length()];
message.toCharArray(charsOfMessage, message.length());
for (int i = 0; i < charsOfMessage.length(); i++) {
if (not charsOfMessage[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
// convert string to char, so you can use .isDigit()
char charsOfMessage[message.length()];
message.toCharArray(charsOfMessage, message.length());
for (int i = 0; i < charsOfMessage.length(); i++) {
if (not charsOfMessage[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";
}
}*/
}
I dont know what to do anymore.
Could you please help me troubleshooting?
Thanks!