Skip to content

Latest commit

 

History

History
223 lines (159 loc) · 7.62 KB

File metadata and controls

223 lines (159 loc) · 7.62 KB

MQTT with Vocal Assistant

Summary

Story

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.

Data scheme

Setup

Step 01 - Turn on an LED

🛠️ Required Hardware:
  • ESP32
  • USB cable

📑 Description:

Your first objective is to light an LED on your ESP32 with code.

📌 Tasks:

Use the LED on your card or an external LED and turn it on.

📚 Documentation:

Step 02 - LED flash

🛠️ Required Hardware:
  • ESP32
  • USB cable

📑 Description:

Now it's time to make your LED blink.
To do this, implement some code in your ESP32.

📌 Tasks:

Your LED must blink with 500 ms.

📚 Documentation:

Step 03 - Connect to WI-FI

🛠️ Required Hardware:
  • ESP32
  • USB cable

📑 Description:

You'll probably need to get on your phone's 4G! So make a connection share and connect via your board.

📌 Tasks:

  • 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!"
  • Print ip of your board in serial monitor

📚 Documentation:

Step 04 - SetUp Adafruit

🛠️ Required Hardware:
  • Your Computer

📑 Description:

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.

📌 Tasks:

  • 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 :)

📚 Documentation:

Step 05 - SetUp IFTTT

🛠️ Required Hardware:
  • Your Computer

📑 Description:

IFTTT is shorthand for If This Then That; it's an automation tool for connecting more than 650 apps and services.

📌 Tasks:

  • 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.
  • In the "Then That" add Adafruit and fill in the fields as follows:
    • Feed Name: on_off
    • Data to save: on

📚 Documentation:

Step 06 - Let's go code

🛠️ Required Hardware:
  • ESP32

📑 Description:

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.

📌 Tasks:

  • 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
  • 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.

📚 Documentation:

Step 07 - Turn ON and turn OFF

📑 Description:

Currently you only send "on" thanks to your voice assistant now it would be nice to send "off" right?

📌 Tasks:

  • Create a new Applet which will send off to the on_off feed.

✔️ Validation:

Use your voice assistant and turn your LED on and off !

🎉 Congratulation !

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.

Authors


Coline SEGURET

Organization


LinkedIn logo Instagram logo Twitter logo Discord logo

Website logo

🚀 Don't hesitate to follow us on our different networks, and put a star 🌟 on PoC's repositories.