You are on page 1of 9

University Institute of Engineering

Department of Computer Science & Engineering

Experiment: 1.2
Student Name: UID:
Sanya Singh 22BCS14374
Nishtha 22BCS12937
Jasleen Kaur 22BCS11775
Navnidhi 22BCS15723
Ankita 22BCS14745

Branch: Computer Science & Engineering Section/Group:115-B


Semester:2 Date of Performance:2-03-2023
Subject Name: Disruptive Technologies-2
Subject Code: 22ECH-103

1. Aim of the practical:

Design a Cloud based weather monitoring system using IoT platform and relevant sensors.

2. Tool Used:

BMP280, ESP32, UBIDOTS.

3. Basic Concept/ Command Description:


a) #include <Adafruit_BMP280.h>
Arduino library for BMP280 sensors.

b) #include <UbidotsESPMQTT.h>
MQTT library for connecting to Ubidots using MQTT protocol and an ESP32 board.
University Institute of Engineering
Department of Computer Science & Engineering

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.

c) #define BMP_SDA 21
Serial data pin

d) #define BMP_SCL 22
Serial clock pin
e) #define 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.

f) #define WIFISSID "……."


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.

g) #define WIFIPASS "……….."


It is a user defined password.

h) Adafruit_BMP280 bmp280;
Creating on object BMP for Adafruit_BMP280. An object file is created to access special
functions.
Ubidots client(TOKEN);
Initialize the instance.
i)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
University Institute of Engineering
Department of Computer Science & Engineering

Board.

 j) 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.

 k) Serial.println("Init... T2_Weather");
Prints data to the serial port 
  

l) client.add("temp", temp);  
client.add("pressure", pressure);
  client.add("altitude", altitude);  
   client.add("wbp", water_boiling_point);
Insert your variable Labels and the value to be sent

4. Code:
#include <Adafruit_BMP280.h>

#include <UbidotsESPMQTT.h>

#define BMP_SDA 21

#define BMP_SCL 22

#define TOKEN "BBFF-zkPpscJnEANLm6jB82ZbIEGAieVOXh"   // Your Ubidots TOKEN

#define WIFISSID "Joker" // Your SSID

#define WIFIPASS "Joker@tenda" // Your Wifi Pass

Adafruit_BMP280 bmp280;

Ubidots client(TOKEN);
University Institute of Engineering
Department of Computer Science & Engineering

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]);

 }

 Serial.println();

void setup() {

 Serial.begin(9600);

 Serial.println("Init... T2_Weather");

 Serial.println("Initializing BMP280");

 boolean status = bmp280.begin(0x76);

 if (!status) {

  Serial.println("BMP280 Not connected!");

 }

 Serial.println("Done");

 Serial.print("Connecting to SSID: ");

 Serial.print(WIFISSID);

 Serial.print(", Password: ");


University Institute of Engineering
Department of Computer Science & Engineering

 Serial.println(WIFIPASS);

 client.wifiConnection(WIFISSID, WIFIPASS);

 Serial.println("Done");

 Serial.println(" Initializing Ubidots Connection...");

 client.ubidotsSetBroker("things.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);

 Serial.println("Done");

 Serial.println("DONE");

void loop() {

 // Acquiring data from BMP280

 float temp = bmp280.readTemperature();

 float pressure = bmp280.readPressure();

 float altitude = bmp280.readAltitude();

 float water_boiling_point = bmp280.waterBoilingPoint(pressure);

 Serial.print("Temperature: ");

 Serial.print(temp);

 Serial.println(" °C");

 Serial.print("Pressure: ");

 Serial.print(pressure);

 Serial.println(" Pa");
University Institute of Engineering
Department of Computer Science & Engineering

 Serial.print("Altitude: ");

 Serial.print(altitude);

 Serial.println(" m");

 Serial.print("Water Boiling Point: ");

 Serial.print(water_boiling_point);

 Serial.println(" F");

 // Establising connection with Ubidots

 if (!client.connected()) {

  client.reconnect();

 }

 // Publising data of both variable to Ubidots

 client.add("temp", temp); // Insert your variable Labels and the value to be sent

 client.add("pressure", pressure);

 client.add("altitude", altitude); // Insert your variable Labels and the value to be sent

 client.add("wbp", water_boiling_point);

 client.ubidotsPublish("weather-monitoring-system"); // insert your device label here

 client.loop();

 delay(5000);

5. Observations, Simulation Screen Shots and Discussions:


University Institute of Engineering
Department of Computer Science & Engineering
University Institute of Engineering
Department of Computer Science & Engineering

6. Result and Summary:

BMP280 is an absolute barometric pressure sensor especially designed for mobile
applications. The sensor module is housed in an extremely compact package. Its small
dimensions and its low power consumption allow for the implementation in battery
driven devices such as mobile phones, GPS modules or watches. Ubidots is a codeless
IoT Platform designed to empower us to prototype and scale IoT projects to production,
whilst improving and economizing the world around us with sensor data.

7. Additional Creative Inputs (If Any):

Learning outcomes (What I have learnt):

1. Learnt about connectivity of IoT modules with cloud for sensor data collection and management.
2. Learn about how to design an appcessory with Bluetooth/Wi-Fi connectivity using standard mobile application
development tools.

Evaluation Grid (To be filled by Faculty):


Sr. No. Parameters Marks Obtained Maximum Marks
University Institute of Engineering
Department of Computer Science & Engineering

1. Worksheet completion 8
including writing learning
objectives/Outcomes. (To
be submitted at the end of
the day)
2. Viva voce 10
3. Conduct 12
Signature of Faculty (with Total Marks Obtained: 30
Date):

You might also like