- Story
- Setup
Step 01
- Turn on an LEDStep 02
- LED flashStep 03
- Connect to WI-FIStep 04
- SetUp AdafruitStep 05
- SetUp IFTTTStep 06
- Let's go codeStep 07
- Turn ON and turn OFF- 🎉 Congratulation !
- Authors
In an increasingly connected world, we are going to use your voice assistant to turn on the led of your esp32. To do this you will need to connect to a wifi network and use Adafruit and IFTTT.
- SETUP your dev environnement
- Create your account on:
🛠️ Required Hardware:
- ESP32
- USB cable
Your first objective is to light an LED on your ESP32 with code.
Use the LED on your card or an external LED and turn it on.
🛠️ Required Hardware:
- ESP32
- USB cable
Now it's time to make your LED blink.
To do this, implement some code in your ESP32.
Your LED must blink with 500 ms.
🛠️ Required Hardware:
- ESP32
- USB cable
You'll probably need to get on your phone's 4G! So make a connection share and connect via your board.
- Create a const variable
WIFI_SSID
- Create a const variable
WIFI_PASS
- In
setup
of your programs, start the wifi connection- As long as you are not connected you should print in the
serial monitor
'>' - When you are connected print "OK!"
- As long as you are not connected you should print in the
- Print
ip
of your board inserial monitor
🛠️ Required Hardware:
- Your Computer
Adafruit IO is one such cloud provider focusing more on IoT deployments on the cloud.
Adafruit IO supports different hardware like Raspberry PI, ESP2866, and Arduino.
- Go on Adafruit for create your first
Feed
.- Here, feeds are the core of the Adafruit IO system. The feed holds metadata about the data you push to Adafruit IO
- Create new Feed named
on_off
.- In the
on_off
feed you will have a summary of what has been sent, so always keep the page open :)
- In the
🛠️ Required Hardware:
- Your Computer
IFTTT is shorthand for If This Then That; it's an automation tool for connecting more than 650 apps and services.
- Go on IFTTT for create your first
Applet
.- Here, you will create an applet that will link your voice assistant and Adafruit (that we have set in the previous step)
- Create new Applet.
- The eternal choice between IOS and Android !
- If you have an Android this step will be much easier in the
"If this"
add"Google assistant"
and fill in the fields. - If you have an iPhone follow this link to use
siri
.
- If you have an Android this step will be much easier in the
- In the
"Then That"
addAdafruit
and fill in the fields as follows:- Feed Name: on_off
- Data to save: on
🛠️ Required Hardware:
- ESP32
Now that all the setups are done we are going to code the program allowing to subscribe to the on_off
topic and to read the data that is published there.
- Create a variable: MQTT_SERV which value is
"io.adafruit.com"
- Create a variable: MQTT_PORT which value is
1883
- Create a variable: MQTT_NAME and MQTT_ACTIVE_KEY
- Know the value in Adafruit in the section
My Key
- Know the value in Adafruit in the section
- Create connection in Adafruit MQTT-API
- Subscribe to the
feed
you created above. - Now you just have to read what happens on this feed and turn on and off the led according to what is sent.
Currently you only send "on" thanks to your voice assistant now it would be nice to send "off" right?
- Create a new
Applet
which will send off to theon_off
feed.
Use your voice assistant and turn your LED on and off !
You now know the basics of MQTT ESP32. Feel free to use your imagination to impletement IoT Communcation. Or combine the previous exercises for new results.
Coline SEGURET |
---|
🚀 Don't hesitate to follow us on our different networks, and put a star 🌟 on
PoC's
repositories.