I have a Portenta C33 and am trying to create a very simple cloud project. It's been a total nightmare to even get this started. The bare minimum project, as created using the cloud tools won't run at all, it first complains: ArduinoIoTCloudTCP::begin could not read device id
and after that it yells
"ArduinoIoTCloudTCP::handle_SyncTime could not get valid time. Retrying now." every time the update() method is called.
I have done all sorts of debugging, including creating my own arduino_secrets.h file because the online IDE does not seem to create it proplerly (when I download it the value that I entered for the SSID and password are not properly set)
I have also verified that if I edit my .h files to properly define the SSID and password the WiFi connection can be properly set up so the physical device is fully capable of networking.
So...what I am looking for is does anybody have an example of a template project for a Portenta C33 that can actually connect to the Arduino Cloud? It doesn't have to do anything at all, I can handle the actual guts of what I need to do, I just want it to get to the point where the call to update() actually works!
Some more info. I instrumented the code to print out debug information. The code and output follow.
/*
Sketch generated by the Arduino IoT Cloud Thing "C33 Demo"
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"
void printIpInfo(const char* message)
{
Serial.println(message);
Serial.print(" WiFi status: ");
Serial.println(WiFi.status());
Serial.print(" IP Address: ");
Serial.println(WiFi.localIP());
}
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();
// Check the WiFi Status prior to the begin function
printIpInfo("Prior to calling begin function");
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
printIpInfo("After calling begin() function");
/*
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(4);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
printIpInfo("In loop:");
ArduinoCloud.printDebugInfo();
// Your code here
delay(1000);
}
The output is as follows:
In loop:
WiFi status: 3
IP Address: 192.168.50.227
***** Arduino IoT Cloud - 2.5.1 *****
Device ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
MQTT Broker: iot.arduino.cc:0
In loop:
WiFi status: 3
IP Address: 192.168.50.227
***** Arduino IoT Cloud - 2.5.1 *****
Device ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
MQTT Broker: iot.arduino.cc:0
ArduinoIoTCloudTCP::handle_SyncTime could not get valid time. Retrying now.
I noticed that missing device ID as well. I did not receive any errors while setting up/provisioning the board.
I have tried just manually setting the Device ID to the value shown in the on-line IDE, by using ArduinoCloud.setDeviceId(). That doesn't fix the problem.
I notice that I'm getting a bit more info out of the shell terminal where I launched the connection script, here's what I'm getting out of that:
I
NFO[5804] Download done.
INFO[5804] DFU state(7) = dfuMANIFEST, status(0) = No error condition is present
INFO[5805] DFU state(2) = dfuIDLE, status(0) = No error condition is present
INFO[5805] Done!
INFO[5805] Inside spHandler
INFO[5805] Opening serial port /dev/ttyACM0 at 9600 baud
INFO[5805] Just tried to open port
INFO[5805] Error opening port no such file or directory
INFO[5805] Inside spHandler
INFO[5805] Opening serial port /dev/ttyACM0 at 9600 baud
INFO[5805] Just tried to open port
INFO[5805] Error opening port no such file or directory
INFO[5806] Inside spHandler
INFO[5806] Opening serial port /dev/ttyACM0 at 9600 baud
INFO[5806] Just tried to open port
INFO[5806] Error opening port no such file or directory
INFO[5807] Inside spHandler
INFO[5807] Opening serial port /dev/ttyACM0 at 9600 baud
INFO[5807] Just tried to open port
INFO[5807] Opened port successfully
INFO[5807] Initting timed buffer flow (output once every 16ms)
INFO[5807] Read 68 bytes ch: Prior to calling begin function
WiFi status: 0
IP Address: 0
INFO[5807] Read 1 bytes ch: .
INFO[5807] Read 3 bytes ch: 0.0
INFO[5807] Read 1 bytes ch: .
INFO[5807] Read 1 bytes ch: 0
INFO[5807] Read 121 bytes ch: ArduinoIoTCloudTCP::begin could not read device id.
After calling begin() function
WiFi status: 0
IP Address: 0.
INFO[5807] Read 4 bytes ch: 0.0.
INFO[5807] Read 1 bytes ch: 0
INFO[5807] Read 39 bytes ch:
***** Arduino IoT Cloud - 2.5.1 *****
INFO[5807] Read 51 bytes ch:
evice ID: a50d05ff-fbdc-448b-a20e-2c595a5ab2c4
NFO[5807] Read 31 bytes ch: MQTT Broker: iot.arduino.cc:0
Read 18 bytes ch: WiFi.status(): 0
NFO[5807] Read 30 bytes ch: Current WiFi Firmware: 1.5.0
INFO[5820] Read 52 bytes ch: Connected to "cooper24"
In loop:
WiFi status: 3
INFO[5820] Read 24 bytes ch:
IP Address: 192.168
INFO[5820] Read 3 bytes ch: .50
INFO[5820] Read 4 bytes ch: .227
INFO[5820] Read 37 bytes ch: ***** Arduino IoT Cloud - 2.5.1 *****
INFO[5820] Read 47 bytes ch: Device ID: a50d05ff-fbdc-448b-a20e-2c595a5ab2c4
INFO[5820] Read 33 bytes ch:
QTT Broker: iot.arduino.cc:0
INFO[5821] Read 54 bytes ch: In loop:
WiFi status: 3
IP Address: 192.168.50
INFO[5821] Read 1 bytes ch: .
INFO[5821] Read 91 bytes ch: 227
***** Arduino IoT Cloud - 2.5.1 *****
Device ID: a50d05ff-fbdc-448b-a20e-2c595a5ab2c4
INFO[5821] Read 31 bytes ch:
MQTT Broker: iot.arduino.cc:0
INFO[5822] Read 124 bytes ch: ArduinoIoTCloudTCP::handle_SyncTime could not get valid time. Retrying now.
In loop:
WiFi status: 3
IP Address: 192
INFO[5822] Read 4 bytes ch: .168
INFO[5822] Read 1 bytes ch: .
INFO[5822] Read 2 bytes ch: 50
INFO[5822] Read 1 bytes ch: .
ch: 227
INFO[5822] Read 37 bytes ch: ***** Arduino IoT Cloud - 2.5.1 *****
should be used only for third-party boards and boards without a secure element. For the C33 you need to complete the provisionig flow described in the document.
A part from this from the log i see the board is not able to synch the time from the NTP server. make sure your network configuration is correct and that the board can use UDP protocol to connect to the ntp server.
Yeah, I only did that setDeviceId as an experiment, and it didn't work. Prior to that, and even after that, I did all of the provisioning as described in the document. In fact, that's where I originally started...I didn't do any of the other experiments until the original provisioning didn't work, at which point I started trying to debug.
I have gone so far as to completely delete everything and start over, but nothing I've done works (so far).
Sigh. As an experiment I once again deleted everything from my cloud account. Deleted devices, deleted sketches. Now when I try to add a new device I have to double-press the reset button to get into DFU mode, at which point the device is recognized. However the next step is for the system to configure the device. It says that it's uploading a sketch, but that step now fails.
I went back and tried once again (probably the 4th try). This time I changed nothing, and in particular did not provide my own custom name and just accepted the auto-generated name. Huh..that worked. At least now I have a device...I'll carry on with creating a sketch now.
While moving on to the next step, the instructions say to associate a device, that part worked. However the next step is to click the Network configure button. That button is disabled (greyed out)
However, if I add a cloud variable, then the Network configure button becomes enabled.
I was able to get through the rest of the process, including what looked like a successful upload to the device, however it still shows as offline and now I can't connect to the serial port.
..and after trying several rounds of connect/disconnect of the usb cable...success! It's now connected.
Dunno why I had such troubles, in each case I was carefully going step-by-step through the instructions, but now it's up and running so I guess this is resolved through the age old approach of "did you try doing the same thing multiple times?" solution!!