MKR1000 connectivity issues with IoT

Hello everyone, today I tried to integrate my arduino MKR1000 project with Alexa; To give it a go I followed step by step the instructions of the tutorial issued by Arduino, but after uploading the sketch the Arduino shows as offline in the dashboard and the Alexa App won't find it. Opening the Serial monitor I get the following message:

_crypto.readDeviceId(...) failed.

***** Arduino IoT Cloud - configuration info *****

Device ID:

MQTT Broker: mqtts-sa.iot.arduino.cc:8883

WiFi.status(): 0

Current WiFi Firmware: 19.6.1

Here is the code, can anyone help me?:

#include <ArduinoGraphics.h>
#include <Arduino_MKRRGB.h>
#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);

  MATRIX.begin();
  MATRIX.brightness(10);

  while (!Serial);

  // 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
}


void onLoungeAreaChange() {
  uint8_t r, g, b;
  loungeArea.getValue().getRGB(r, g, b);
  if (loungeArea.getSwitch()) {
    Serial.println("R:" + String(r) + " G:" + String(g) + " B:" + String(b)); //prints the current R, G, B values
    MATRIX.beginDraw(); //starts a new "drawing" on the RGB shield's pixels
    MATRIX.clear(); //clears the RGB shield's pixels
    MATRIX.noStroke();
    MATRIX.fill(r, g, b); //the r, g, b values are fed into the shield's pixels
    MATRIX.rect(0, 0, MATRIX.width(), MATRIX.height()); //creates a rectangle (this covers the entire matrix)
    MATRIX.endDraw(); // ends the draw, and displays the new "drawing"

  }
  else {
    Serial.println("Lamp Off");
    //the following code simply turns everything off
    MATRIX.beginDraw();
    MATRIX.clear();
    MATRIX.noStroke();
    MATRIX.fill(0, 0, 0);
    MATRIX.rect(0, 0, MATRIX.width(), MATRIX.height());
    MATRIX.endDraw();

  }
}

Hello!

I see nowhere in your code where you initialize the Wi-Fi connection
Is there a part of you code you didn't share?
Otherwise, if your not connected to your Wi-Fi it is normal to not be able to connect to Alexa

The fact that Wifi.status() returns 0 confirms that you're not connected

first of all thanks for your reply!

I didn't include in the message the tab called thingproperties.h, this is it, anyway as I was saying I copied the exact instructions and code from the tutorial so I guess it must be something in my network or configuration, right?:

// Code generated by Arduino IoT Cloud, DO NOT EDIT.

#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

const char SSID[]     = SECRET_SSID;    // Network SSID (name)
const char PASS[]     = SECRET_OPTIONAL_PASS;    // Network password (use for WPA, or use as key for WEP)

void onLoungeAreaChange();

CloudColoredLight loungeArea;

void initProperties(){

  ArduinoCloud.addProperty(loungeArea, READWRITE, ON_CHANGE, onLoungeAreaChange);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

Did you add you credentials for connecting to your network?

Or maybe did you, in the past, succeeded to connect to your Wi-Fi?

Yes, I added them and to test of it was the board I used the example sketch to successfully connect to my network

Well according to the output of the monitor you gave if your first messages, you aren't connected to your Wi-Fi
Can you try with an basic exemple from the library of your choice (compatible with your board ofc) to connect to your Wi-Fi to confirm it is working actually?

yes, I tried, the board managed to connect, this is the output i get:

Board Information:
IP Address: "REDACTED"

Network Information:
SSID: "REDACTED"
signal strength (RSSI):-58
Encryption Type:2

When you use the ArduinoIoTCloud library you don't need any additional library to manage the WIFI connection as it handles the connectivity for you. So the code looks good to me.

For testing purposes, could you do the following?

  1. Increase debug level
setDebugMessageLevel(4);
  1. Add a log message at the end of the setup()
Serial.println("setup done!");
  1. Add the following code to your loop
unsigned long last_ts = 0;
void loop()
{
  ArduinoCloud.update();

  if (millis() - last_ts > 1000) {
    last_ts = millis();
    Serial.print("WiFi.status(): ");
    Serial.println(WiFi.status());
  }
}

and share your logs with us.

Additionally, I would suggest double checking that your WIFI credentials are ok and that you have good WIFI coverage.

Hi thanks for your reply and sorry if I answer after days, I did as you said and these are the logs:

/usr/local/bin/arduino-cli compile --fqbn arduino:samd:mkr1000 --build-cache-path /tmp --output-dir /tmp/2714324162/build --build-path /tmp/arduino-build-986FCDB3889FDD0EBC89DEE4626DA4E3 /tmp/2714324162/test_aug08a

Sketch uses 149664 bytes (57%) of program storage space. Maximum is 262144 bytes.

Global variables use 24604 bytes (75%) of dynamic memory, leaving 8164 bytes for local variables. Maximum is 32768 bytes.

Upload started

Programming with: Serial

Restarting in bootloader mode

Flashing with command:C:/Users/matte/.arduino-create/arduino/bossac/1.7.0-arduino3/bossac.exe -i -d --port=COM6 -U true -i -e -w -v C:/Users/matte/AppData/Local/Temp/arduino-create-agent3770140445/test_aug08a.bin -R

Set binary mode

readWord(addr=0)=0x20007ffc

readWord(addr=0xe000ed00)=0x410cc601

readWord(addr=0x41002018)=0x10010305

version()=v2.0 [Arduino:XYZ] Dec 20 2016 15:36:43

chipId=0x10010005

Connected at 921600 baud

readWord(addr=0)=0x20007ffc

readWord(addr=0xe000ed00)=0x410cc601

readWord(addr=0x41002018)=0x10010305

Atmel SMART device 0x10010005 found

write(addr=0x20004000,size=0x34)

writeWord(addr=0x20004030,value=0x10)

writeWord(addr=0x20004020,value=0x20008000)

Device : ATSAMD21G18A

readWord(addr=0)=0x20007ffc

readWord(addr=0xe000ed00)=0x410cc601

readWord(addr=0x41002018)=0x10010305

Chip ID : 10010005

version()=v2.0 [Arduino:XYZ] Dec 20 2016 15:36:43

Version : v2.0 [Arduino:XYZ] Dec 20 2016 15:36:43

Address : 8192

Pages : 3968

Page Size : 64 bytes

Total Size : 248KB

Planes : 1

Lock Regions : 16

Locked : readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

readWord(addr=0x41004020)=0xffff

none

readWord(addr=0x41004018)=0

Security : false

Boot Flash : true

readWord(addr=0x40000834)=0x7000a

BOD : true

readWord(addr=0x40000834)=0x7000a

BOR : true

Arduino : FAST_CHIP_ERASE

Arduino : FAST_MULTI_PAGE_WRITE

Arduino : CAN_CHECKSUM_MEMORY_BUFFER

Erase flash

chipErase(addr=0x2000)

done in 0.781 seconds

Write 149672 bytes to flash (2339 pages)

write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x2000, size=0x1000)

