I am trying to make a solar controlled light that can be enabled and disabled using Alexa. I have an Arduino Nano 33 IoT, connected to the same network as Alexa and an Alexa compatible variable (CloudLight). Whenever I enable the Alexa skill, it does not discover any devices.
Code:
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/86c5cf06-5fb0-4a6b-89a4-65109a20f86c
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
CloudLight solarLight;
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 lightLevel;
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
pinMode(9, OUTPUT);
delay(1500);
// 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
lightLevel = analogRead(1); //Reads light level
while(solarLight == true){
if (lightLevel < 550) { //if low light, turn light on
digitalWrite(9, HIGH);
delay(2000);// prevents flashing light
} else {
digitalWrite(9, LOW);
}
}
if(solarLight == false){
digitalWrite(9, LOW);
}
}