Hi!
My first post ever :o
So far I was always able to find posts of people struggling with the same issues like me and others who helped them. This time I cannot find any entries on the following problem (and please give me a link if I'm wrong and it has been discussed already):
When I run this code on my mkr wifi 1010:
/*
Sketch generated by the Arduino IoT Cloud Thing "test_thing"
https://create.arduino.cc/cloud/things/XXX
Arduino IoT Cloud Properties description
The following variables are automatically generated and updated when changes are made to the Thing properties
bool led;
Properties 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"
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(LED_BUILTIN, OUTPUT);
Serial.println("this is the last line of void setup");
}
void loop() {
ArduinoCloud.update();
// Your code here
Serial.println("this is inside void loop");
delay(3000);
}
void onLedChange() {
digitalWrite(LED_BUILTIN, led);
Serial.print("The light is ");
if (led) {
Serial.println("ON");
} else {
Serial.println("OFF");
}
}
which is basically the LED example with some extra debugging messages, I get this in the serial monitor:
[ 10717 ] Connected to "Kaffeenetz"
this is inside void loop
this is inside void loop
this is inside void loop
[ 19718 ] Connecting to Arduino IoT Cloud...
this is inside void loop
Compile time: 1553299200
[ 27047 ] Connected to Arduino IoT Cloud
this is inside void loop
this is inside void loop
this is inside void loop
this is inside void loop
this is inside void loop
this is inside void loop
The light is ON
this is inside void loop
The light is OFF
this is inside void loop
this is inside void loop
this is inside void loop
this is inside void loop
And i wonder why there is no entry from the void setup function?
Uploading this modified blink sketch with Arduino IDE:
/*
Blink
Turns an LED on for one second, then off for one second, repeatedly.
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
the correct LED pin independent of which board is used.
If you want to know what pin the on-board LED is connected to on your Arduino
model, check the Technical Specs of your board at:
https://www.arduino.cc/en/Main/Products
modified 8 May 2014
by Scott Fitzgerald
modified 2 Sep 2016
by Arturo Guadalupi
modified 8 Sep 2016
by Colby Newman
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Blink
*/
// the setup function runs once when you press reset or power the board
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);
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
Serial.println("this is the last line of void setup");
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
Serial.println("this is inside void loop");
}
I do get a message out of the setup function:
this is the last line of void setup
this is inside void loop
this is inside void loop
this is inside void loop
this is inside void loop
this is inside void loop
Please help me understand what I am missing.. The void setup function must be passed, since the serial port is available and the pin mode is set (right?) But why is there no message in the serial monitor when uploading it from arduino create/iot cloud?
I noticed this behavior when I tried to insert https://www.arduino.cc/en/Tutorial/WiFiRTC into my "thing" sketch. The connection to the ntp server is established inside void setup - and it wasn't.
Thanks
Moritz