Professional Documents
Culture Documents
IOT CLOUD MANUAL-modified
IOT CLOUD MANUAL-modified
IOT CLOUD MANUAL-modified
Expt. No. 1
Create any Cloud Platform account, explore IoT services
And register a thing on the platform.
Date:
AIM: To Create Adafruit Cloud Platform account, explore IoT services and register
a thing on the platform.
REQUIREMENTS:
1. Computer or mobile device
2. Adafruit account
3. IoT device or sensor
4. Internet connectivity
DESCRIPTION:
The Adafruit Cloud Platform is a cloud-based service that enables users to
create and manage Internet of Things (IoT) projects. It provides a platform for
developers and hobbyists to connect their devices and sensors to the cloud, store
and analyze data, and control their devices remotely.
With the Adafruit Cloud Platform, users can register their IoT devices and
sensors, create custom dashboards to visualize and analyze data, and set up triggers
and alerts to automate their devices. The platform supports various protocols for
connecting IoT devices such as MQTT, HTTP, and WebSocket, making it versatile
for different types of devices and projects.
Users can also create custom APIs to interact with their devices and build
custom applications. The platform has a user-friendly interface and provides several
pre-built blocks and widgets for creating custom dashboards and visualizations,
making it easy for users to get started with their projects.
PROCEDURE:
For the creation of an Adafruit Cloud Platform account and register a thing
on the platform, we should follow these steps:
1
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
2. Click on the “SIGN IN” button located in the top right corner of the page.
2
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
4. Fill out the required information, including your name, email address, and a
password. Then click on the "Create A
Account"
ccount" button to submit your
registration.
5. Once you have created your account, log in to the Adafruit Cloud Platform
using your email address and password.
3
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
4
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Expt. No. 2
Date: Push sensor data to cloud
5
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
6
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Now we can add some settings for the display of the guage
7
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
CIRCUIT DIAGRAM:
For implementing this experiment we need publish code and config.h code.
SOURCE CODE:
PUBLISH CODE:
#include "config.h"
int count = 0;
Adafruit IO_Feed *counter = io.feed("Temperature");
void setup() {
Serial.begin(115200);
While (! Serial);
Serial.print("Connecting to Adafruit IO");
io. connect ();
While (io.Status() < AIO_CONNECTED) {
Serial.Print (".");
delay (500);
}
8
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Serial.Println ();
Serial.Println (Io.status Text());
}
void loop() {
io.run();
OUTPUT:
RESULT:
Push sensor data to cloud was successfully completed.
9
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Expt. No. 3
Date: Control an Actuator through cloud
SOFTWARE REQUIREMENTS:
Arduino IDE
Adafruit
DESCRIPTION:
Adafruit cloud can store, control and monitor the any actuator using
development boards. Here we are using the ON/OFF button from the adafruit cloud
we are controlling the LED light. By switching ON/OFF the button through the
cloud we can control the LED from any remote area. There is not need of real
switch controlling can be done through virtual switch.
PROCEDURE:
1. Open adafruit cloud to create a feed related to experiment and a new
dashboard to be created.
2. In dashboard create a layout with on/off switch and give the value ON as HIGH
10
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
11
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
void loop() {
io.run();
}
void handleMessage(AdafruitIO_Data *data) {
String cmd= data->value();
Serial.print("received <- ");
Serial.println(cmd);
if(cmd == "HIGH"){
Serial.println("Rx HIGH");
digitalWrite(LED_PIN, HIGH);
}
else if(cmd == "LOW"){
Serial.println("Rx LOW");
digitalWrite(LED_PIN, LOW);
}
}
OUTPUT:
RESULT:
Accessing the data pushed from the sensor to cloud and applying any data
analytics or visualization service is successfully completed.
13
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Expt. No. 4
Date: Data Analytics Or Visualization Services
AIM:
To Access The Data Pushed From Sensor To Cloud And Apply Any Data
Analytics Or Visualization Services
HARDWARE REQUIREMENTS:
1.DHT11 sensor
2.Jumper wires
3.NodeMCU
4.Power Adapter
SOFTWARE REQUIREMENTS:
1. Arduino IDE
2. Libraries for DHT sensor
3. Libraries for node MCU
4. Libraries for esp8266
5. Adafruit cloud platform
6. Adafruit IO Arduino libraries
COMPONENTS DESCRIPTIION :
DHT11 SENSOR: The DHT11 is a basic, ultra low-cost digital temperature and
humidity sensor. It uses a capacitive humidity sensor and a thermostat to measure
the surrounding air and spits out a digital signal on the data pin (no analog input
pins needed).
DHT11 Applications:
It gives accurate temperature and humidity.
14
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
NODE MCU: Node MCU is an open source firmware for which open source
prototyping board designs are available
available.. The name "NodeMCU" combines
comb
"node" and "MCU" (micro--controller
controller unit). Strictly speaking, the term "NodeMCU"
refers to the firmware rather than the associated development kits.
BLOCK DIAGRAM:
15
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
PROCEDURE:
1. First to write the code we have to go to file->examples->
Adafruit IO Arduino->Arduino_subscribe ..then we have to write the record
regarding our project.
2. While writing the code then we have to give names of feed as of we have
provided in the cloud(adafruit.com).
3. After implement the code we have to compile it.
4. To upload the code to the nodeMCU, firstly we have to connect the system to
the nodeMCU using a data cable.
5. Then we should connect the sensor to the kit using the cables and should
provide power supply.
6. Then after all the connections are done correctly then we have to select the
feed (which we provide in the code) in the cloud platform (Adafruit.com).
16
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
7. Then after selecting the feed we have to select the dashboard of the name
Temperature and Humidity. Then we have to create the new block and select
the guage for showing the output of humidity and temperature.
8. After selecting the guage we have to provide the lower limit for the gauges
we have selected.
9. Then we have to create the actions to send the mail. For this we have to select
the new action under action tab ->reactive->choose the action->setup our
action->account setting->time zone->again to action->email verification.
17
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
18
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
10.Then we can get alert mails to our registered and verified mail.
SOURCE CODE
SUBSCRIBE CODE:
#include "config.h"
#include "DHT.h"
#define DHTPIN 14
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
int count = 0;
AdafruitIO_Feed *Temperature = io.feed("Temperature");
AdafruitIO_Feed *Humidity = io.feed("Humidity");
void setup() {
Serial.begin(115200);
Serial.println(F("DHTxx test!"));
dht.begin();
while(! Serial);
Serial.print("Connecting to Adafruit IO");
19
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
io.connect();
while(io.status() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.println(io.statusText());
}
void loop() {
io.run();
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t) ) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
float hic = dht.computeHeatIndex(t, h, false);
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.println("sending data -> ");
Temperature->save(t);
Humidity->save(h)
delay(30000);
}
CONFIG CODE:
#define IO_USERNAME "AliyaSyed"
#define IO_KEY "aio_EKBA07YKKoySuioNArMqmwCBiu5"
#define WIFI_SSID "Aliya"
#define WIFI_PASS "12345"
20
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
#include "AdafruitIO_WiFi.h"
#if defined(USE_AIRLIFT)) || defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE
ADAFRUIT_METRO_M4_AIRLIFT_LITE)
||
defined(ADAFRUIT_PYPORTAL
ADAFRUIT_PYPORTAL)
#if !defined(SPIWIFI_SS)
#define SPIWIFI SPI
#define SPIWIFI_SS 10
#define NINA_ACK 9
#define NINA_RESETN 6
#define NINA_GPIO0 -1
#endif
AdafruitIO_WiFi io(IO_USERNAME,
IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS,
SPIWIFI_SS, NINA_ACK,
NA_ACK, NINA_RESETN, NINA_GPIO0, &
&SPIWIFI)
SPIWIFI);
#else
AdafruitIO_WiFi io(IO_USERNAME,
IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS
WIFI_PASS);
#endif
OUTPUT:
22
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Expt. No. 5
Date: To control any two actuators using Bluetooth
HARDWARE REQUIRMENTS :
NODE MCU
BLUETOOTH MODULE
POWER MODULE
TWO MOTORS
MICRO USB CABLE
12-V ADAPTER
JUMPER WIRES
SOFTWARE REQUIRMENTS :
ARDUINO IDE
ARDUINO BLUECONNECT
DESCRIPTION :
NODE MCU :
o The NodeMCU (Node MicroController Unit) is an open-source
software and hardware development environment built around an
inexpensive System-on-a-Chip (SoC) called the ESP8266.
o The ESP8266 is also hard to access and use. You must solder wires,
with the appropriate analog voltage,
o The Arduino project created an open-source hardware design and
software SDK for their versatile IoT controller. Similar to NodeMCU
PROCEDURE:
VCc,GND,Tx,Rx pins of Bluetooth module is connected to the NodeMcu.
Tx is connected to the Rx of NodeMCU.
Rx is connected to the Tx of NodeMCU.
The power module contains two 5v pins and two GND. These two pins are
connected to the NodeMCU.
The two motors are interconnected and these interconnected pins are
connected to the 12v and GND of power module.
The Connections of motor is as fillows:
o Motor 11 is connected to the 16 pin.
o Motor 12 is connected to the 8 pin.
o Motor 21 is connected to the 4 pin.
o Motor 22 is connected to the 2 pin.
12v is supplies to the kit.
ArduinoBlueControl app is available in playstore and is downloaded in our
mobile.
Bluetooth module is named as HC-05 is connected to our mobile.
We can control the two motors by using the mobile application by giving
commands.
HC-05
ArduinoBlueControl
24
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
SOURCE CODE:
const int Motor11 = 16;
const int Motor12 = 5;
const int Motor21 = 4;
const int Motor22 = 0;
void setup() {
Serial.begin(9600);
pinMode(Motor11, OUTPUT);
pinMode(Motor12, OUTPUT);
pinMode(Motor21, OUTPUT);
pinMode(Motor22, OUTPUT);
}
void loop() {
if(Serial.available()>0)
{
char data= Serial.read();
if (data == 'F'){
digitalWrite(Motor11, HIGH);
digitalWrite(Motor12, LOW);
digitalWrite(Motor21, HIGH);
digitalWrite(Motor22, LOW);
}
if (data == 'B'){
digitalWrite(Motor11, LOW);
digitalWrite(Motor12, HIGH);
digitalWrite(Motor21, LOW);
digitalWrite(Motor22, HIGH)
}
if (data == 'L'){
digitalWrite(Motor11, HIGH);
digitalWrite(Motor12, LOW);
digitalWrite(Motor21, LOW);
digitalWrite(Motor22, LOW);
}
if (data == 'R'){
digitalWrite(Motor11, LOW);
digitalWrite(Motor12, LOW);
digitalWrite(Motor21, HIGH);
digitalWrite(Motor22, LOW);
}
if (data == 'S'){
digitalWrite(Motor11, LOW);
digitalWrite(Motor12, LOW);
digitalWrite(Motor21, LOW);
25
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
digitalWrite(Motor22, LOW);
}
OUTPUT:
Result: Hence the control of any two actuators by using Bluetooth is successfully
completed.
26
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Expt. No. 6
Date: Control any two actuators using Ultra Sonic Sensor
Aim: To read data from sensor (ultrasonic sensor) and send it to a requesting client.
Description: Adafruit io-platform can store, control, monitor any data from and
send it to a requesting client.
By using the ultrasonic sensor data stream sent to the cloud and process it and
send it to any requesting client or can control actuators (led) based on the
thresholds. We can even setup actions to notify us via email whenever an object is
detected.
Hardware Requirements:
NodeMCU,
Ultrasonic Sensor,
Led,
Breadboard & Connecting wires.
Software Requirements:
Arduino IDE,
Adafruit IO platform & libraries.
Procedure:
Step-1: Setup Arduino IDE for nodeMCU and register in Adafruit IO platform.
Step-2: open Adafruit IO platform and in IO section > open feeds tab and create a
new feed for reading sensor data.
Step-3: in dashboards tab> create a new dashboard and add a new data element
to layout.
Step-4: in alerts tab> create a new alert for sending an email when an activity is
noticed.
Step-5: now in Arduino IDE, open ”sub&pub” sketch under File>examples>Arduino
IO Adafruit.
Step-6: in the config.h file configure credentials such as API KEY, USERNAME,
WIFI SSID, WIFI PASSWORD.
Step-7: in the sketch file, add “feed” and code to read data from sensor and to control
actuator
Step-8: Connect the components as shown in the block diagram and ensure that
wi-fi is established and connect the nodeMCU to ultrasonic sensor with the pins
27
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
accordingly.
Ultrasonic Sensor NodeMCU
Vin Vcc
TRIG D1
ECHO D2
GND Gnd
Step-9: Now, compile the code and dump it onto the nodeMCU board
and check the serial monitor for the output.
Source Code:
#include "config.h"
#define TRIG D1
#define ECHO D2
#define LED D4
#define SPEED 0.343
AdafruitIO_Feed *Distance = io.feed("ultrasonic-sensor.distance");
AdafruitIO_Feed *Alert = io.feed("ultrasonic-sensor.alert");
void setup() {
Serial.begin(115200);
pinMode(TRIG, OUTPUT);
pinMode(ECHO, INPUT);
pinMode(LED, OUTPUT);
while(!Serial);
Serial.print("Connecting to Adafruit IO");
io.connect();
Alert->onMessage(handleMessage);
while(io.status() < AIO_CONNECTED){
Serial.print(".");
delay(500);
}
Serial.println(); Serial.println(io.statusText());
}
void loop() {
io.run();
digitalWrite(TRIG, LOW);
delayMicroseconds(5);
digitalWrite(TRIG, HIGH);
delayMicroseconds(10); digitalWrite(TRIG, LOW);
int duration = pulseIn(ECHO, HIGH);
int distance = (duration / 2 ) * SPEED; Serial.print("distance:");
Serial.println(distance);
if(distance!=0 && distance<20) Alert->save("alert");
else Alert->save("noActivity");
if(distance!=0){
Distance->save(distance);}
delay(1000);}
28
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
29
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Expt. No. 7
Date: Detection of smoke using gas sensor
Aim: To detect smoke or gas by using (Gas sensor) and send it to the
cloud.
By using the Gas sensor gas stream is detected sent to the cloud and
process it and send it to any requesting cloud or We can even setup actions to
notify us via email whenever LPG or smoke is detected gas sensors are
employed in factories and homes detect gas leakages.
Hardware Requirements:
Node MCU,
MQ-2 Gas sensor
Breadboard & Connecting wires.
Software Requirements:
Arduino IDE,
Adafruit IO platform & libraries.
Procedure:
Step-1: Setup Arduino IDE for node MCU and register in Adafruit IO
platform.
Step-2: open Adafruit IO platform and in IO section > open feeds tab and create
a new feed for reading sensor data.
Step-3: in dashboards tab> create a new dashboard and add a new data element
to layout.
Step-4: in alerts tab> create a new alert for sending an email when an activity is
noticed.
Step-5: now in Arduino IDE, open ”sub&pub” sketch under
File>examples>Arduino IO
Adafruit.
Step-6: in the config.h file configure credentials such as API KEY,
USERNAME, WIFI SSID, WIFI PASSWORD.
Step-7: in the sketch file, add “feed” and code to read data from sensor and
30
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
tocontrol actuator.
Step-8: Connect the components as shown in the block diagram and ensure
that wi-fi is established and connect the node MCU to Gas sensor with the pins
accordingly.
MQ-2 GAS SENSOR NODE MCU
Vcc Vin
A0 A0
D0 No Connectin
GND GND
9: Now, compile the code and dump it onto the nodeMCU board and check the
serial monitor for the output.
Block Diagram
Source code:
#include "config.h"
int co= A0;
AdafruitIO_Feed *counter = io.feed("Welcome Feed");
void setup() {
Serial.begin(115200);
pinMode(co,INPUT);
pinMode(14,OUTPUT);
while(! Serial);
Serial.print("Connecting to Adafruit IO");
io.connect();
while(io.status() < AIO_CONNECTED) {
Serial.print(".");
31
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
delay(500);
}
Serial.println();
Serial.println(io.statusText());
}
void loop() {
io.run();
int data = analogRead(co);
Serial.println(data);
delay(100);
Serial.print("sending -> ");
Serial.println(data);
counter->save(data);
if(data >600){
digitalWrite(14,HIGH);
delay(100);
}
if(data < 600)
{
digitalWrite(14,LOW);
delay(100);
}
delay(10000);
}
CONFIG CODE:
32
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Confirmation email:-
OUTPUT:-
33
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Expt. No. 8
Date: Transferring Accelerometer Reading over WiFi
HARDWARE REQUIRMENTS :
NODE MCU
MICRO USB CABLE
JUMPER WIRES
ACCELEROMETER SENSOR
SOFTWARE REQUIRMENTS :
ARDUINO IDE
ARDUINO ACCELEROMETER LIBRARY
ADAFRUIT ACCOUNT WITH FEED NAME
DESCRIPTION :
NODEMCU:
Accelerometer Sensor:
Accelerometers measure linear acceleration and are also used for other
purposes such as inclination and vibration measurement. MEMS
accelerometers embed several useful features for motion and acceleration
detection, including free-fall, wakeup, single/double-tap recognition,
activity/inactivity detection, and
6D/4D orientation.
34
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
35
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Code:
Main code:
#include "config.h"
int x= A0;
AdafruitIO_Feed *counter = io.feed("Welcome Feed");
void setup() {
Serial.begin(115200);
pinMode(x,INPUT);
pinMode(12,OUTPUT);
while(! Serial);
Serial.print("Connecting to Adafruit IO");
io.connect();
while(io.status() < AIO_CONNECTED)
{
Serial.print(".");
delay(500);
}
Serial.println();
Serial.println(io.statusText());
}
void loop() {
io.run();
int data = analogRead(x);
Serial.println(data);
delay(100);
Serial.print("sending -> ");
Serial.println(data);
counter->save(data);
if(data >500){
digitalWrite(14,HIGH);
delay(100);
}
36
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Config code:
#define IO_USERNAME "Akash_19"
#define IO_KEY "aio_CGJA68VfWFPZP7dovM2YZbHsIYk4"
#define WIFI_SSID "Akash"
#define WIFI_PASS "akash1907"
#include "AdafruitIO_WiFi.h"
#if defined(USE_AIRLIFT) || defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE)
#defined(ADAFRUIT_PYPORTAL)
#if !defined(SPIWIFI_SS)
#define SPIWIFI SPI
#define SPIWIFI_SS 10
#define NINA_ACK 9
#define NINA_RESETN 6
#define NINA_GPIO0 -1
#endif
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS,
SPIWIFI_SS,NINA_ACK, NINA_RESETN, NINA_GPIO0, &SPIWIFI);
#else
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
#endif
RESULT:
Hence, the system which transfers accelerometer readings over WiFi is
successfully performed.
37
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Expt. No. 9
Date: Perform smart alarm clock using iot
HARDWARE REQUIRMENTS :
NODE MCU
Rtc module
MICRO USB CABLE
12-V ADAPTER
JUMPER WIRES
RELAY MODULE
SOFTWARE REQUIRMENTS :
ARDUINO IDE
ARDUINO BLUECONNECT
DESCRIPTION :
NODE MCU :
RTC Module:
o The real time clock module is the one in the figure below (front and back
view). When you first use this module, you need to solder some header
pins. As you can see in the picture above, the module has a backup battery
installed. This allows the module to retain the time, even when it’s not
being powered up.
38
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Buzzer:
RELAY MODULE:
39
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
PROCEDURE:
o Connect vcc- 3v to the node mcu and connect GND to GND pin of
the Node Mcu.
o Connnect SDA of the rtc module to the node mcu pin -D2
o Connect SCL of the rtc module to the node mcu pin -D3
o SQW AND 32K is not used in the project
o Add the library file to the Arduino IDE “RTC lib by Adafruit” ,
Install the librarys from manage librarys
o Connect the buzzer to the relay module .
o Connect the relay VCC,GND,IN pins with repective pins of the node
mcu.
SOURCE CODE:
#include "config.h"
#include "RTClib.h"
RTC_DS1307 rtc;
int h1,m1;
String h,m;
/************************ Example Starts Here *******************************/
void setup() {
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running, let's set the time!");
// When time needs to be set on a new device, or after a power loss, the
// following line sets the RTC to the date & time this sketch was compiled
40
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// connect to io.adafruit.com
io.connect();
// we are connected
Serial.println();
Serial.println(io.statusText());
void loop() {
io.run();
DateTime now = rtc.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
41
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Serial.print(now.second(), DEC);
Serial.println();
// Check to see if the morning scheduled trigger has executed
if ((now.hour() == h1)&& (now.minute
minute() == m1)) {
Serial.println("Alarm ON");
digitalWrite(RELAY_POWER_PIN,
RELAY_POWER_PIN, HIGH HIGH);
delay(500);
Serial.println("Alarm OFF");
digitalWrite(RELAY_POWER_PIN,
RELAY_POWER_PIN, LOW LOW);
delay(50);
}
delay(2000);
}
void handleMessage(AdafruitIO_Data
ta *data) {
Serial.print("feed
"feed received new data <
<- ");
Serial.println(data->toChar());
OUTPUT:
42
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Expt. No. 10
Date: Design a controller of light using Alexa and Arduino
IOT Cloud
Aim:To design a controller of light using Alexa and Arduino IOT Cloud.
Components:
Hardware : 1.NodeMcu
2.Relay
3.Bulb,Bulb holder
Software: 1.Arduino IDE
2.Adafruit IO platform & libraries.
3.Alexa App in Playstore.
Connections:
Relay Connected to NodeMcu
Power Supply connectd to NodeMcu
Bulb Connected to Relay.
Description:
Now you can securely connect Alexa to your Arduino IoT
Cloud projects with no additional coding required. You could use Alexa to
turn on the lights in the living room, check the temperature in the bedroom,
start the coffee machine, check on your plants, find out if your dog is
sleeping in the doghouse… the only limit is your imagination!
Procedure:
>First you have to search for the IFTTT in google,then open the first page.
43
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
ADD
44
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
45
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
46
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
>then select “say a specific phrase” then we have to give a new phrase under
‘what phrase?’ as ”trigger lights on”.
>then select “say a specific phrase” then we have to give a new phrase under
‘what phrase?’ as ”trigger lights off”.
>Then send data to Adafruit IO.
>then create a new feed”Alexa”
>then save the data.
>Now you have to create a new Action as “HIGH” and “LOW”.
Source Code:
#include "config.h"
#define LED_PIN 13
47
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
SPIWIFI_SS,
NINA_ACK, NINA_RESETN, NINA_GPIO0, &SPIWIFI);
#else
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
#endif
Output:
49
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Expt. No. 11
Date: Design an arduino colud based system to interact with
a simple webpage
Aim:To Design an arduino colud based system to interact with a simple webpage.
Hardware required :
• Node mcu
• Buzzer
• Relay
• Light
• Connecting wires
Software required:
• Arduino IDE
• Google chrome
Description:
Procedure:
• Setup the arduino IDE for nodemcu.and place the code.
• Hardware configuration:
51
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
• When we press on button in web page bulb will on and when we press of
button the bulb will off.
Source code:
#include <ESP8266WiFi.h>
const char* ssid = "IOTLAB";
const char* password = "Iotlab@123";
WiFiServerserver(80);
String header;
String output5State = "off";
52
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
void loop(){
WiFiClient client = server.available();
if (client) {
Serial.println("New Client.");
String currentLine = "";
currentTime = millis();
previousTime = currentTime;
while (client.connected() &¤tTime - previousTime<= timeoutTime) {
currentTime = millis();
if (client.available()) {
char c = client.read();
Serial.write(c);
header += c;
if (c == '\n') {
if (currentLine.length() == 0) {
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
Serial.println("GPIO 5 on");
output5State = "on";
digitalWrite(output5, HIGH);
} else if (header.indexOf("GET /5/off") >= 0) {
Serial.println("GPIO 5 off");
output5State = "off";
digitalWrite(output5, LOW);
} else if (header.indexOf("GET /4/on") >= 0) {
Serial.println("GPIO 4 on");
output4State = "on";
digitalWrite(output4, HIGH);
} else if (header.indexOf("GET /4/off") >= 0) {
Serial.println("GPIO 4 off");
output4State = "off";
digitalWrite(output4, LOW);
}
client.println("<!DOCTYPE html><html>");
client.println("<head><meta name=\"viewport\" content=\"width=device-width,
initial-scale=1\">");
client.println("<link rel=\"icon\" href=\"data:,\">");
client.println("<style>html { font-family: Helvetica; display: inline-block; margin:
0px auto; text-align: center;}");
client.println(".button { background-color: #195B6A; border: none; color: white;
padding: 16px 40px;");
client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor:
pointer;}");
client.println(".button2 {background-color: #77878A;}</style></head>");
client.println("<body><h1>PBRVITS Web Server</h1>");
client.println("<p>GPIO 5 - State " + output5State + "</p>");
if (output5State=="off") {
client.println("<p><a href=\"/5/on\"><button
class=\"button\">ON</button></a></p>");
} else {
client.println("<p><a href=\"/5/off\"><button class=\"button
button2\">OFF</button></a></p>");
}
client.println("<p>GPIO 4 - State " + output4State + "</p>");
if (output4State=="off") {
client.println("<p><a href=\"/4/on\"><button
class=\"button\">ON</button></a></p>");
} else {
client.println("<p><a href=\"/4/off\"><button class=\"button
button2\">OFF</button></a></p>");
}
client.println("</body></html>");
client.println();
54
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
break;
} else {
currentLine = "";
}
} else if (c != '\r') {
currentLine += c;
}
}
}
header = "";
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
}
Output:
55
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Result: Hence, designing of arduino cloud based system to interact with a simple
webpage was successfully completed.
56
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Expt. No. 12
Date:
Medicine remainder system
Aim: To design the Medicine Alert system which alerts the elderly patients to take
medicines on time.
Components:
software:
1. Adafruit
2. Arduino IDE
Hardware:
1.NODE-MCU
2. connecting wires/jumper wires
3.Rtc module
4. Buzzer
5.4-pin LCD display
Libraries:
1- Adafruit IO Arduino
2. RTC.h Library
3. Node-MCU libraries.
Description:
1. Some people overlook to take care of health because of the Lack of an expert,
people are forced to submit in frequent health related problems .
2.By Analyzing the data an IoT based Reminder system has been developed. It is
designed to assist the patient who forgot to take medicine.
3.By this system, patients will no longer have to worry about their daily medication.
The application will send the notification when its time take medicine.
4.The medicine reminder will facilitate the users to require the right medication on
time.
5.This system provides a real- time monitoring system that allow related people to
monitor the patients activity remotely.
57
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Block diagram:
Circuit Connection:
RTC MAodule:
SCL->D1
SDA-> D2
VCC -> 3.3V/5V
GND->Ground
LCD 4 pin display :
SCL-> D1
SDA-> D2
VCC->3.3V
GND->GND
Buzzer:
Two ends/pins:
One end -> D6 , other end -> GND
Procedure :-
1.Let's get into the Adafruit software process to run the code.
2.Firstly, open the Arduino IDE platform -> go to file -> Examples ->Adafruit I0
Arduino ->Arduino_00_publish. And place the code in that publish file.
3.It will provide another file called “config.h” file.
4.In that config file there are some changes need to be done:
5.we have to provide IO_ Username, IO_KEY which is available in the adafruit.
6. Also we have to provide WIFI_SSID , WIFI_PASS which means wifi network
name & wifi password.
58
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
7.After that go to Adafruit & click on the new dashboard & set a new feed then
click on the new block-> select text block.
8.Now we have to set the alarms (morning, afternoon ,evening/night) for taking
medicines.
9.By setting these alarms the system will remind the medicine to take on time &
alert the patients.
SOURCE CODE :
#include "config.h"
#include "RTClib.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
RTC_DS1307 rtc;
LiquidCrystal_I2C lcd(0x27, 16, 2);
int h1,m1,h2,m2,h3,m3;
String hs1,ms1,hs2,ms2,hs3,ms3;
int Buzzer = 12; //d6
#define RELAY_POWER_PIN 12
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"};
AdafruitIO_Feed *relay = io.feed("Relay");
void setup() {
lcd.begin();
lcd.backlight();
lcd.setCursor(2,0);
lcd.print("Smart Medicine ");
lcd.setCursor(5,1);
lcd.print("Reminder");
delay(2000);
pinMode(Buzzer,OUTPUT);
Serial.begin(115200);
pinMode(RELAY_POWER_PIN, OUTPUT);
while(! Serial);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
while (1) delay(10);
}
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running, let's set the time!");
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
59
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
void loop() {
io.run();
DateTime now = rtc.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
lcd.setCursor(0,0);
lcd.print(now.hour(), DEC);
lcd.setCursor(2,0);
lcd.print(":");
lcd.setCursor(3,0);
lcd.print(now.minute(), DEC);
lcd.setCursor(5,0);
lcd.print(" ");
lcd.setCursor(6,0);
lcd.print(now.day(), DEC);
lcd.setCursor(8,0);
lcd.print("/");
60
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
lcd.setCursor(9,0);
lcd.print(now.month(), DEC);
lcd.setCursor(11,0);
lcd.print("/");
lcd.setCursor(12,0);
lcd.print(now.year(), DEC);
lcd.setCursor(2,1);
lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
delay(1000);
if ((now.hour() == h1)&& (now.minute() == m1)) {
lcd.setCursor(0,0);
lcd.print("Medicen1 Reminder");
lcd.setCursor(0,1);
lcd.print(" !!Alert!! ");
digitalWrite(RELAY_POWER_PIN, HIGH);
delay(500);
lcd.clear();
Serial.println("Medicen1 reminder OFF");
digitalWrite(RELAY_POWER_PIN, LOW);
delay(50);
}
lcd.setCursor(0,0);
lcd.print("Medicen2 Reminder");
lcd.setCursor(0,1);
lcd.print(" !!Alert!! ");
digitalWrite(RELAY_POWER_PIN, HIGH);
delay(500);
lcd.clear();
Serial.println("Medicen2 reminder OFF");
digitalWrite(RELAY_POWER_PIN, LOW);
delay(50);
}
if ((now.hour() == h3)&& (now.minute() == m3)) {
lcd.setCursor(0,0);
61
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
lcd.print("Medicen3 Reminder");
lcd.setCursor(0,1);
lcd.print(" !!Alert!! ");
digitalWrite(RELAY_POWER_PIN, HIGH);
delay(500);
lcd.clear();
Serial.println("Medicen3 reminder OFF");
digitalWrite(RELAY_POWER_PIN, LOW);
delay(50);
}
//delay(1000);
}
m1 = ms1.toInt();
Serial.println(m1);
h2 = hs2.toInt();
Serial.println(h2);
m2 = ms2.toInt();
Serial.println(m2);
h3 = hs3.toInt();
Serial.println(h3);
m3 = ms3.toInt();
Serial.println(m3);
62
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
OUTPUT :
63
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Expt. No. 13
Date: Design a system which connects your door to the cloud
and open it from anywhere
Aim:To design a system which connects your door to the cloud and open it from
anywhere
Hardware Requirements:
1.Relay module
2.NodeMcu
3.5v power supply
4.12v power supply
5.jumper wires
6.EM(electromagnetic lock)
Software Requirements:
1.Arduino IDE
2.Adafruit IO adruino library
3.ESP8266 Module
Description:
EM lock stands for electromagnetic lock, which is a type of lock that uses an
electromagnet to hold the door closed. To design a system that connects your door
to the cloud and allows you to open it from anywhere using an EM lock, you will
need the following components:
1. An EM lock: An EM lock is an electronic lock that uses an electromagnet to
hold the door closed. It can be easily installed on your door and is compatible with
most access control systems.
2. A Wi-Fi enabled access control system: A Wi-Fi enabled access control
system is a device that connects your EM lock to the internet. It allows you to
control the lock from anywhere.
64
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
3. A cloud
oud server: A cloud server is a remote server that stores data and
provides services over the internet. In this case, it will store the access credentials
for your lock and allow you to remotely access and control it.
Block diagram:
Circuit Diagram:
Procedure:
1.Setup Arduino IDE for node MCU and register in Adafruit IO platform.
2. open Adafruit IO platform and in IO section > open feeds tab and create a new
feed as Door
3.in dashboards tab> create a new dashboard as lock and add a new data elem
element to
layout
65
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
void loop() {
io.run();
}
void handleMessage(AdafruitIO_Data *data) {
String cmd = data->value();
66
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
}
else if (cmd == "LOW") {
Serial.println("Rx LOW");
digitalWrite(LED_PIN, LOW);
}
}
Output:
Conclusion: Design a system which connects your door to the cloud and open it
67
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Expt. No. 14
Date: Build a line follower robot using raspberry pi
68
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
Block Diagram:
Procedure :
1. Give the power supply to robot and then switch on it .
2. Make sure your laptop, mobile, raspberry pi should be connected to same
hotspot.
3. Install the vnc viewer and then open it.
4. In mobile phone connected devices it will show the raspberry pi Ip address
5. Enter that Ip address in vnc viewer .
6. It will ask username and password .
69
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
GPIO.setup(L_sensor, GPIO.IN)
GPIO.setup(R_sensor, GPIO.IN)
GPIO.output(m10, GPIO.LOW)
GPIO.output(m11, GPIO.LOW)
GPIO.output(m20, GPIO.LOW)
GPIO.output(m21, GPIO.LOW)
print("Here we go! Press CTRL+C to exit")
try:
while 1:
if (GPIO.input(L_sensor) == False and GPIO.input(R_sensor) == True): #
pressed
GPIO.output(m10,GPIO.LOW)
GPIO.output(m11,GPIO.LOW)
GPIO.output(m20,GPIO.HIGH)
GPIO.output(m21,GPIO.LOW)
print('Turn Left')
if ((GPIO.input(L_sensor) == True) and (GPIO.input(R_sensor) == False)): #
pressed
GPIO.output(m10,GPIO.HIGH)
GPIO.output(m11,GPIO.LOW)
GPIO.output(m20,GPIO.LOW)
70
IOT DEVELOPMENT USING CLOUD LAB DEPARTMENT OF CSE
GPIO.output(m21,GPIO.LOW)
print('Turn Right')
if ((GPIO.input(L_sensor) == True) and (GPIO.input(R_sensor) == True)):
# pressed
GPIO.output(m10,GPIO.HIGH)
GPIO.output(m11,GPIO.LOW)
GPIO.output(m20,GPIO.HIGH)
GPIO.output(m21,GPIO.LOW)
print('Move forward')
if ((GPIO.input(L_sensor) == False) and (GPIO.input(R_sensor) == False)):
# pressed
GPIO.output(m10,GPIO.LOW)
GPIO.output(m11,GPIO.LOW)
GPIO.output(m20,GPIO.LOW)
GPIO.output(m21,GPIO.LOW)
print('Stop')
pwm.stop()
GPIO.cleanup()
Result :
Hence, we had successfully built a line follower robot using raspberry pi.
71