Alexa not communicating with device via voice interaction

I have a Nano 33 IOT with 4 magnetic switches attached. My program on the Arduino cloud works great, flawless. I have the switches set up to change the value of some correlating Alexa compatible Contact sensor variables. But now that I try to integrate it into Alexa, it works in the app, I can view the status of the motion sensor variables. However, I cannot ask Alexa the status. She responds with “one or more motion sensors are not responding”. I have them in a group. I have the Arduino skill installed on the app. Does anybody know a work around? I just want to have a routine where Alexa checks the status of the variables every hour.

Please post code and wiring.

I don’t have a wiring diagram but its just directly connected to non-pwm pins. I don’t think you would need the wiring as the device and code works well, just the communication via voice on Alexa seems not to be working with the variables. Code is attached.

WaterTankMonitor.txt (2.59 KB)

Please read the topics like "How to use the Forum", especially how to post code. Many helpers don't want to fill up their computers, tablets or phones with such files.

// ezButton - Version: Latest 
#include <ezButton.h>

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/0e5a32d1-9ff9-41d2-a37d-23c8be6147ae 

  Arduino IoT Cloud Variables description

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

  CloudContactSensor full;
  CloudContactSensor half;
  CloudContactSensor quarter;
  CloudContactSensor threeQuarter;
  int waterLevel;

  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"

ezButton LevelQ(4);
ezButton LevelH(7);
ezButton LevelTQ(8);
ezButton LevelF(14);

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); 

  // 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();
  
  LevelQ.setDebounceTime(50);
  LevelH.setDebounceTime(50);
  LevelTQ.setDebounceTime(50);
  LevelF.setDebounceTime(50);
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  
  LevelQ.loop();
  LevelH.loop();
  LevelTQ.loop();
  LevelF.loop();
  
  int Q = LevelQ.getState();
  int H = LevelH.getState();
  int TQ = LevelTQ.getState();
  int F = LevelF.getState();
  
  
  if (F==false){
    waterLevel = 4;
    full = true;
    threeQuarter = false;
    half = false;
    quarter = false;
  }
  else if (TQ==false){
    waterLevel = 3;
    full = false;
    threeQuarter = true;
    half = false;
    quarter = false;
  }
  else if (H==false){
    waterLevel = 2;
    full = false;
    threeQuarter = false;
    half = true;
    quarter = false;
  }
  else if (Q==false){
    waterLevel = 1;
    full = false;
    threeQuarter = false;
    half = false;
    quarter = true;
  }
  else if (Q==true){
    waterLevel = 0;
    full = false;
    threeQuarter = false;
    half = false;
    quarter = false;
  }

}

Railroader:
Please read the topics like “How to use the Forum”, especially how to post code. Many helpers don’t want to fill up their computers, tablets or phones with such files.

Sorry, new to the forum. Here’s the proper version.

How are the variables set in loop connected to the Cloud?

  ArduinoCloud.update();

I would expect a pointer to a structure here.

Railroader:
How are the variables set in loop connected to the Cloud?

  ArduinoCloud.update();

I would expect a pointer to a structure here.

Honestly, I think the arduino cloud handled that part. I just put the variable I wanted the cloud to monitor into the website and coded the rest using those variables in there. I assume it's tied somehow because on my arduino cloud dashboard I can send and receive values over the network. If there is something that I should add, best practice or something like that, let me know. I'm learning still.

I'm not familiar at all with the environment You use and can't pinpoint anything. Poking around in unknown systems for many years has given me some kind of idea generator.

The class... ezbutton is connexted to the loop variables but how is ezbutton connected to "Cloud"?

Railroader:
I'm not familiar at all with the environment You use and can't pinpoint anything. Poking around in unknown systems for many years has given me some kind of idea generator.

The class... ezbutton is connexted to the loop variables but how is ezbutton connected to "Cloud"?

I can explain the ezbutton part. I use that library so that I can connect my magnetic switches without any sort of external resistors and electronics, just the switch directly connected between a pin and ground. The ezbutton part I would say operates entirely locally on the board and I use the if statements to take the ezbutton values and translate to/ update the cloud variables that the arduino cloud put in the code for me.

Fine. Ezbuttons owns the variables You set in loop but they looks like unknown to Cloud. I see no way Cloud can know about them.

jpacampbell:
However, I cannot ask Alexa the status. She responds with "one or more motion sensors are not responding". I have them in a group. I have the Arduino skill installed on the app. Does anybody know a work around? I just want to have a routine where Alexa checks the status of the variables every hour.

I was ready to tell you that you need a skill for Alexa to interface with, then I read your question again.

Wow. I did not know that there was an Arduino Amazon Alexa skill. I have been struggling to understand the Alexa Skill Builder and Alexa Gadgets and often just give up.

I don't have an answer for you, but I am excited to explore the Arduino Amazon Alexa skill. Watch this space.