Home Automation using Google Assistant + Dialogflow + Firebase + ESP8266/Wemos (Part 4)

Vishal Dubey
2 min readOct 28, 2017

--

We have successfully created an app in actions on google console and linked it with a Dialogflow agent. In the previous section, we wrote a webhook using Firebase Cloud Function which will push data to Firebase Realtime Database. The final step is to setup the hardware which is constantly listening for changes in the Realtime Database and takes necessary action i.e switch on/off the bulb. The YouTube video series can be found on my channel. Check it out here. Also, don’t forget to like, share and subscribe. :P

Hardware Requirements:

  1. ESP8266 or Wemos d1mini or similar alternative.
  2. One 5V Relay.
  3. One bulb with socket and three pin plug.
  4. Few jumper wires and breadboard (optional)
  5. Clone the firebase-arduino library into the libraries folder of Arduino

Connections:

  1. +ve of relay → Vin/5V of ESP8266.
  2. -ve of relay → GND of ESP8266.
  3. IN of relay → D2 of ESP8266.
  4. Split one of the wires coming from the 3 pin plug and one end goes to COM of relay and another goes to NO (Normally Open) of relay.

Flashing code on ESP8266:

  1. Connect your ESP8266 to your laptop/PC and open a new sketch in Arduino IDE. Copy and paste the following code:
  2. Add WIFI_SSID, WIFI_PASSWORD, FIREBASE_DB_URL and FIREBASE_DB_SECRET_KEY.

3. Awesome! We now have the hardware ready to respond to our requests using the Google Assistant.

It’s time to test our application. Go to the Actions on google console and open your project. Click on the TEST button at the bottom of the page. This makes your project live which you can test from any device running the Google Assistant and is affiliated with the same Google account. The app is not live to be used by everyone. Only you can test the application.

You can watch the demo video here.

The code for complete demo is here. Hope you liked this series of articles. Try new examples and ideas and let me know what interesting things you build.

--

--

Vishal Dubey

| Google Certified Developer |Intel Software Innovator | Full Stack Dev | React Native | IoT Enthusiast | Mentor | https://github.com/vishal-android-freak