My Friends,
Toying around with Voice to Environment Control, the ESP32 and Alexa, is very easy to get some things going!
I have been using the Library: ESPAlexa
The example is clear and precise:
Espalexa is designed to be as simple to use as possible.
First, you'll need a global object declaration and a prototype for the function that Espalexa will call when the device is changed:
#include <Espalexa.h> void firstDeviceChanged(uint8_t brightness); Espalexa espalexa;
You then want to actually add the callback function (one for each device)
void firstDeviceChanged(uint8_t brightness) { //brightness parameter contains the new device state (0ff,255n,1-254immed) //do what you'd like to happen here (e.g. control an LED) }
In your setup function, after you connected to WiFi, you'd want to add your devices:
espalexa.addDevice("Alexa name of the device", firstDeviceChanged);
The first parameter of the function is a string with the invocation name, the second is the name of your callback function (the one Espalexa will call when the state of the device was changed) You may also add a third
uint8_t
parameter that will specify the default brightness at boot.Below the device definition in setup, add:
espalexa.begin();
Finally, in the loop() function, add:
espalexa.loop();
And that's it!
Ref: ESPAlexa
Very cool and very easy! Simple coding and simple examples to follow!
The ESP32 is a really nice, reasonable well priced Microcontroller!
Small and powerful!
Here is a very good video, showing you hoe easy this is:
Although there are some limitations here, it appears some of these limitations may be by design, from a security point of view from Alexa programming side.
Best Wishes,
Chris