Today we learn how to control stuff using Alexa and an ESP32 and make it work with this
PCB.
We can control anything.
First, let’s check this example.
And this works in any language, just change Alexa settings to your language and when you
add the device, in the Arduino code, just write the name in that language.
For example, this is the same process but in Spanish.
This project works perfectly with my Noobix board from a previous project and this already
has the ESP32, the programming pads, 12V and 5V voltage regulation and a solid state relay
so is ready to turn on and off any device using your voice and Alexa.
So guys, let’s get started.
What’s up my friends welcome back.
To make this project we need an ESP32, a relay or even better, a solid-state relay or SSR
and obviously, we need an Alexa device connected to the internet.
But instead of making connections on a breadboard, if you want a more permanent and compact solution,
just use my Noobix board.
Remember this PCB from a previous IOT project.
Is the same PCB, it also works with Alexa.
So if you want it, just download the GERBER files from below and you can order the PCBs
from PCBWAY.
Remember that I’ve changed the design so it wouldn’t have those small mistakes I’ve
made and now the design has enough clearance and safety features.
Please read all the updates on my website.
Anyway, get the GERBERs and go to PCBWAY.com and click the quote button.
Add the PCB size, the amount of PCB which in this case is just 5, the color, which could
be green or any other color and save to cart.
Here upload the GERBERs you’ve downloaded before and make the order.
Receive the PCBs in just a few days.
They look pretty good, PCBWAY always does a good job.
I won't go over how to assemble it once again, just watch my previous video about the IOT
connection to see what you need and how to assemble it for the 12V converter module,
the SSR relay, the LEDs and the small SMD ESP32.
But before we test the Alexa control on my PCB, let’s make the same connection with
a commercial ESP32 development board, so it would be easier to follow.
This board costs just a few dollars on AliExpress.
So get an ESP32, a normal relay, or even better, a solid state relay like this one, a light
bulb and an Alexa control device.
Make connections from the ESP to the relay like this, connected on GIPO pin 12.
Add the light bulb at the relay output and a power cable at the input but don’t plug
it in just yet.
Now connect a USB cable to the ESP32 and to your PC and let’s see the code.
First, copy this link here and open Arduino IDE.
Then go to file, preferences and in the extra URLs add that link you’ve copied.
Now go to tools, board and open board manager.
Here search for ESP32 and install these boards in case that you don’t have them.
Once installed, if you now go back to boards, you now have this group of ESP32 based boards.
Select the ESP32 Dev Module and make sure you have these configurations.
Now we could upload codes to the ESP32 board.
Now let’s check the Alexa code.
For that, go into sketch, libraries and open the manager.
Here search for fauxmo.
Install this library that will do everything for us.
Once installed, go to examples and open this example file.
Go to credentials, copy these two lines, go back to the code, delete the credential library
import and paste those two lines of code.
Now add your wifi name and password.
Here we define the Alexa devices we want to create.
By default it creates 4 different devices controlled on these pins.
For this example I only want one, so I delete all devices except the yellow one.
For the yellow pin I select GPIO 12 but you could select any other pin if you want.
I use pin 12 because that’s the one I’ve used on my Noobix board to control the relay,
as you can see there on the schematic.
Next, in the code for the yellow ID I change the name to workshop light.
This is the word you will have to say later in order to activate it, so make sure you
select good words.
Scroll down and since I’ve deleted the other IDs, we also need to delete the pin modes
and digital writes and only leave the yellow one.
Scroll even more and here, in the if/else detection, delete the other devices and only
leave the yellow one.
Now compile and upload the code to the ESP32 board.
Now the ESP will automatically connect to the WIFI name you’ve placed in the code.
So go ahead and open the Alexa App on your smartphone.
Go to devices and click the plus icon.
In my case I select a light control.
It doesn’t have a brand so scroll down and select other.
As connection, select WIFI and then Alexa will discover devices.
After a few seconds, it detected the workshop light so I click the add device button.
There you go, as you can see, the workshop light is now on my devices list.
If I press the on button, the relay connected on pin 12 will turn on.
Also, I can say the command to Alexa and it will also turn on or off the relay, look.
That’s how easy is to control an IOT device with Alexa and an Arduino code.
But is more.
In the code we have this value variable which will give us the light brightness.
So instead of digital write I now change the code to an analog write using this function
for the ESP.
I upload the code and make the same process but with an LED instead of a relay.
But now look, I can control the LED brightness from the Alexa app.
I can also say the command.
And I
can do the same with my NOOBIX PCB.
Check my previous tutorial and see how to assemble the PCB.
Connect an FTDI module to the SPI pads on the back like this.
Now connect the FTDI programmer to your PCB.
Select the COM and upload the code.
Now I power the NOOBIX board from 220V with a power cable and add a 220V light bulb as
an output load.
Be careful working with high voltage and never touch the PCB when is powered on.
I go to the Alexa app and add the new device with the same name of “workshop light”.
Now I can control the light bulb like this.
That’s how easy is to use the NOOBIX board and control anything with Alexa.
A fan, a light, your TV, an alarm, a motor, an LED strip or anything else.
Because, once you get the data on the Arduino code, the rest is just Arduino code so you
could add servo motors, displays, color LEDs, measuring devices such as temperature sensor,
humidity sensor, movement sensor sand so on.
Such a nice and easy project to play with.
So get my PCB from below and order it at PCBWAY if you want to make the same project.
You have the code and more information below on electronoobs.com.
Thanks again and see you later guys.