Alexa device discovery not working

I have a thing defined with an int variable and my device is online and functioning beautifully. I have added the Arduino skill to Alexa but the device discovery is not working at all. There doesn't appear to be any troubleshooting guidance on how to isolate and resolve this issue. Is the service functioning properly, or is there something I need to validate on my end? I don't see any settings or status for Alexa integration in the cloud portal.

Hi @shanmcarthur .

Thanks for sharing your issue.
In order to help you, can you please share more information about your setup, sketch and variable types?

Please, make sure that the variables you are using are Alexa compatible. You can check the full list in the IoT Cloud variables document.

I guess that you have already checked the official Alexa & Arduino IoT Cloud Integration doc, but adding it just in case.

It is simple. I took the blinker sample app, and added a single integer to use as a blink delay. I have a single int seconds; in my thinproperties.h, and a single variable in my cloud device. The device is online and working properly. I just can't get Alexa to discover it. The way it should work is that I add the Arduino skill, I connect it to my account, then when it goes through discovery I would assume that Alexa calls the arduino apis using my account and enumerates the devices. This is where it is failing. This has nothing to do with my sketch - my device is operational and my dashboard now shows the device online and I can manage that variable. Alexa should be able to discover the device. There isn't any Alexa config experience I can see anywhere in the product for me to tinker with it, nor is there any status or diagnostic tools to help.

The variable description is:
Declaration int seconds
Type Integer number
Variable Permission Read & Write
Send Values On change threshold: 0

When I look at the variable types and select "alexa compatible", the variable type of Integer number is allowed. This is not an instance of an incompatible variable type. I have no other variables anywhere else.

Thanks,
Shan

Thanks for your detailed reply.

Could you please share the sketch anyway? I will try the sketch myself to see where it's failing.

Thanks!

The sketch should not matter - the issue is in Alexa discovering a device and parameters in my Arduino Cloud subscription. But here is the sketch anyways.

Alexa_Blinker.zip (85 KB)

Thanks for sharing the sketch.

Taking a look at the sketch, I see that it is not an "IoT Cloud sketch", as it doesn't include the thingProperties.h header file, the init functions, the ArduinoCloud.update() function in the loop() or the callback functions at the end. So that sketch will not work with the IoT Cloud or Alexa.

My suggestion would be:

  1. Add the Device (skip if you have already done that)
  2. Create the Thing (I would repeat this step anyway)
  3. Associate it to the device and configure the WIFI
  4. Create your variable(s)
  5. Go to the Sketch section of the Thing
  6. Copy/paste your init code in the setup() function
  7. Copy/paste your code in the loop() function after // Your code here

To be able to help you, I would like to understand the goal of what you are trying to do, as I don't see direct correlation in your sketch about how it is going to interact with the IoT Cloud (and so, with Alexa). So here there are a couple of additional questions:

  • The int variable that you have defined, what's the purpose of it? Is it the blink period? Have you created a dashboard to modify it?
  • How do you want to use Alexa? Do you want to change that int variable or do you want to act over the blink? (for instance, enabling/disabling it)

Sorry I provided the wrong sketch - I am not accustomed to using the online system. I don't see the point of looking at my sketch - my device is working fine and I can control it from the dashboard using that variable. The issue is that Alexa is not discovering the device despite me linking the skill to my cloud account.

I have added the device, I have created the thing. I have created a variable (integer). I have built a sketch that connects my physical device to my wifi and reads from that variable. I have added the thing to a dashboard and dragged the variable onto it. My sketch uses the integer for a blink interval and I can confirm that changing this number immediately changes the blink rate as appropriate on the device. The device-to-wifi-and arduino cloud is working flawlessly. What is failing is in Alexa world. I have added the Arduino skill and connected it to my account. It then fails to discover any devices. That is where I am stuck.

My goal is to learn this so I can build real devices. I am starting with a simple device that blinks the LED. Once I get this working fully, then I will build a much more complex device.

Attaching the active sketch source code:

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/4871972e-ba92-4e4c-8242-bc0faacae374 

  Arduino IoT Cloud Variables description

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

  int seconds;

  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"

// constants won't change. Used here to set a pin number:
const int ledPin = LED_BUILTIN;  // the number of the LED pin

// Variables will change:
int ledState = LOW;  // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;  // will store last time LED was updated

