Adding Amazon Alexa, I2C and NTP together in an ESP32
I have come across 3 pieces of ESP32 Code that I have tried to merge into one piece of code to put onto one ESP32 to combine all these features.
This would allow me to connect a head of line Micro:bit to the ESP32 that has this combined code in. The head of line Micro:bit communicates with a Mesh of Micro:bits, allowing for information to be exchanged up and down/to and from the Micro:bits to Alexa.
I have experimented with the Micro:bit Mesh, and this sort of works. But I cannot get the 3 ESP32 functions to work together.
Has anyone else tried anything like this? Or could someone suggest a way for me to merge the 3 ESP32 functions to work together?
Or could these 3 features be wrapped together into MicroBlocks so that I could experiment with them. I can program in Blocks, but not in Arduino…
The 3 ESP32 codes are;
Alexa
https://github.com/Aircoookie/Espalexa
NTP
https://github.com/arduino-libraries/NTPClient
I2C
https://github.com/espressif/arduino-esp32/tree/master/libraries/Wire
Comments (8)
-
repo owner -
repo owner - changed status to open
-
mBlocks has support for WebThings.io. https://wiki.microblocks.fun/en/microblocks_webthings As a https://webthings.io/gateway/ has its own value, there are integration options for Alexa. https://github.com/bwssytems/ha-bridge/wiki/Basic-concept
BTW, piggybacking the Philips Hue Light Bulb protocol (as Espalexa does) should be doable with the uBlocks built-in functions (if UDP blocks support receiving the broadcast).
-
repo owner Thanks, Dariusz. It would be cool (and pretty easy) the WebThings protocol could be used to interface to Alexa.
The UDP blocks do support both sending and receiving UDP broadcasts. Do you have a good reference for the Philips Hue Light Bulb protocol? Didn't realize that it used UDP.
-
It's a speculation based on the minimal, plain Arduino, emulation of the Belkin device https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/blob/master/sinric.ino
The EspAlexa uses slightly different XML to emulate Philips Hue https://github.com/Aircoookie/Espalexa/blob/main/src/Espalexa.h but the general concept seems to be the same.
The discovery phase uses UDP broadcast, then plain HTTP.
I have no Alexa device and have not convinced myself, yet, that I need one ;), so can't test this concept.
-
repo owner Thanks for the info.
In short, someone could probably get MicroBlocks do something similar to what EspAlexa does using a combination of UDP, HTTP, and custom generated XML.
This would big a big project and would involve digging into several of the underlying protocols and standards, but it could be a fun challenge. The great thing is that you couldn't need to write any C code to explore!
If I were doing this, I'd try to find the simplest thing to control -- say, the brightness of a Phillips Hue bulb. I'd first figure out how to control the bulb from MicroBlocks, then I'd figure out how to get Alexa to talk to MicroBlocks via HTTP. Even the first part -- controlling a bulb from MicroBlocks -- would be really fun.
-
repo owner I'm going to mark this as resolved, but let please let me know if you manage to interface MicroBlocks to Alexa.
-
repo owner - changed status to resolved
- Log in to comment
Unfortunately, the only way to add new Arduino libraries to MicroBlocks is to write some C code "primitive functions" to interface between MicroBlocks and the library -- or to find someone to help you with that.
Note that the Wire library is already useable from MicroBlocks via the i2c blocks in the (advanced) Comm category. There is also an example of using MicroBlocks to pull the time from an HTTP server in the Network example folder ("Online clock example").
The ESP Alexa library is a very special case and the author warns that the API is not yet stable, I don't plan to add that library to the official MicroBlocks but, as you now know, it's not difficult to build your own variation of the MicroBlocks virtual machine.
Perhaps someone in the MicroBlocks community who knows C could help. You might post a request on our Discord server (link in footer of MicroBlocks website).