0% found this document useful (0 votes)
65 views16 pages

Institute - Uie Department-Academic Unit-1: Disruptive Technologies-II 21ECH103

The document discusses developing a smart phone application for a smart home voice assistant using an ESP32 board, Ubidots MQTT library, and MIT App Inventor. It provides code to connect the ESP32 to WiFi, initialize the Ubidots connection, define callbacks to handle messages, and control a relay based on payload data. The setup function initializes connections and pin modes. The loop function reconnects if disconnected and processes messages. In summary, the document provides code for an IoT project using an ESP32, Ubidots, and a smart phone app to control a relay for smart home automation.

Uploaded by

Prabhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views16 pages

Institute - Uie Department-Academic Unit-1: Disruptive Technologies-II 21ECH103

The document discusses developing a smart phone application for a smart home voice assistant using an ESP32 board, Ubidots MQTT library, and MIT App Inventor. It provides code to connect the ESP32 to WiFi, initialize the Ubidots connection, define callbacks to handle messages, and control a relay based on payload data. The setup function initializes connections and pin modes. The loop function reconnects if disconnected and processes messages. In summary, the document provides code for an IoT project using an ESP32, Ubidots, and a smart phone app to control a relay for smart home automation.

Uploaded by

Prabhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

INSTITUTE - UIE

DEPARTMENT- ACADEMIC UNIT-1


Bachelor of Engineering

Disruptive Technologies-II
21ECH103

DISCOVER . LEARN . EMPOWER


Course Outcomes
CO Title Level
Number

CO1 Establish connectivity of IoT modules with cloud for sensor Remember
data collection and management.  
CO2 Design an appcessory with Bluetooth/Wi-Fi connectivity using Understand
standard mobile application development tools.  
CO3 Create robot prototypes enabled with sensors and actuators Apply
for restricted movement in different environments.

CO4 Develop augmented reality add-ons for smart-device Analyze and


applications to add interactivity, animate objects and build evaluate
logic into effects.
CO5 Demonstrate acquired skillset/technical knowledge of their Create
selected project topic.

2
AGENDA

• Develop a smart phone application for smart home


voice-assistant.
#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 25

 Connent relay at pin no 25

 #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 ac
count
  client.setDebug(true);                        // Pass a true or false bool value to activate debug mess
ages
  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");

}
void loop() {

   

  // Establising connection with Ubidots

  if (!client.connected()) {

    client.reconnect();

    client.ubidotsSubscribe("smart-home-voice

-assistant","bulb"); //Insert the Device and Variable's Labels

  }

  client.loop();

  delay(1000);

}
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?

13
Summary
• 1. MIT App Inventor: MIT App Inventor is an intuitive, visual
programming environment that allows everyone even children to
build fully functional apps for smartphones and tablets. 
• 2. Ubidots: Ubidots is a cloud based Internet of Things(IoT) data
analytics and visualization platform.

14
References
• https://www.geeksforgeeks.org/how-to-connect-mit-app-inventor-to-
ubidots-and-make-a-basic-smart-home-automation-app/
• https://ubidots.com/community/t/solved-how-to-post-and-get-data-t
o-any-variable-in-device-of-ubidots-cloud-using-mit-app-inventor/289
8
• http://iot.appinventor.mit.edu/

15
THANK YOU

For queries
Email: [email protected]

16

You might also like