// constants won't change:
const long interval = 750;  // interval at which to blink (milliseconds)


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 ("Starting device");
  
  // Defined in thingProperties.h
  initProperties();

  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);

  // 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() 
{
  Serial.println ("cloud updating");
  ArduinoCloud.update();
  
  Serial.println ("updated");
  // Your code here 
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= seconds * 100) 
  {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
      Serial.println("On");
    } else {
      ledState = LOW;
      Serial.println("Off");
    }

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
}

/*
  Since Seconds is READ_WRITE variable, onSecondsChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onSecondsChange()  {
  // Add your code here to act upon Seconds change
}


Thanks again for sharing your sketch!

The issue is that the int variable type is not compatible with Alexa. You can find the full list of Alexa-compatible variable types here.

As you can see, there is no direct Integer variable type, so you should use one of the existing ones. For instance, the most straighforward workaround would be to use the DimmedLight type.

So you have to declare your variable as DimmedLight and you can get two values from that variable:

  • Brightness (float: 0-100) --> xxxx.getBrightness()
  • State (bool) --> xxxx.getSwitch()

I have just tested it with Alexa and it works.

I hope this helps!

That was very helpful. Thanks. When I picked the variable type I clicked on the Alexa compatibility option and assumed that since I picked it, it was a filter. I didn't realize that the non-alexa-compatible variables would be presented too. When I add a variable now and ONLY pick Alexa compatibility, and ensure that Basic types are not selected, I see that integer is not included and I only see values that feel like would be natively supported in Alexa. Thanks for pointing out that the variable type was not supported. I think there is some opportunity in the Alexa integration documentation to highlight the importance of picking the right variable types and highlighting the ones that are available for Alexa.

1 Like

Yes. Thanks for your feedback.

We will try to improve the documentation so that it is clearer.

I am having same issue but I am trying to move a servo to control a window blinds tilt function. Not sure I could use the Dimming function sense it's float value is from 0-100 but the servo needs to be able to move to 180. any help here would be appreciated. Once I have 1 working I will need to build 16 more.

Hi! You can do the calculation and use the dimming function as a percentage and convert the number to your real scale in the sketch.

Hello, I’m also have the same issue but I use bolean type, and mi Alexa didn’t find my devices, can you help me?

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/e9436291-fabf-4bb5-b6d3-f32941eb9b39 

  Arduino IoT Cloud Variables description

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

  bool iluminacion;
  bool ventilacion;
  bool ventilacionExtra;

  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"
#define R1 32
#define R2 33
#define R3 27
#define R4 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();
  pinMode(R1, OUTPUT);
  pinMode(R2, OUTPUT);
  pinMode(R3, OUTPUT);
  pinMode(R4, OUTPUT);
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  
  
}


/*
  Since Iluminacion is READ_WRITE variable, onIluminacionChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onIluminacionChange()  {
  // Add your code here to act upon Iluminacion change
if (iluminacion){
    digitalWrite(R1, LOW);
    digitalWrite(R2, LOW);
  } else {
    digitalWrite(R1, HIGH);
    digitalWrite(R2, HIGH);
  }
  
}

/*
  Since Ventilacion is READ_WRITE variable, onVentilacionChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onVentilacionChange()  {
  // Add your code here to act upon Ventilacion change
  if (ventilacion){
    digitalWrite(R3, LOW);
  } else {
    digitalWrite(R3, HIGH);
  }
}

/*
  Since VentilacionExtra is READ_WRITE variable, onVentilacionExtraChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onVentilacionExtraChange()  {
  // Add your code here to act upon VentilacionExtra change
    if (ventilacionExtra){
    digitalWrite(R4, LOW);
  } else {
    digitalWrite(R4, HIGH);
  }
}

Hi! Sure!
Your issue is that bool variable types is not supported by Alexa integration.
You should use any of the variables listed in this page instead: https://docs.arduino.cc/arduino-cloud/getting-started/cloud-variables#alexa-variables

In your case, you should use the type Switch.

Let us know if that helps.

Thank you for the tip about using ONLY Alexa compatible types. i changed int to CloudSwitch and Alexa discovered it! i was a bit surprised that the UI would allow me to select both Basic Types and Alexa Compatible types. If Alexa doesn't work with Basic Types, then i guess clicking Alexa Compatible should unclick Basic Types. Thanks!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.