DISCOVER . LEARN . EMPOWER INSTITUTE - UIE DEPARTMENT- ACADEMIC UNIT-2 Bachelor of Engineering Emerging & Disruptive Technologies Workshop (IoT, AR-VR, Robotics) 24ECP-103 Smart Home Voice Assistant 1
Smart Home using Ubidots 2
Smart Home Voice Assistant 3
Smart Home Voice Assistant 4
#include < UbidotsESPMQTT.h > MQTT library for connecting to Ubidots using MQTT protocol and an ESP32 board. MQTT(Message Queuing Telemetry Transport) is a standard messaging protocol for the Internet of Things(IOT). It is ideal for connecting remote devices with a small code footprint and minimal network bandwidth. #define RELAY 2 Connent relay at pin no 2 #define TOKEN "…………………." // Your Ubidots TOKEN A Token is a unique key that authorizes your device to interact with Ubidots API . A Device Token is a unique key that is linked to a single device within Ubidots data base, with either one or both of the following permissions: Send data: Publish to, or make POST requests to send data to the device.
#define WIFISSID "……." // Your SSID A service set identifier (SSID) is a sequence of characters that uniquely names a wireless local area network. An SSID is sometimes referred to as a "network name." This name allows stations to connect to the desired network when multiple independent networks operate in the same physical area. SSIDs are a sequence of alphanumeric characters (letters or numbers), are case sensitive and can have a maximum length of 32 characters . #define WIFIPASS "……….." // Your Wifi Pass It is a user defined password. Ubidots client(TOKEN); Initialize the instance.
void callback (char* topic, byte* payload, unsigned int length)
Serial . print ( "Message arrived [" ); Serial . print (topic); Serial . print ( "] " ); for (int i = 0; i < length; i ++) { Serial.print ((char)payload[ i ]); Payload is a pointer of type byte. transcode a byte array into a message payload without changing the meaning of the message. Prints data to the serial port as human-readable ASCII text. Serial . println (); Serial . print ( "Command: " ); bool command = *payload - 48 ; // A bool holds one of two values, true or false . (Each bool variable occupies one byte of memory.) Serial . println (command); digitalWrite (RELAY, !command); // Writing command status to relay pin
void setup () { Serial . begin ( 9600 ); Serial . println ( "Init... T4_Smart_Home" ); pinMode (RELAY, OUTPUT); Serial . print ( "Connecting to SSID: " ); Serial . print (WIFISSID); Serial . print ( ", Password: " ); Serial . println (WIFIPASS); client . wifiConnection (WIFISSID, WIFIPASS); Serial . println ( "Done" ); Serial . println ( " Initializing Ubidots Connection..." ); client . ubidotsSetBroker ( "industrial.api.ubidots.com" ); // Sets the broker properly for the business account client . setDebug ( true ); // Pass a true or false bool value to activate debug messages client . begin ( callback ); client . ubidotsSubscribe ( "smart-home-voice- assistant" , "bulb " ); //Insert the Device and Variable's Labels Serial . println ( "Done" ); Serial . println ( "DONE" ); }
void setup () { // Use it to initialize variables, pin modes, start using libraries, etc. The setup() function will only run once, after each powerup or reset of the Arduino board. Serial . begin ( 9600 ); // This tells the Arduino to get ready to exchange messages with the Serial Monitor at a data rate of 9600 bits per second. Serial . println ( " Init. .. T4_Smart_Home" ); pinMode (RELAY, OUTPUT); // Configures the specified pin to behave either as an input or an output. Serial . print ( "Connecting to SSID: " ); Serial . print (WIFISSID); Serial . print ( ", Password: " ); Serial . println (WIFIPASS); client . wifiConnection (WIFISSID, WIFIPASS); Serial . println ( "Done" );
Serial . println ( " Initializing Ubidots Connection..." ); client . ubidotsSetBroker ( "industrial.api.ubidots.com" ); // Sets the broker properly for the business account client . setDebug ( true ); // Pass a true or false bool value to activate debug messages client . begin ( callback ); client . ubidotsSubscribe ( "smart-home-voice- assistant" , "bulb " ); //Insert the Device and Variable's Labels // To monitor more than one variable Serial . println ( "Done" ); Serial . println ( "DONE" ); }
Viva Voice Questions What is signal conditioning? What is the difference between LM 34 and LM 35 sensors? Touch screen of mobile phones uses which type of sensors? 14
References Esp32 Programming for the Internet of Things. Sever Spanulescu 2nd Edition https://www.amazon.in/ESP32-programming-Internet-Things-Microcontrollers-ebook/dp/B07L7Q6WZX ESP32 Simplified: Control your home over the internet Luc Volders 1st Edition https://www.amazon.com/ESP32-Simplified-Control-your-internet/dp/171694211X Development using the Arduino IDE iain hendry 1st Edition https://www.amazon.in/ESP32-Development-using-Arduino-IDE-ebook/dp/B07RHBSFG9 ESP8266 Weather Station: Getting Started Guide Daniel Eichhorn 1st Edition https://www.amazon.in/ESP8266-Weather-Station-Getting-Started-ebook/dp/B01LFX8Z5W Remote Sensor Monitoring by Radio with Arduino: Detecting Intruders, Fires, Flammable and Toxic Gases, and Other Hazards at a Distance David Leithauser 1st Edition https://www.amazon.in/Remote-Sensor-Monitoring-Radio-Arduino/dp/153464055X 15