[ ] 2% (64/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x3000, size=0x1000)

[= ] 5% (128/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x4000, size=0x1000)

[== ] 8% (192/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x5000, size=0x1000)

[=== ] 10% (256/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x6000, size=0x1000)

[==== ] 13% (320/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x7000, size=0x1000)

[==== ] 16% (384/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x8000, size=0x1000)

[===== ] 19% (448/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x9000, size=0x1000)

[====== ] 21% (512/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0xa000, size=0x1000)

[======= ] 24% (576/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0xb000, size=0x1000)

[======== ] 27% (640/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0xc000, size=0x1000)

[========= ] 30% (704/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0xd000, size=0x1000)

[========= ] 32% (768/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0xe000, size=0x1000)

[========== ] 35% (832/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0xf000, size=0x1000)

[=========== ] 38% (896/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x10000, size=0x1000)

[============ ] 41% (960/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x11000, size=0x1000)

[============= ] 43% (1024/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x12000, size=0x1000)

[============= ] 46% (1088/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x13000, size=0x1000)

[============== ] 49% (1152/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x14000, size=0x1000)

[=============== ] 51% (1216/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x15000, size=0x1000)

[================ ] 54% (1280/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x16000, size=0x1000)

[================= ] 57% (1344/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x17000, size=0x1000)

[================== ] 60% (1408/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x18000, size=0x1000)

[================== ] 62% (1472/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x19000, size=0x1000)

[=================== ] 65% (1536/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x1a000, size=0x1000)

[==================== ] 68% (1600/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x1b000, size=0x1000)

[===================== ] 71% (1664/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x1c000, size=0x1000)

[====================== ] 73% (1728/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x1d000, size=0x1000)

[====================== ] 76% (1792/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x1e000, size=0x1000)

[======================= ] 79% (1856/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x1f000, size=0x1000)

[======================== ] 82% (1920/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x20000, size=0x1000)

[========================= ] 84% (1984/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x21000, size=0x1000)

[========================== ] 87% (2048/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x22000, size=0x1000)

[=========================== ] 90% (2112/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x23000, size=0x1000)

[=========================== ] 93% (2176/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x24000, size=0x1000)

[============================ ] 95% (2240/2339 pages)write(addr=0x20005000,size=0x1000)

writeBuffer(scr_addr=0x20005000, dst_addr=0x25000, size=0x1000)

[============================= ] 98% (2304/2339 pages)write(addr=0x20005000,size=0x8c0)

writeBuffer(scr_addr=0x20005000, dst_addr=0x26000, size=0x8c0)

[==============================] 100% (2339/2339 pages)

done in 1.867 seconds

Verify 149672 bytes of flash with checksum.

checksumBuffer(start_addr=0x2000, size=0x1000) = 6e41

checksumBuffer(start_addr=0x3000, size=0x1000) = a983

checksumBuffer(start_addr=0x4000, size=0x1000) = f820

checksumBuffer(start_addr=0x5000, size=0x1000) = 35a6

