Hi
I am quite new to Arduino, so my terminology / understanding may be a bit off. Nevertheless, I have been working on project that uses Alexa to communicate an Arduino Nano 33 IoT, which then sends some instructions through a logic level converter to an Arduino Nano over I2C. I have attached a pdf of my schematic below.
The project seemed to work as expected when I had prototyped it on my breadboard, but when I soldered everything together, my Nano 33 had trouble connecting to Cloud. After some research, I believe I am running into a problem similar to the one described here:
https://forum.arduino.cc/index.php?topic=606191.0
The problem seems to be the connection between the SDA / SCL of my two Arduinos are interfering with the ability of my Nano 33 to connect to cloud. Following the solution of the above linked forum post, I modified my code to include ArduinoCloud callbacks, but they didn't fix the issue. Also, when I pull up the serial monitor, my Nano 33 freezes.
Here is the code I am running on my Nano 33:
#include "arduino_secrets.h"
#include "thingProperties.h"
#include <Wire.h>
#define DEVICE_NUM 4 // Transmission device id, i have defined the regular nano as device #4
bool wireInit = true;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
delay(2000);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
ArduinoCloud.addCallback(ArduinoIoTCloudEvent::CONNECT, onConnect);
ArduinoCloud.addCallback(ArduinoIoTCloudEvent::DISCONNECT, onDisconnect);
/*
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();
}
void onLightColorChange() { // Callback from event recieved by alexa on light strip status changed
if (wireInit) {
Serial.println("Color Change Recieved from Alexa");
Wire.beginTransmission(DEVICE_NUM);
Wire.write((byte)0x00); // Write event byte
Wire.write((byte)lightColor.getSwitch());
if (lightColor.getSwitch()) { // If the light strip is on
byte r, g, b;
lightColor.getValue().getRGB(r, g, b); // Get the rgb vals
Wire.write(r);
Wire.write(g);
Wire.write(b);
Wire.write((byte)lightColor.getBrightness());
}
int _error = Wire.endTransmission();
if (_error != 0) {
Serial.print("Error: ");
Serial.println(_error);
}
delay(50);
}
}
void onFadeChange() { // Represented as a "Smart Switch", Boolean
if (wireInit) {
Serial.println("Fade Change Recieved from Alexa");
Wire.beginTransmission(DEVICE_NUM);
Wire.write(1); // Write event byte
Wire.write(fade);
Wire.endTransmission();
delay(50);
}
}
void onConnect(){
Wire.begin();
wireInit = true;
Serial.println("Board successfully connected to Arduino IoT Cloud");
}
void onDisconnect() {
wireInit = false;
}
So far, my work around is to disconnect the logic level converter, wait for the Nano 33 to connect to the cloud, then reconnect the level converter, which results in everything working as expected. The ideal solution would be something that doesn't require me to do this every time.
Does any one know of a solution? Any help is appreciated!
schematic.pdf (33.5 KB)