Login

Make a Google Assistant based Home automation system using NodeMCU

Objectives

  • Set up io.adafruit.com to control LEDs on the NodeMCU
  • Set up IFTTT to link Google Assistant with io.adafruit.com
  • Use Google Assistant to control LEDs connected to NodeMCU

 Things

  1. NodeMCU board (quantity: 1 no.)
  2. Micro USB cable A to B (quantity: 1 no.)
  3. Breadboard (quantity: 1 no.)
  4. RGB LED module (quantity: 1 no.)
  5. Jumper wire – male to male (quantity: 4 no.)
  6. io.adafruit.com account
  7. ifttt.com account
  8. Google Assistant on phone
  9. Adafruit MQTT library
  10. Arduino IDE on your computer

Let’s begin!

It is possible to use IFTTT and io.adafruit.com to control any components connected to a NodeMCU. In this experiment, we will control LEDs connected to NodeMCU. Potentially, we can connect relays connected to various components like bulb and fan to make a voice controlled home automation system.

Install Google Assistant on phone

 

Google Assistant on phone

 

Create an Adafruit account

Step 1: Open a browser and go to io.adafruit.com. Click on Get Started for Free.

Step 2Fill in your details and click on Create Account. Note that the site would have navigated to accounts.adafruit.com

Step 3Once you’ve successfully logged in, this page will be displayed. You can change your details if you wish to.

   

 

Set up your Adafruit dashboard to control the NodeMCU

 

Set up an IFTTT account and link Google Assistant with Adafruit

 

Interfacing RGB LED to NodeMCU

 

Interfacing RGB LED with NodeMCU

 

Final Code

You will need to install Adafruit MQTT library. Go to Sketch -> Include Library -> Manage libraries. Search for Adafruit MQTT  and click Install.

Change the following lines in the code:

Add your WiFi credentials

#define WLAN_SSID "Your_SSID"
#define WLAN_PASS "Your_Password"

Add your Adafruit username

#define AIO_USERNAME "xxxxxxxxxx"

Add your AIO key

#define AIO_KEY "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

To copy the code, right click on view raw at the bottom of the code, click on open link in new tab and then copy the code.

Uploading the code

Step 1: Enter the final code in the Arduino IDE window.

  • When you click on New to open a new blank code in the Arduino IDE, you will get a new  window with two functions: void setup() and void loop()
  • You can either type commands as shown in the final code under void setup() and void loop() functions or
  • delete the contents of this window. Then copy and paste the final code in the Arduino IDE window.

Step 2: Compile/ verify the code by clicking on the verify button.

  • Make sure the board is connected to your computer
  • Check if the correct board and port is selected.

Step 3: Upload the code by clicking on the upload button, which is right next to the verify button.

  • The Arduino IDE provides a progress bar when it’s uploading.
  • After it is done, you will see “Done uploading” on the bottom left of your IDE.
  • If you encounter any errors, you need to go back to the code and fix the errors.
SEE ALL Add a note
YOU
Add your Comment

We would love to see what you build out of these learnings!

Click here to submit your projects, share it with the world and stand a chance to be rewarded.

top

Knowledge and Content by Li2 Technologies | © 2021 NASSCOM Foundation | All rights reserved

X