How To Configure WisBlock Integration to Ubidots Over MQTT and Voice Command Using Google Assistant

KHM-045-00.png

Overview

You can monitor your home or office with our RAKwireless WisBlock modules using a web or mobile dashboard, add voice commands with Google Assistant for automation, and switch control to integrate your IoT (Internet of Things) easier.

Hardware

You need the following to get started:

Software

The following are also required to get started:

WisBlock Integration

WisBlock Integration to Ubidots over MQTT

Setup the hardware components. The RGB LED strip was used as the load for our relay.

KHM-045-01.png

KHM-045-02.png

Install the RAKWireless ESP32 BSP on Arduino Boards Manager.

Download and install the following libraries into your Arduino IDE:

    • PubSubClient
    • Ubidots ESP MQTT
    • Adafruit_BME680

Before uploading codes to the RAK11200, short circuit BOOT0 and GND pin and press the reset button. Make sure to do this so that your upload will not fail.

See Uploading to WisBlock for a complete guide on Arduino Tools Configuration.

KHM-045-03.png

Copy and upload the code from our WisBlock GitHub repo into your Arduino IDE.

đź“ť NOTE: Input your WiFi credentials:
const char *WIFI_SSID = "******";
const char *WIFI_PASS = "******";
const char *UBIDOTS_TOKEN = "******";

Once you're done uploading the code, go and log in to your Ubidots account. It will automatically input the newly created device, its variables within the device, and sensor data.

KHM-045-04.png

KHM-045-05.png

The relay variable has not been automatically inserted in Ubidots, and it is still missing. We need to manually add a variable for the relay:

    • Select the Add Variable.
    • Choose Raw.
    • Rename the added variable with relay.

Then, you can create your own dashboard where you can monitor the environment coming from the sensor. To create a dashboard, go to Create Dashboards and Widgets.

KHM-045-06.png

Set up an IFTTT to control your relay where the RGB LED strip is connected to your system via voice command using Google Assistant.

WisBlock Integration to Google Assistant over IFTTT

After integrating your WisBlock with Ubidots, log in to your IFTTT account.

Select Create to create a new Applet.

Then click the If This Add icon.

KHM-045-07.png

Search and select Google Assistant.

KHM-045-08.png

Select the Say a simple phrase.

KHM-045-09.png

You need to fill the fields with the Google Assistant to switch the relay and turn our RGB LED light on. For example:

  • What do you want to say?: Turn on the led
  • What's another way to say it? (optional): Switch on the led
  • And another way? (optional): Lights on
  • What do you want the Assistant to say in response?: Okay RAKstar! Turning on the led lights
  • Language: English

Then, click Create trigger.

KHM-045-010.png

When the trigger is already set, create the action Then That Add.

Then, choose Webhooks as action service.

KHM-045-011.png

Make a web request and fill the fields of the WebHooks setup with the following parameters:

  • URL: http://industrial.api.ubidots.com/api/v1.6/devices/{DEVICE-LABEL}?token={YOUR-UBIDOTS-TOKEN}
  • Method: POST
  • Content Type: application/json
  • Body: {"relay":1}

KHM-045-012.png

Then, click Create action to finish.

Once the trigger and action have been properly configured and connected, go to your Google Assistant and say Turn on the led and listen to Google Assistant's response. See how the relay is turned on to switch the RGB LED strip.

KHM-045-013.png

Repeat the previous steps to create the applet that will switch the relay and turn off the RGB LED strip. All of the preceding steps are the same; the only differences are listed below:

  • Trigger Configuration (Google Assistant): switch on for off
  • Action Configuration (Webhooks): the body should be {"relay":0} to switch off the relay

Once both applets are created and connected, you’re done! You can now control and automate your devices using Google voice commands.

KHM-045-014.png

KHM-045-015.png

Now, you have a smart home application for remotely controlling your devices by using Ubidots and Google Assistant!

Updated