When using Arduino online sketch that is connected to the cloud, its enough for the sensor to be connected and that I can't connect to cloud and sometimes even can't upload the code.
This is my code:
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);
Serial.println("Lights!");
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
if (!SI1145.Begin()) { // Sunlight Sensor, waits for board to be connected before moving on
Serial.println("Si1145 is not ready!");
delay(1000);
lightReady = false;
}
else {
lightReady = true;
}
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
That sensor uses i2c for communication, which might interfere with the correct functioning of the crypto-chip.
The way I usually solve this is by only initialising the i2c peripherals once the Arduino IoT Cloud is connected successfully
There are callbacks available on the ArduinoCloud object
then you can have 2 functions which will be called when you connect and disconnect from IoT Cloud.
void onIoTConnect() {
// enable your other i2c devices
Serial.println(">>> connected to Arduino IoT Cloud");
if (!SI1145.Begin()) { // Sunlight Sensor, waits for board to be connected before moving on
Serial.println("Si1145 is not ready!");
delay(1000);
lightReady = false;
}
else {
lightReady = true;
}
}
void onIoTDisconnect() {
// disable your other i2c devices
lightReady = false;
}
this should help you out and fix your i2c issues.
Let me know
I'm using this library : "SI114X.h" with seeed sun light sensor module.
The onconnect method didn't work for me at all, is there anything else need to be define? Sometimes I can't even see the serial port prints, and need to upload the new code through bootloader(guess it's stuck on some kind of a loop)
Another thing which is weird that this whole setup (without ONCONNECT method) works fine with another i2c device(sht31).
#include <Wire.h>
#include "SI114X.h"
SI114X SI1145 = SI114X();
#include "thingProperties.h"
bool lightReady = false;
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(5000);
Serial.println("Lights!");
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
ArduinoCloud.addCallback(ArduinoIoTCloudEvent::CONNECT, onIoTConnect);
ArduinoCloud.addCallback(ArduinoIoTCloudEvent::DISCONNECT, onIoTDisconnect);
/*
if (!SI1145.Begin()) { // Sunlight Sensor, waits for board to be connected before moving on
Serial.println("Si1145 is not ready!");
delay(1000);
lightReady = false;
}
else {
lightReady = true;
}
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
if (lightReady) {
light = SI1145.ReadVisible();
Serial.print("Vis: "); Serial.println(light);
delay(500);
}
else {
Serial.print("Light not ready");
delay(1000);
}
}
void onIoTConnect() {
// enable your other i2c devices
Serial.println(">>> connected to Arduino IoT Cloud");
if (!SI1145.Begin()) { // Sunlight Sensor, waits for board to be connected before moving on
Serial.println("Si1145 is not ready!");
delay(1000);
lightReady = false;
}
else {
lightReady = true;
}
}
void onIoTDisconnect() {
// disable your other i2c devices
lightReady = false;
}
Hi,
tried this code, basically it's stuck on connecting, this is what I get in the serial:
Connected to "Mixtiles"
Light not readyArduino IoT Cloud Connection status: CONNECTING
Light not readyArduino IoT Cloud connecting ...
I need to go through the most obvious questions, sorry
have you gone through the Getting Started guided setup for IoT Cloud?
your board might not be provisioned
are you working with the Java IDE or in Create?
if you are using create please share your sketch using the platform by clicking on the 3 dots next to the board name and selecting "share sketch"
I use Nano 33 IoT a lot and it works all the time.
In the past we had some users behind some very restrictive networks and the board could not make calls on certain services.
Please open the Serial Monitor before uploading the sketch and extend the delay() inside setup to 10 seconds to make sure no message is lost.
Once that is starting and you get a few "connecting" messages copy the whole output of the Serial Monitor in your reply.
The text you pasted above are missing the initial messages from the library.
I am very interestedin the output of this particular call, that's why I asked you to put 10 seconds delay after Serial.begin()
ArduinoCloud.printDebugInfo();
also, could you also do setDebugMessageLevel(4) which increases the verbosity?
if you are on windows you could be victim of something very annoying Win does which is re-enumerate the COM ports upon reconnecting of a device.
You could also just manually reset the board when it starts showing text in the serial monitor, or download the Java IDE and try that serial monitor which is usually much quicker at picking up serial data
Ok, I got the log with debug(4)(identical to debug(2):
Lights!
Cryptography processor failure. Make sure you have a compatible board.
***** Arduino IoT Cloud - configuration info *****
Device ID:
Thing ID: 2442462d-1b27-405c-9aef-3895076d0a63
MQTT Broker: mqtts-sa.iot.arduino.cc:8883
WiFi.status(): 0
Current WiFi Firmware: 1.2.3
Connected to "Mixtiles"
Light not readyArduino IoT Cloud Connection status: CONNECTING
Light not readyArduino IoT Cloud connecting ...
Cryptography processor failure. Make sure you have a compatible board.
Getting Started might not have worked properly.
Can you go through that process again?
I'd try these things in order, one at a time:
1: upgrade the NINA firmware (info here https://www.arduino.cc/en/Tutorial/WiFiNINA-FirmwareUpdater)
test
2: comment the import of Adafruit's SHT31 (it's an i2c device and might do something to the i2c bus settings)
test
3: redo the Getting Started for IoT Cloud
test
Thanks
Did the GettingStarted process again successfully.
Uploaded blank sketch and saw it connect to iot cloud and wifi successfuly as well.
NINA firmware:
Failed in the process :
While trying to update version I get :
Error while reading flash memory(connection is ok, happend during verify)
When trying to Check firmware version I get:
Communication with WiFi module failed!
Then went back to iot cloud and got this message :
Arduino IoT Cloud Connection status: IDLE
***** Arduino IoT Cloud - configuration info *****
Device ID: ac0cb8d9-6fb1-4157-8adb-c957abcfd9f3
Thing ID: b57f0045-a2a8-46d9-99d4-3c31a0cec7fc
MQTT Broker: mqtts-sa.iot.arduino.cc:8883
WiFi.status(): 255
WiFi Hardware failure.
Make sure you are using a WiFi enabled board/shield.
Then reset and retry
Now, I get the same message on the getting started as if I don't have a wifi board.
so after reprovisioning you got a successful connection, but then went ahead and tried to update the firmware and got failure...
try replacing the USB cable and attempt the firmware upgrade again.
if you still have issues you might have a faulty board, although to be honest I haven't seen one yet
These Nano boards are so resilient it doesn't make sense.
Also... if the writing of firmware worked fine, it's weird that it broke during verification and then it stopped working.
The ESP32 in the NINA is very simple to upgrade.
Can you make sure your WiFiNINA library is up to date?
Ok, Managed to do NINA firmware update and these are the results:
I did the GettingStarted process from the beginning, uploaded sketch, everything connects and works(with the "blank" arduino iot cloud sketch).
Once connecting the SI114X sensor to i2c(with the same code) I get the error: "Cryptography processor failure. Make sure you have a compatible board."
When disconnecting it everything works fine(no Cryptography error shown).
Logs:
Without SI114X conected:
Arduino IoT Cloud Connection status: IDLE
***** Arduino IoT Cloud - configuration info *****
Device ID: f6e45686-79f2-4e94-b7ab-523aa699633e
Thing ID: e8ecc4de-d098-4607-a0f9-d92ce706adf1
MQTT Broker: mqtts-sa.iot.arduino.cc:8883
WiFi.status(): 0
Current WiFi Firmware: 1.2.4
Connected to "Mixtiles"
Arduino IoT Cloud Connection status: CONNECTING
Arduino IoT Cloud connecting ...
Arduino IoT Cloud Connection status: CONNECTED
With SI114X conected:
Cryptography processor failure. Make sure you have a compatible board.
***** Arduino IoT Cloud - configuration info *****
Device ID:
Thing ID: e8ecc4de-d098-4607-a0f9-d92ce706adf1
MQTT Broker: mqtts-sa.iot.arduino.cc:8883
WiFi.status(): 0
Current WiFi Firmware: 1.2.4
Connected to "Mixtiles"
Arduino IoT Cloud Connection status: CONNECTING
Arduino IoT Cloud connecting ...
The following variables are automatically generated and updated when changes are made to the Thing properties
int light;
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(10000);
// 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
what if you try and comment this line but leave the sensor connected?
SI114X SI1145 = SI114X();
I'm trying to figure out if the sensor does something to the i2c bus in the physical or code realm.
I know for a fact that the crypto-chip has some specific requirements, but up until now I never had problems using my callbacks to enable/disable things after a successful conneciton
ubidefeo:
what if you try and comment this line but leave the sensor connected?
As said, in my last check I ran the initial arduino cloud code without any addiotional code, only with the sensor physically connected. Once I disconnect it there are no problems.
Maybe the IoT cloud awakens the sensor which causes issues afterwards.
I checked the schematic of the Adafruit module and I can't see anything strange.
The pull-up resistors seem a bit high, and it shouldn't be a problem, but when it comes to i2c bus capacitance it can be tricky to troubleshoot modules which have on-board pull-up.
It might very well be what you say, that this sensor is woken up by operations to initiate the ECCx08 crypto-chip.
There might be another solution, which is enabling another i2c port on pins D6 and D5.
I've done that to have a MKRZero with 4 hardware UARTs in a project, but at this very moment I don't have a lot of time to look into it because in 2 hours I'm leaving on holiday.
If you're a bit patient I can look into it tomorrow and provide you with some sample code for that.
I always carry a few arduino boards with me while on holiday so I migth be able to even test it before I send it over
If you want to dig into the amazing world of wiring_secret.h here's some code I used to remap a Serial port using just code
#include <Arduino.h>
#include <wiring_private.h>
#define SERIAL3_RX_LOCAL 3
#define SERIAL3_TX_LOCAL 2
Uart SerialPlayerRight (&sercom0, SERIAL3_RX_LOCAL, SERIAL3_TX_LOCAL, SERCOM_RX_PAD_3, UART_TX_PAD_2); // Create the new UART instance assigning
// Attach the interrupt handler to the SERCOM
void SERCOM0_Handler()
{
//Serial.println("SERCOM0_Handler");
SerialPlayerRight.IrqHandler();
}
of course the above is for UART while you'll have to use PAD_0 and PAD_1.
Sorry if all of the above adds confusion, but I promise I'll look into that as soon as I can get to it
Hi,
Thanks a lot for all the help and effort!
I'm aware of the port changing method, but the problem is I am using a grove nano shield for quick connections, and pins 5 and 6 are separate meaning if I do this i'm missing the whole point.
For that reaason I didn't even try.
Assuming that the sensor does wake up due to crypto chip operation, is there something that can be done or will be done by Arduino?
Thanks
I don't know if we'll address this on our end, especially since our MKR ENV shield which also runs on i2c works well with our boards.
The crypto-chip can be finicky with some i2c peripherals but the workaround I gave you using connect/disconnect callbacks always worked, that's why I'm surprised why this isn't working.
Because I've had some issues using a Grove adapter board in a project (can't remember) I'm wondering if the Grove has some additional logic level translation going on.
The tests you are running are just Nano 33 IoT and SI114x or is the sensor going through the Grove adapter board?
I would try and just connect the Grove sensor to the Nano using jumper wires
That sensor module has a v-reg which might hinder the correct functioning of the sensor when input is 3V3.
I seriously believe that shield can only work with 5V reliably, look at the comment below the product page.
not clear, though