The following is the content of an article:
Controlling Micro-Controller Output with Alexa
If you own an Amazon Fire tablet like me or one of the other Amazon devices that are not definitely not surveillance gadgets, then you might be familiar with Alexa. It's an intelligent personal assistant developed by Amazon, which you can interact with verbally to set a timer, hear a funny joke, or control home automation.
In this video, I will present you a simple way on how to control a micro-controller output with Alexa. This allows us, for example, to verbally turn on/off the lights and a corridor.
First things first, we need a microcontroller. I went with the popular ESP8266 since it offers Wi-Fi and is supported by the Arduino IDE once we install its library through the boards manager.
Additionally, we need an electrically controllable switch which should be some kind of relay because I want to let us switch mains voltage with it. While we are at it, we should probably add a voltage regulator circuit for the microcontroller and a transistor will flyback diode for the relay. But before I overcomplicate this project too much. Let's rather order one of those ESP8266 Relay Board. It got everything we need for those projects.
A voltage regulation circuit, A Relay with transistor and diodes as well as slots between its high voltage traces PCB terminals and even an Optocoupler Input as a bonus. If you want more details about the board then definitely check out microcontroller experiments article about it which offers tons of useful information.
For our application though. We only need to know the GPIO pin four of the esp8266 Is connected to the base of the relay transistor. Which means by pulling it high it activates the relay and by pulling it low it deactivates the relay. Which is also indicated by an onboard led. This way the change over contact of the relay which are connected to the upper three PCB terminals can be used to connect our appliance to mains voltage.
To reprogram the microcontroller though. I sold at male headers to all the five solder pads in the down left corner of the PCB then I grabbed a USB to serial converter set to 3.3 volts and Connected its TX pin to RX, RX to TX and ground to ground. Afterwards, I shorted the lower two pins with a jumper and connected the boards to a power supply set to at least 7 volts.
With that been done it was time to program. Since I'm terrible at that. I rather try to utilize the FouxmoESP codes. Which basically emulates a Belkin WeMo device and thus lets you control the ESP8266 through Alexa so after editing the provided example codes Choosing the right upload options and uploading the codes.
I then remove the jumper, restart the boards, and realize that no matter how often I search for the device with the alexa software it never found it. There seems to be lots of problems with incompatible libraries in alexa updates. So I ditched that idea and instead went with a bulletproof method provided by Kakopappao papa.
Firstly I had to create an account on Sinric, which is an IOT site that can connect all kinds of boards with Alexa. Then I added a smart home device to my system.
I still hope that this example gave you lots of ideas on how to utilize Alexa and an esp8266 in order to control all kinds of things, but please handle mains voltage with care.
As always thanks for watching. If you enjoyed the video then don't forget to Like share and subscribe Stay creative and I will see you next time
WEBVTTKind: captionsLanguage: enIf you own an Amazon fire tablet like me or one of the other Amazon definitely not surveillance gadgetsThen you might be familiar wolf Alexa. It is an intelligent personal assistantDeveloped by Amazon which you can interact with verbally to, for example, set a timer or hear a funny jokeOf course, there are more useful functions that Alexa can handle for example home automationSo in this video, I will present you a simple way on how to control a micro-controller output with AlexaWhich allows us, for example, to verbally turn on/off the lights and a corridorLet's get started!This video is sponsored by JLC PCBupload, your Gerber files to other high quality PCBs for insanely low prices and turn your designs into real boards to make yourprojects look more professionalThe first thing we need for the small project is obviously a microcontroller.I went with the popular ESP8266Since it offers Wi-Fi and is supported by the Arduino IDE once we install its library through the boards managerAdditionally, we need an electrically controllable switchwhich should be some kind of relay because I want to let us switch mains voltage with itand while we are at it, we should probably add a voltage regulator circuit for the microcontrollerand a transistor will flyback diode for the relayBut before I overcomplicate this project too much. Let's rather order one of thoseESP8266 Relay Boardit got everything we need for those projects. A voltage regulation circuit,A Relay with transistor and diodes as well as slots between its high voltage tracesPCB terminals and even an Optocoupler Input as a bonus. If you want more details about the boardThen definitely check out microcontroller experiments article about it which offers tons of useful informationFor our application though. We only need to know the GPIO pin four of the esp8266Is connected to the base of the relay transistorWhich means by pulling it high it activates the relay and by pulling it low it deactivates the relayWhich is also indicated by an onboard ledThis way the change over contact of the relay which are connected to the upper three PCB terminalsCan be used to connect our appliance to mains voltageTo reprogram the microcontroller though. I sold at male headers to all the five solder pads in the down left corner of the PCBthen I grabbed a USB to serial converter set to 3.3 volts andConnected its TX pin to RX, RX to TX and ground to groundAfterwards, I shorted the lower two pins with a jumper and connected the boards to a power supply set to at least 7 voltsWith that been done it was time to programBut since I'm terrible at that, I rather try to utilize the FouxmoESP codesWhich basically emulates a Belkin WeMo device and thus lets you control the ESP8266through Alexaso after editing the provided example codesChoosing the right upload options and uploading the codes. I then remove the jumperRestart the boards and realize that no matter how often I search for the device with the alexa software it never found itThere seems to be lots of problems with incompatible libraries in alexa updatesSo I ditched that idea and instead went with a bulletproof method provided by Kakopappao papaFirstly I had to create an account on Sinric, which is an IOT site that can connect all kinds of boards with AlexaThen I added a smart home deviceWhich I will call lights and continued by downloading the example Sinric ESP8266 code from GithubAfter unpacking, I opened the switch example and downloaded/included the two libraries which were mentioned in the codesafterwards, I added my Wi-Fi information along with the API key for my Sinric account as well as the API key formy light switch to the codesHere I can now tell the microcontroller what to do when the device is been turned on or turned offwhich is in my case a simple digitalWrite function andWith that being doneI uploaded this new code to the boards, added the Sinric skill to Alexa and search for new devicesWhich this time was successfulAt this point the voice control of the microcontroller should work without any problemsAlexa turnon the lights(Clicks) OkayAlexa turn off the lights(Clicks) OkayThat means we could now hook up a lamp or something similar to the relay and call it a dayBut I wanted to present you a more practical example of home automation with AlexaAs you might know when it comes to switching on your lights then we got a pretty straightforward electrical installationWe usually start in the distribution box where we got our fusewith the protection in place the wire then goes to a switch andAfterwards to the lights before it returns to the distribution box in order to complete the circuitSo the place where we would need to add our Alexa relay is in parallel to the light switchWhich is certainly not an easy and appropriate real life solutionThe good news though is that I got one light circuit that is different because it utilizes push button and a surge relayWhich like the name implies is a relay that either closes/opens its contacts when other there's a current surgeThis way we can add the microcontroller with relay right next to it in the distribution box and utilize the given hat rail assemblySo I reprogrammed my microcontroller in a way that it only activates the relay for half seconds to simulate the current surgeMounted the board inside a hat rail compatible enclosure and added at 24 volts hat rail power supply to the mixAfterwards, I added the parts to my distribution box and wired them upBut I will not go into detail hereBecause if you plan to add something like this to your own house wiring then you should always consult an expertotherwise, you could kill yourself through mains voltage or burn your house downAnd once my wiring was complete it was time for another testAlexa turnthe lights on(Clicks) OkayAlexa turn the lights off(Clicks) OkayAs you might have noticed this system works flawlesslyBut since I'm not such a big home automation enthusiast, I rather remove the system from my distribution boxBut I still hope that this example gave you lots of ideas on how to utilize Alexa and an esp8266in order to control all kinds of things, but please handle mains voltage with care.As always thanks for watching. If you enjoyed the video, then don't forget to Like share and subscribeStay creative and I will see you next time