Let's begin with a small tutorial on how to control your home Bulb using the Google Voice assistance which you used in a Mobile device or smart TV at the home.
Find below the Video link for the complete sequence to create this project at your home.
Objective:
With the Internet of Things, we can able to connect every device to the Internet and able to interact with it using the different services available over the internet. This device can be any sensor that can be able to generate any information in the form of an analog or digital signal. this device information can be used in different internet service using data communication and use available service to control these devices from the online service.
Let's begin with the following sequence :
- Installation of Arduino and ESP8266 configuration.
- Adafruit IO service
- IFTTT applet service.
- Hardware setup configuration.
- Source code
- Demo
Hardware Requirement:
- ESP8266 NodeMCU
- Bulb
- Relay Board (1 channel relay Board )
- Breadboard
- Jumper wire
- Arduino IDE.
- Fritzing
Installation of Arduino software:
The Arduino Software (IDE) allows you to write programs and upload them to your Microcontroller board used to connect any sensor device.
It easy to write code and upload it to the board. It runs on Windows, Mac OS X, and Linux. Please find the Software Download link for the windows. Now Install the Arduino Desktop IDE for windows using step-by-step instructions using my video reference.
Once you installed the IDE successfully open the Arduino program from the start menu. Connect your ESP8255 Nodemcu microcontroller board to PC using USB-Serail Port. The matching COM port will be shown in Ardunio SOftware when you connect the ESP8266 Nodemcu with the PC using USB-Serial Cable.
- Go to File -> Preferences from the Arduino Software.
- Add link http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field in the Arduino preferences.
- Install ESP8266 Nodemcu library using the "esp8266" key in the search bar.
After the install process, you should see that the esp8266 package is marked INSTALLED. Close the Boards Manager window once the install process has completed.
Blink Test :
We'll begin with the simple blink test so it will make sure that our connection to the ESP8266 board is correct and working fine.
void setup() { pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output } // the loop function runs over and over again forever void loop() { digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level // but actually the LED is on; this is because // it is active low on the ESP-01) delay(1000); // Wait for a second digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the voltage HIGH delay(2000); // Wait for two seconds (to demonstrate the active low LED) }
Build and upload the code to the connected ESP8266 Microcontroller. Once successful upload ESP8266 will start blinking its LED with a delay of 1 sec.
Adafruit IO Service:
Adafruit IO: Feeds
Adafruit IO : Dashboard
Adafruit IO Key:
To use the Adafruit service over the internet we need a few connection details when establishing the connection to Adafruit IO service. use the following details to connect an MQTT client to Adafruit IO:
Adafruit IO Service:
Now we have configured ESP8288 with Arduino software we are ready for the next step to create service using the Adafruit IO service. Adafruit IO is the easiest way to get your projects onto the Internet of Things. Using Adafruit IO service you can connect your device our the internet service. Adafruit IO uses MQTT (message queue telemetry transport) as a transport protocol for device communication that Adafruit IO supports.
Adafruit IO: Feeds
Feeds are the core of Adafruit IO which takes part in exacting data communication to and from Adafruit IO service. This feed data can be used to control the sensor device using the microcontroller device like ESP8266. Using an MQTT library or client you can publish and subscribe to a feed to send and receive feed data. you can read more from Adafruit IO site on how to create, edit, and delete your very own feed.
The second part is Dashboards allow you to visualize and control Adafruit IO connected projects from any modern web browser. Widgets such as charts, sliders, and buttons are available to help you quickly get your project up and running without the need for any custom code.
To use the Adafruit service over the internet we need a few connection details when establishing the connection to Adafruit IO service. use the following details to connect an MQTT client to Adafruit IO:
- Host: io.adafruit.com
- Port: 1883 or 8883 (for SSL encrypted connection)
- Username: your Adafruit account username (see the accounts.adafruit.com page here to find yours)
- Password: your Adafruit IO key (click the AIO Key button on a dashboard to find the key)
Note: Your Adafruit IO Key should be kept in a safe place and treated with the same care as your Adafruit username and password.
Below are the parameters which need to be set in the Arduino source code.
#define IO_USERNAME "account_username"
#define IO_KEY "aio_key"
IFTTT ( If This Then That), is a web-based service that creates chains of simple conditional statements, called applets. An applet is triggered by changes that occur within other web services such as Gmail, Facebook, Telegram, Instagram, or any app service which can be used daily basis.
With this you’ll have access to an ecosystem of over 600 world-class services, thousands of active developers and millions of consumers.
Using applets we can able to connect the multiple services together and trigger any action based on the condition set to the trigger. For more details please go to the documentation page of the IFTTT site.
Our applets will connect the Adafruit feed service to the google voice assistance service. For that, you need to register this service using your Google account details. With google voice assistance we can create the trigger to Adafruit using the trigger command set which can be done easily with IFTTT applet service. So we have created two applets to feed voice data for turning on light and turning off light to Adafruit feed we have created.
Once we have created service ready we can able to start with setup details and coding part.
Setup Diagram:
ESP8266 NodeMCU :
NodeMCU is a low-cost open-source IoT platform. NodeMCU included firmware that runs on the ESP8266 Wi-Fi SoC from Espressif Systems. ESP8266 is a bite-sized and low const WiFi-enabled microcontroller, it can monitor and control things from anywhere in the world and it just perfect for just about any IoT project.
Specification of ESP866 NodeMCU:
- ESP-12E Chip Tensilica Xtensa® 32-bit LX106
- 80 to 160 MHz Clock Freq.
- 128kB internal RAM
- 4MB external flash
- 802.11b/g/n Wi-Fi transceiver
Power to the ESP8266 NodeMCU is supplied via the on-board MicroB USB connector. Alternatively, if you have a regulated 5V voltage source, the VIN pin can be used to directly supply the ESP8266 and its peripherals.
The ESP8266 NodeMCU has total of 30 pins that interface it to the outside world. The connections are as follows:
For more details please visit NodeMCU Link.
Relay: A relay is an electrically operated switch and like any other switch, it can be turned on or off the electrical device. It can be controlled with low voltages, like the 3.3V or 5V which can be provided by the ESP8266 GPIOs and allows us to control high voltages like 12V, 24V or mains voltage 230V from home AC line.
Below is the Fritzing sket of the circuit diagram. You can download this from my git repo google-voice-assistance-with-ESP8266-nodemcu.
Here we controlling 230V bulb using the GPIO pin connected from ESP8266 Micontoller using Arduino code. The two connectors (with three sockets each) on the left side of the relay module connect high voltage bulb, and the pins on the right side (low-voltage) connect to the ESP8266 GPIOs.
Connect D1 pin of ESP8266 to Relay to control as shown in the circuit diagram.
- Download the source code from my git repository google-voice-assistance-with-ESP8266-nodemcu.
- Open ardino file ESP8266_BULB.ino using Arduino Software.
- Edit the Wifi Credential to connect your ESP8266 device to internet service using local wifi connection.
// WiFi parameters
#define WLAN_SSID "ssid" // use wifi ssid
#define WLAN_PASS "password" // use wifi password
- Then edit the Adafruit connection Details described with Adafruit service.
// Adafruit IO server details.
#define AIO_SERVER "io.adafruit.com"
#define AIO_SERVERPORT 1883
#define AIO_USERNAME "username" // user username
#define AIO_KEY "aio_key" // use aio key Obtained from account info on io.adafruit.com
- Build the code using Arduino IDE build command.
- After Build successful Upload the code to connected ESP8266 NodeMCU using USB-serial cable. Arduino IDE will automatically upload the code to ESP8266.
- Then ESP8266 will reset itself and start running with uploaded code.
- you can monitor the console log enabled in using connecting to serial monitor using Arduino IDE.
Now your home electric bulb is connected to your google voice assistance. So you can start your google voice assistance mobile device and send the voice command which you have registered as a command to IFTTT applets.
Visit below my youtube link here.
I hope you enjoyed the small IoT project at your homeplace. Please provide your feedback about this project. Please do like, comment, and share my project to reach more people who wanted to learn such interesting projects.
No comments:
Post a Comment