checksumBuffer(start_addr=0x6000, size=0x1000) = 3e40

checksumBuffer(start_addr=0x7000, size=0x1000) = a4ba

checksumBuffer(start_addr=0x8000, size=0x1000) = 29d4

checksumBuffer(start_addr=0x9000, size=0x1000) = 5a74

checksumBuffer(start_addr=0xa000, size=0x1000) = 5c83

checksumBuffer(start_addr=0xb000, size=0x1000) = d73b

checksumBuffer(start_addr=0xc000, size=0x1000) = 4bca

checksumBuffer(start_addr=0xd000, size=0x1000) = d115

checksumBuffer(start_addr=0xe000, size=0x1000) = 610a

checksumBuffer(start_addr=0xf000, size=0x1000) = 5ad3

checksumBuffer(start_addr=0x10000, size=0x1000) = ade8

checksumBuffer(start_addr=0x11000, size=0x1000) = 6937

checksumBuffer(start_addr=0x12000, size=0x1000) = 1795

checksumBuffer(start_addr=0x13000, size=0x1000) = 4bb4

checksumBuffer(start_addr=0x14000, size=0x1000) = c581

checksumBuffer(start_addr=0x15000, size=0x1000) = 64a2

checksumBuffer(start_addr=0x16000, size=0x1000) = bf36

checksumBuffer(start_addr=0x17000, size=0x1000) = 6b9d

checksumBuffer(start_addr=0x18000, size=0x1000) = c584

checksumBuffer(start_addr=0x19000, size=0x1000) = abd9

checksumBuffer(start_addr=0x1a000, size=0x1000) = e063

checksumBuffer(start_addr=0x1b000, size=0x1000) = 8de5

checksumBuffer(start_addr=0x1c000, size=0x1000) = 65c3

checksumBuffer(start_addr=0x1d000, size=0x1000) = 272b

checksumBuffer(start_addr=0x1e000, size=0x1000) = b440

checksumBuffer(start_addr=0x1f000, size=0x1000) = 1ff8

checksumBuffer(start_addr=0x20000, size=0x1000) = 43c8

checksumBuffer(start_addr=0x21000, size=0x1000) = 8987

checksumBuffer(start_addr=0x22000, size=0x1000) = 31b4

checksumBuffer(start_addr=0x23000, size=0x1000) = 90a9

checksumBuffer(start_addr=0x24000, size=0x1000) = 7d97

checksumBuffer(start_addr=0x25000, size=0x1000) = 8eed

checksumBuffer(start_addr=0x26000, size=0x8a8) = af6a

Verify successful

done in 0.146 seconds

CPU reset.

readWord(addr=0)=0x20007ffc

readWord(addr=0xe000ed00)=0x410cc601

readWord(addr=0x41002018)=0x10010305

writeWord(addr=0xe000ed0c,value=0x5fa0004)

What you gave here are the outputs during the compilation and the upload of the code

What we asked you to provide is the logs, so what the Arduino is printing on the Serial port
(such as "WiFi.status(): ")

Pls open your serial monitor and give us what is written there (wait a few seconds so that the Arduino finished printing everything)

Oh sorry, this is the output:

_crypto.readDeviceId(...) failed.
***** Arduino IoT Cloud - configuration info *****
Device ID: 
MQTT Broker: mqtts-sa.iot.arduino.cc:8883
setup done!
WiFi.status(): 0
Current WiFi Firmware: 19.6.1

Are you sure that your credentials for you WiFi network are good? Since the arduino isn't connectede to your network

Share all your code pls

@matte_fontanaa you need to provision your board before connectin to the ArduinoIoTCloud.

_crypto.readDeviceId(...) failed.

Means that your board is not provisioned (registered) to the cloud, in fact there is no Device ID associated.

Follow this guide to add your board to the ArduinoCloud:

1 Like

well, I had already added the board like you said, but the result is the same, I tried to search some documentation about it and I found the self-provisioning sketch, but I couldn't understand what to put in the secret_ID and secret client_id, can you help me with that?

Do you have something connected to the i2c bus?

You need to create them from here https://cloud.arduino.cc/home/api-keys

no, I just have the raw arduino connected to the PC

ok, thanks. Please be aware that if this error persist you wont be able to connect to ArduinoIoTCloud also using self provisioning. So you may want to investigate why this is happening before trying self provisioning.

Update, I tried to manually connect and this is the output I get. Anyway I tried to check out self-provisioning and it says I have to create an API, which would require me to create a premium account, is that right?

_crypto.readDeviceId(...) failed.
***** Arduino IoT Cloud - configuration info *****
Device ID: 
MQTT Broker: mqtts-sa.iot.arduino.cc:8883
setup done!
WiFi.status(): 3
Current WiFi Firmware: 19.6.1

Can you please try running this sketch to check if there is something wrong with your board crypto?

I don't know about the requirement to create the API keys maybe @dbeamonte_arduino can help

Done, I don't know how this is supposed to work but the output is the following:

The ECC508/ECC608 is not locked!