Can't verify code in arduino iot cloud with nano 33 iot

hi I'm new the cloud and I've been trying to get my nano 33 iot working with the cloud I've gone through all the steps witch includes installing the arduino agent and configuring the device and the current status is online but when I try to upload my code to the arduino trough usb it gives an error message. if I use the full editor it uploads but using the cloud editor the error pops up. I've tried to build a dashboard with a switch widget and linked it to a variable for switching a simple led after uploading with full editor but its seems like the arduino is not connected to the cloud even after it successfully uploaded with full editor.

here's my code:

/*
  Sketch generated by the Arduino IoT Cloud Thing "Untitled 2"
  https://create.arduino.cc/cloud/things/ecdde80b-480a-409a-8db0-19ccd690dd54

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  bool led1;

  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 ledPin=8;
void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  pinMode(ledPin,OUTPUT);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);
  //Serial.println("hello world");

  // 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();
}

void loop() {
  ArduinoCloud.update();
  // Your code here
Serial.println(led1);

}



void onLed1Change() {
  // Do something
  if (led1){
    digitalWrite(ledPin,HIGH);
  }
  else{
    digitalWrite(ledPin,LOW);
  }
}

and here's the error message:

Start verifying
In file included from /tmp/199022313/temperature_aug22a/temperature_aug22a.ino:1:0:
/tmp/199022313/temperature_aug22a/arduino_secrets.h:2:21: error: missing terminating " character
 #define SECRET_PASS "wifiPassword"
                     ^
/tmp/199022313/temperature_aug22a/thingProperties.h:10:25: note: in expansion of macro 'SECRET_PASS'
 const char PASS[]     = SECRET_PASS;    // Network password (use for WPA, or use as key for WEP)
                         ^~~~~~~~~~~
In file included from /tmp/199022313/temperature_aug22a/temperature_aug22a.ino:17:0:
/tmp/199022313/temperature_aug22a/thingProperties.h:10:36: error: expected primary-expression before ';' token
 const char PASS[]     = SECRET_PASS;    // Network password (use for WPA, or use as key for WEP)
                                    ^
exit status 1

In file included from /tmp/199022313/temperature_aug22a/temperature_aug22a.ino:1:0:
/tmp/199022313/temperature_aug22a/arduino_secrets.h:2:21: error: missing terminating " character
 #define SECRET_PASS "wifPassword"
                     ^
/tmp/199022313/temperature_aug22a/thingProperties.h:10:25: note: in expansion of macro 'SECRET_PASS'
 const char PASS[]     = SECRET_PASS;    // Network password (use for WPA, or use as key for WEP)
                         ^~~~~~~~~~~
In file included from /tmp/199022313/temperature_aug22a/temperature_aug22a.ino:17:0:
/tmp/199022313/temperature_aug22a/thingProperties.h:10:36: error: expected primary-expression before ';' token
 const char PASS[]     = SECRET_PASS;    // Network password (use for WPA, or use as key for WEP)
                                    ^
exit status 1

When you open the full editor did you edit the Secrets tab? The "error: missing terminating" would indicate that you are missing a double quotation " in line 2 of the secrets.h file.

I would suggest to try starting all over and follow these steps in the setup page of the IoT Cloud instead of opening the full editor:

  • Create a thing
  • Add Variable = led1
  • Select Device (Nano 33 IoT)
  • Enter network credentials (IoT Cloud not Full editor)

Then a sketch will be generated after you have configured the network and you should be able to verify and upload the sketch no problem. Once you see the board is connected to the cloud you can modify you sketch.

I don't think I changed any thing in the secret file but it seems like it has a problem with my wifi password because it has a \ in it. I gave it network credentials of a different router that have a different password and it worked. I don't know if that is the problem but it almost seems like it.

1 Like

Oh I see. Yea then definitely something to do with the special characters that the IoT Cloud doesn't process correctly. Good to know. :thinking:

yes I've changed my password and it works now so apparently it doesn't like special characters. but thank you for helping I learned something today.

If you have a \ in your password (or strings in general), you need to escape it with a \.

So hello\world must be entered in code as hello\\world

I've moved your topic to a more suitable location on the forum. Installation and Troubleshooting is not for problems with your project.

At least in the Arduino Web Editor, there is some automagic escaping of special characters for you. As it says on the "Secret" tab:

All the values you enter will be considered a string, some special characters will be automatically escaped.

This means you actually should not manually escape in the Arduino Web Editor secret fields. For example, if I run this sketch:

void setup() {
    Serial.begin(9600);
    Serial.println(SECRET_FOO);
}
void loop() {}

With the value of SECRET_FOO set to foo\\ in the Arduino Web Editor "Secret" tab, then this is printed to the Monitor:

foo\\

notice the two \ rather than one as you would get from a standard string literal like this:

void setup() {
    Serial.begin(9600);
    Serial.println("foo\\");
}
void loop() {}