I just bought a MKR WIFI 1010 board to try out IoT. I got a lot to work in the first couple of days using the Iot Cloud editor.
My project is to turn on a driveway heater using the phone.
Turn on/off works fine but now I want to set a time for the heater to run. I have included the <RTZZero.h> lib and this is where things started to go wrong. I can't do much in the IoT cloud editor so I am stucked.
On compile I get this error:
Using library SNU at version 1.0.2 in folder: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.11/libraries/SNU
Using library adafruit_sleepydog_library_1_4_0 at version 1.4.0 in folder: /home/builder/opt/libraries/latest/adafruit_sleepydog_library_1_4_0
/tmp/962397445/build/libraries/arduinoiotcloud_1_1_1/utility/time/TimeService.cpp.o:/home/builder/opt/libraries/latest/arduinoiotcloud_1_1_1/src/utility/time/TimeService.cpp:33: multiple definition of `rtc'
/tmp/962397445/build/sketch/Driveway_Heater_aug03a.ino.cpp.o:/tmp/962397445/Driveway_Heater_aug03a/Driveway_Heater_aug03a.ino:26: first defined here
I think the library you are using is for a SAMD21 not and ESP32. You should check you have the correct library. And every Arduino library has example code. You should find the example and verify all is operating before using your own code.
As stated in the top the board is MKR WIFI 1010 - this is a SAMD board. I am suspecting that maybe <ArduinoIotCloud.h> or something else also includes TimeService.cpp. If I am right it makes Arduino Iot Cloud unusable - you just choose the libraries you need and that is it. Maybe I will need to download these libraries and see if anything is declared twice. Then make a copy and upload a new version to my Sketch.
@peterol I think that the issue is because you're using both the RTCZero and Adafruit Sleepydog libraries. The former employs the RTC timer/counter, while the latter the WDT watchdog timer.
These libraries conflict, because they both try to configure their own 32.768kHz clock source on generic clock 2 (GCLK2), which clocks their respective timers.
RTCZero attempts configure SAMD21's GCLK2's source to be either the external 32.768kHz crystal (XOCS32K) or the on-chip internal 32.768kHz internal oscillator (OSC32K), (depending on whether the board is has an external crystal or not), while Sleepdog attempts to configure GCLK2 for the on-chip internal ultra low power 32.768kHz oscillator (OSCULP32K).
The workaround is to edit one of the libraries and move the clock source to say GCLK4, (GCLKs 0 to 3 are used by the Arduino core code).
@peterol Digging a little deeper, it looks like the Arduino IoT Clound library already uses both the RTCZero and Adafruit Sleepydog libraries, which is why the Ardafruit Sleepydog library is being referenced in your compilation errors. Not being familiar with the Arduino IoT Cloud library, I'm not sure why they're using two incompatible libraries together?