Professional Documents
Culture Documents
Name of faculty
TABLE OF CONTENTS
LAB OUTCOMES
After completion of this lab course students will be able to
LO1: Interpret the vision of IoT from a global context.
LO2: Determine the Market perspective of IoT.
LO3: Compare and Contrast the use of Devices, Gateways and Data Management in IoT. LO4:
Implement state of the art architecture in IoT.
LO5: Illustrate the application of IoT in Industrial Automation and identify Real World Design
Constraints.
Vision of Department
To establish an acknowledged Department of academics in the field of Electronics and Communication
Engineering.
Mission of Department
1. To equip the students with strong foundations to enable them for continuing education in the field of
Electronics and Communication Engineering.
2. To provide quality education & to make the students entrepreneur and employable.
3. To undertake research and development in the field of Electronics and Communication Engineering.
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
PROGRAMME OUTCOMES
PO 1: Engineering Knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex engineering problems.
PO 2: Problem Analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics, natural
sciences, and engineering sciences.
PO 3: Design/Development of Solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate consideration for
the public health and safety, and the cultural, societal, and environmental considerations.
PO 4: Conduct Investigations of Complex Problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of the
information to provide valid conclusions.
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
PO 5: Modern Tool Usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools prediction and modeling to complex engineering activities with an
understanding of the limitations.
PO 6: The Engineer and Society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the
professional engineering practice.
PO 7: Environment and Sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and the need for
sustainable development.
PO 8: Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
PO 9: Individual and Team Work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
PO 10: Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and write effective
reports and design documentation, make effective presentations, and receive clear instructions.
PO 11: Project Management and Finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and leader in
team, to manage projects and in multidisciplinary environments.
PO 12: Life-Long Learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
EXPERIMENT LIST
8EC4-21: IOT Lab
Credit: 1 Max. Marks: 50 (IA:30, ETE:20)
Los PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
LO 1 - - - 3 3 3 - - - - - -
LO 2 - - - 3 3 3 2 - - - - -
LO 3 - - 3 3 3 2 - - - - - -
LO 4 - 3 3 3 2 3 3 - - - - -
LO 5 - - 3 3 3 2 - - - - - -
ROTOR PLAN
ROTOR 1
1. Study the fundamental of IOT softwares and components.
2. Familiarization with Arduino/Raspberry Pi and perform necessary software
installation.
3. To interface LED/Buzzer with Arduino/Raspberry Pi and write a program to
turn ON LED for 1 sec after every 2 seconds.
4. To interface Push button/Digital sensor (IR/LDR) with Arduino/Raspberry Pi
and write a program to turn ON LED when push button is pressed or at
sensor detection.
5. To interface DHT11 sensor with Arduino/Raspberry Pi and write a program to
print temperature and humidity readings.
6. To interface motor using relay with Arduino/Raspberry Pi and write a
program to turn ON motor when push button is pressed.
7. To interface OLED with Arduino/Raspberry Pi and write a program to print
temperature and humidity readings on it.
ROTOR 2
8. To interface Bluetooth with Arduino/Raspberry Pi and write a program to
send sensor data to smartphone using Bluetooth.
9. To interface Bluetooth with Arduino/Raspberry Pi and write a program to
turn LED ON/OFF when ‘1’/’0’ is received from smartphone using Bluetooth.
10 Write a program on Arduino/Raspberry Pi to upload temperature and
humidity data to thingspeak cloud.
11. Write a program on Arduino/Raspberry Pi to retrieve temperature and
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
1
2
3
4
5
6
Rotor:- II
7
8
9
10
11
12
RESPONSIBILITIES OF USERS
Users are expected to follow some fairly obvious rules of conduct:
ALWAYS
Enter the lab on time and leave at proper time.
Wait for the previous class to leave before the next class enters.
Turn off the machine before leaving the lab unless a member of lab staff has specifically told you
not to do so.
If you notice a problem with a piece of equipment (e.g. a computer doesn't respond) or the room
in general (e.g. cooling, heating, lighting) please report it to lab staff immediately. Do not attempt
to fix the problem yourself.
NEVER
Don't abuse the equipment.
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
Do not adjust the heat or air conditioners. If you feel the temperature is not properly set, inform
lab staff; we will attempt to maintain a balance that is healthy for people and machines.
Do not remove printers and machines from the network without being explicitly told to do so by
lab staff.
Don’t use internet, internet chat of any kind in your regular lab schedule.
No hardware including USB drives can be connected or disconnected in the labs without prior
permission of the lab in-charge.
Don’t bring any external material in the lab, except your lab record, copy and books.
Don’t bring the mobile phones in the lab. If necessary then keep them in silence mode.
All the students are supposed to prepare the theory regarding the next experiment.
Students are supposed to bring the practical file and the lab copy.
Previous programs should be written in the practical file.
All the students must follow the instructions, failing which he/she may not be allowed in the
lab.
ZERO LAB
14 WoT4 Constrained Devices as Web Servers – in IoT any smart physical object can act
as directly accessible data or application server
15 Smart Environments – how to tag, sense and actuate environments to become smart
environments.
16 Low Energy & Sustainable IoT – without which IoT is not scalable and its cons will
outweigh its pros.
17-18 IoT Data Processing and Management – why it’s not just about data queries and big
data
19-20 IoT Security and Privacy – guarding against internet attacks by any smart thing and
governing how things can profile us humans IoT Security and Privacy – guarding against
internet attacks by any smart thing and governing how things can over profile us humans.
EXPERIMENT NO: 1
THEORY:
Introduction to IOT
With the increasing bandwidth availability and cheap hardware cost, IoT is changing the
industry landscapes in scale. From medical, construction, governance to Insurance, BFS
the use cases of IoT are spreading day by day. The IT spending of multinational
corporations, banks, and other institutes are also increasing along with all these
developments. Though the hardware, software and infrastructure requirements of Industry
grade IoT differ from domain to domain, the basic components remain the same. In this
article, we will discuss the standard components of an IoT system.
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
We can list down the below components as key parts of an IoT ecosystem.
For any IoT use case, the components of the endpoint are sensors. Sensors capture electric
pulse or analog signals which are passed through the IoT ecosystems. Based on the use
case and domains RFID, temperature sensors, light sensors, electromagnetic sensors, etc.
are used. For example, smartphones and smart wearables are equipped with sensors like
accelerometer, Gyroscope sensors, etc. Data obtained from these IoT endpoints can be
used in various domains like Human activity recognition, medical stability, etc. Based on
the use case and precision requirements sensors can be chosen keeping the following
parameters in mind
In a typical IoT ecosystem, sensors are connected with computation layers and intelligent
layers via network or connectivity layers. IoT endpoints need to be always connected with
various other components seamlessly over the connectivity layer. Based on the scale of
the implementations IoT components can be connected overs LANs, MANs or WANs. It
can also be connected through telephony networks like LTE (Long Term Evolution or
popularly known as 4G Network) or light-based technologies like Li-Fi (where light is
used as a mode of communication to maintain interconnections). For local use cases,
Bluetooth and Wi-Fi can also be used.
An IoT network consists of various network components like routers, gateways, switches,
various network protocols, etc. Based on the use case and domain proper network
infrastructure is needed to be chosen.
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
3. Security Layers
The heart of any industry-grade IoT user story is ‘data’. In a standard use case, analog or
digital signal is acquired by sensors and the signal is then converted to a format on top of
which AI/ML components can work. In the total flow of data, proper security systems and
methodologies need to be enforced. The data can be compromised in any layers starting
from the data acquisition to business insights derivations. We can enforce proper security
by using strong encryption in various layers of communication, using proper firmware and
anti-malware systems, etc.
4. Compute Engines
Industry grade IoT systems typically use multiple technology stacks inside an umbrella.
For example in insurance premiums can be calculated as a variable component as per the
driving pattern of the insurer. The data collected from smart devices are converted and
preprocessed to a format on which machine learning models are developed. Customers
can use any cloud partners of their choice or develop their own infrastructure to execute a
use case.
For example, the compute engines from PaaS (Product as a service) or IaaS (IoT as
service) will differ from on-premise systems.
Sensitive information flow over the various components of the IoT ecosystem. To cope up
with this the systems need to adhere to proper technique and governance standard and
KPIs
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
Most of the practical and industry-grade IoT use cases are intended to derive business
insights or actionable recommendations. The preprocessed data need to be integrated with
ML components and the trained models are deployed to the production environment. The
choice of the technology stack to develop the intelligent business component is dependent
on the compatibility with the in house existing systems, the scale of the business, the
complexity of the use case, and precision and latency requirements of the domain,
company partnerships, etc.
For example in the heavy manufacturing industry, the data obtained from various
machinery can be used to predict the fault of the machine which can help to reduce
manufacturing downtime and increase efficiency.
Viva Question
EXPERIMENT NO: 2
THEORY:
Arduino Uno is a microcontroller board based on the ATmega328P (datasheet). It has 14
digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16
MHz ceramic resonator (CSTCE16M0V53-R0), a USB connection, a power jack, an ICSP
header and a reset button.
"Uno" means one in Italian and was chosen to mark the release of Arduino
Software (IDE) 1.0. The Uno board and version 1.0 of Arduino Software (IDE)
were the reference versions of Arduino, now evolved to newer releases. The Uno
board is the first in a series of USB Arduino boards, and the reference model for
the Arduino platform; for an extensive list of current, past or outdated boards see
the Arduino index of boards.
Viva Question
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
EXPERIMENT NO: 3
APPARATUS:
Arduino/Raspberry Pi
LED/Buzzer
THEORY:
Introduction:
Raspberry Pi is a sort of jack of all trades when it comes to being a single board computer
based on the Arm processor. The general purpose input output (GPIO) pins on the
Raspberry Pi speak and listen to the outside world and can be controlled or programmed.
Each pin has a specific role. Its hardware has a limited number of digital I/O pins. You
can add 16 digital I/O pins by connecting a Pi wedge B + expander chip to the Raspberry
Pi hardware.A discrete signal (digital signal) supplied to the Raspberry Pi is known as
digital input.
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
PROGRAM :
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
Viva Question
1. Can you write a query to insert the data into MongoDB?
2. Explain how did you insert bulk data in MongoDB, can write the query for that?
3. What is DB command?
4. What are the layers of OSI?
5. List some Advance IOT projects?
6. What is the layout GPIO pins?
7. How many pins are available in Arduino UNO board?
8. Which Latest model of Raspberry pi now? And it’s features?
9. Do you have a better idea for the saving electricity?
10.Difference between Arduino and Raspberry Pi?
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
EXPERIMENT NO: 4
APPARATUS:
Arduino/Raspberry Pi
LED/Buzzer
THEORY:
Introduction:
Raspberry Pi is a sort of jack of all trades when it comes to being a single board computer
based on the Arm processor. The general purpose input output (GPIO) pins on the
Raspberry Pi speak and listen to the outside world and can be controlled or programmed.
Each pin has a specific role. Its hardware has a limited number of digital I/O pins. You
can add 16 digital I/O pins by connecting a Pi wedge B + expander chip to the Raspberry
Pi hardware.
A discrete signal (digital signal) supplied to the Raspberry Pi is known as digital input.
This signal can be generated manually using a push button switch.
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
Push button switch is a switch which provides connectivity between its terminals when
pressed. When the button is released terminals get disconnected.
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
PROGRAM :
State = 1
Sleep(1)
Viva Question
EXPERIMENT NO: 5
AIM: To interface DHT11 sensor with Arduino/Raspberry Pi and write a program to print
temperature and humidity readings.
APPARATUS:
Arduino/Raspberry Pi
DHT11 sensor
Bread Board
Jumper Wires
THEORY:
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
Introduction:
The term DHT is an abbreviation of Digital Humidity and Temperature sensor. DHT11
consists of a resistive humidity sensor, NTC temperature sensor and an 8-
bit microcontroller providing cost effectiveness, anti-interference ability, excellent
quality and fast response.
Specifications
Working
Description
PROGRAM
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "DHT.h"
#define DHTPIN 2
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
void setup() {
delay(2000);
dht.begin();
delay(2000);
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
delay(2000);
else {
dtostrf(t,2,1,temp_buff);
strcat(temp_disp_buff,temp_buff);
dtostrf(h,2,1,hum_buff);
strcat(hum_disp_buff,hum_buff);
display.clearDisplay();
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println(temp_disp_buff);
display.println(hum_disp_buff);
display.display();
delay(2000);
Viva Question
EXPERIMENT NO: 6
APPARATUS:
Arduino/Raspberry Pi
Relay
Motor
THEORY:
Connections:
Motor positive - Relay switch 1 COM input
Motor negative - Relay switch 2 COM input
9v battery positive - Relay switch 1 NO & Relay switch 2 NO
9v battery negative - Relay switch 1 NC & Relay switch 2 NC
Each relay switch has three inputs
NO (Normally open) ,COM (Common) and NC (Normally closed)
In this project, both wires from the motor will connect to both of the COM (middle) inputs
of the relay switches.
The positive wire from the 9v battery will connect to both of the NO (top) inputs.
The negative wire from the 9v battery will connect to both of the NC (bottom) inputs.
This external power supply (9v battery) will be used to power the motor. This can be
changed to control the speed of the motor.
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
Connection:
Arduino 5v pin - Relay module VCC pin
Arduino GND pin - Relay module GND pin
Arduino pin#7 - Relay module IN1
Arduino pin#8 - Relay module IN2
After we finish connecting the motor, all we need to do is power the relay switch module
itself. using the arduino, we can connect the wires and send signals to activate the relay
switches.
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
PROGRAM :
Viva Question
1. Can you write a query to insert the data into MongoDB?
2. Explain how did you insert bulk data in MongoDB, can write the query for that?
3. What is DB command?
4. What are the layers of OSI?
5. List some Advance IOT projects?
6. What is the layout GPIO pins?
7. How many pins are available in Arduino UNO board?
8. Which Latest model of Raspberry pi now? And it’s features?
9. Do you have a better idea for the saving electricity?
10.Difference between Arduino and Raspberry Pi?
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
EXPERIMENT NO: 7
APPARATUS:
Arduino/Raspberry Pi
DHT11 sensor
0.96 inch OLED
Bread Board
Jumper Wires
THEORY:
Introduction:
The term DHT is an abbreviation of Digital Humidity and Temperature sensor. DHT11
consists of a resistive humidity sensor, NTC temperature sensor and an 8-
bit microcontroller providing cost effectiveness, anti-interference ability, excellent
quality and fast response.
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
Specifications
Working
Description
PROGRAM
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "DHT.h"
#define DHTPIN 2
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
void setup() {
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
delay(2000);
dht.begin();
delay(2000);
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
delay(2000);
else {
dtostrf(t,2,1,temp_buff);
strcat(temp_disp_buff,temp_buff);
dtostrf(h,2,1,hum_buff);
strcat(hum_disp_buff,hum_buff);
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
display.setCursor(0,0);
display.println(temp_disp_buff);
display.println(hum_disp_buff);
display.display();
delay(2000);
Viva Question
EXPERIMENT NO: 8
APPARATUS:
An Arduino. Any model can be used, but all code and schematics in this
manual will be for the Uno.
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
THEORY:
To use the HC-05 Bluetooth module, simply connect the VCC to the 5V output on the
Arduino, GND to Ground, RX to TX pin of the Arduino, and TX to RX pin of the
Arduino. If the module is being used for the first time, you’ll want to change the name,
passcode etc. To do this the module should be set to command mode. Connect the Key
pin to any pin on the Arduino and set it to high to allow the module to be programmed.
Circuit Diagram-
1. connection with Bluetooth
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
PROGRAM
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
#include <SoftwareSerial.h>
#include "DHT.h"
#define DHTPIN 2
SoftwareSerial BTSerial(4,5);
void setup() {
Serial.begin(9600);
BTSerial.begin(38400
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
delay(500);
while (BTSerial.available()) {
Serial.write(BTSerial.read());
delay(500);
while (BTSerial.available()) {
Serial.write(BTSerial.read());
dht.begin();
void loop()
{ char c;
if(Serial.available())
c = Serial.read();
if(c=='t')
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
readSensor();
}}
void readSensor() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
return;
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print(hic);
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
Serial.print(" *C ");
Viva question-
EXPERIMENT-9
APPARATUS
An Arduino. Any model can be used, but all code and schematics in this manual will be
for the Uno.
An Android Smartphone that has Bluetooth.
HC-05 Bluetooth Module
Android Studio (To develop the required Android app)
USB cable for programming and powering the Arduino
LED and resistor
Theory
HC 05/06 works on serial communication.here the android app is designed to send serial
data to the Bluetooth module when a certain button is pressed. The Bluetooth module at
the other end receives the data and sends it to Arduino through the TX pin of the
Bluetooth module(RX pin of Arduino). The Code fed to Arduino checks the received data
and compares it.If received data is 1 the LED turns on turns OFF when received data is 0
PROGRAM
void setup()
Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data
transmission
void loop()
data = Serial.read(); //Read the incoming data and store it into variable data
}}
CIRCUIT DIAGRAM
Download the
application from
Amazon App Store or
Github.
devices.3. Pair your smartphone to the HC 05/06 by entering default password 1234 OR
0000.
Install the LED application on your Android device.
Open the application.
VIVA QUESTION
EXPERIMENT-10
APPARATUS
Arduino Uno
ESP8266 WiFi Module
DHT11 Sensor
Breadboard
Jumper Wires
CIRCUIT DIAGRAM
IOT LAB MANUAL
PCE/ECE/VI SEM/ 8EC 4-21
Procedure:
For creating your channel on Thingspeak you first need to Sign up on Thingspeak. In case if
you already have account on Thingspeak just sign in using your id and password.
Click on Sing up if you don‘t have account and if you already have account click on sign in.
Once you Sign in after your account verification, create a new channel by clicking
―New Channel‖ button. After clicking on ―New Channel‖, enter the Name and Description
of the data you want to upload on this channel. For example I am sending my DHT11 sensor
data, so I named it as DHT11 data.
Enter the name of your data ‗Temperature‘ in Field1 and ‗Humidity‘ in Field2. If you want
to use more Fields you can check the box next to Field option and enter the name and
description of your data.
To send data to Thingspeak, we need a unique API key, which we will use later in our code
to upload our sensor data to Thingspeak Website.
Click on ―API Keys‖ button to get your unique API key for uploading your sensor data.
PROGRAM
#include <stdlib.h>
#include <DHT.h>
String msg = "GET /update?key=Your API Key"; //change it with your key...
float temp;
int hum;
String tempC;
int error;
void setup()
Serial.println("AT");
delay(5000);
if(Serial.find("OK")){
connectWiFi();
void loop(){
start:
error=0;
temp = dht.readTemperature();
hum = dht.readHumidity();
char buffer[10];
updateTemp();
if (error==1){
goto start;
delay(5000);
}
void updateTemp(){
cmd += IP;
cmd += "\",80";
Serial.println(cmd);
delay(2000);
if(Serial.find("Error")){
return;
cmd = msg ;
cmd += "&field1=";
cmd += tempC;
cmd += "&field2=";
cmd += String(hum);
cmd += "\r\n";
Serial.print("AT+CIPSEND=");
Serial.println(cmd.length());
if(Serial.find(">")){
Serial.print(cmd);
else{ Serial.println("AT+CIPCLO
SE");
//Resend...
error=1;
boolean connectWiFi(){
Serial.println("AT+CWMODE=1");
delay(2000);
String cmd="AT+CWJAP=\"";
cmd+=SSID;
cmd+="\",\"";
cmd+=PASS;
cmd+="\"";
Serial.println(cmd);
delay(5000);
if(Serial.find("OK")){
return true;
}else{
return false;
}
VIVA QUESTION-
AIM: Write a program on Arduino/Raspberry Pi to retrieve temperature and humidity data from
thingspeak cloud.
APPARATUS
Arduino Uno
ESP8266 WiFi Module
DHT11 Sensor
Breadboard
Jumper Wires
CIRCUIT DIAGRAM
PROGRAM
#include "ThingSpeak.h"
#include <ESP8266WiFi.h>
WiFiClient client;
//---------Channel Details--------//
// //
void setup()
Serial.begin(115200)
WiFi.mode(WIFI_STA);
ThingSpeak.begin(client);
void loop()
// Network //
if (WiFi.status() != WL_CONNECTED)
Serial.print("Connecting to ");
Serial.print(ssid);
Serial.println("....");
WiFi.begin(ssid, pass);
delay(5000);
}
//--------- End of Network connection-------//
// Channel 1 //
statusCode = ThingSpeak.getLastReadStatus();
if (statusCode == 200)
Serial.print("Temperature: ");
Serial.println(temp);
else
delay(100);
// End of Channel 1 //
// Channel 2 //
if (statusCode == 200)
Serial.print("Humidity: ");
Serial.println(humidity);
else
delay(100);
// End of Channel 2 //
VIVA QUESTION
1.What is the function for reading humidity from DHT Sensor from Arduino?
APPARATUS
Raspberry Pi
Micro SD Card
Power Supply
Ethernet Cord or WiFi dongle (The Pi 3 has WiFi inbuilt)
Procedure
1. Before we get started with installing MySQL to our Raspberry Pi, we must first update our
package list and all installed packages.
Terminals
2.The next step is to install the MySQL server software to your Raspberry Pi.
Installing MySQL to the Raspberry Pi is a simple process and can be done with the following
command.
Terminals
By default, MySQL is installed without any password set up meaning you can access the
MySQL server without any authentication.
sudo mysql_secure_installation
Just follow the prompts to set a password for the root user and to secure your MySQL
installation. For a more secure installation, you should answer ―Y‖ to all prompts when
asked to answer ―Y‖ or ―N―. These prompts will remove features that allows someone
to gain access to the server easier.
Make sure you write down the password you set during this process as we will need to use it
to access the MySQL server and create databases and users for software such as WordPress
or PHPMyAdmin.
4. Now if you want to access your Raspberry Pi‘s MySQL server and start making changes to
your databases, you can enter the following command.
5. You will be prompted to enter the password that we just created in step 3 for MySQL‘s
root user.
6. You can now enter MYSQL commands to create, alter, and delete databases. Through this
interface, you can also create or delete users and assign them the rights to manage any
database.
7. There are two different ways you can quit out of the MYSQL command line, the first of
those is to type ―quit;‖ into the MySQL interface.
The other way of quitting out of the MYSQL command line is to press CTRL + D.
8. At this point, you will now have successfully setup MySQL on your Raspberry Pi. Our
next few sections will go into making better use of this database.
B. Performing Queries:
1. Before we proceed to create a MySQL user and database on our Raspberry Pi, we must
first log back into the MySQL command-line tool.
Run the following command to log in to the MySQL command line. You will be prompted to
enter the password for the ―root‖ account that you set up earlier.
Terminal$
This command is super simple and is just ―CREATE DATABASE‖ followed by the name
that you want to give the database. In our example, we will be calling this database
―exampledb―.
mysql >
3. Next, we will create a MySQL user that we will assign to our new database. We can create
this user by running the following command. For this example, we will be calling the user
―exampleuser‖ and giving it the password ―pimylifeup―. When creating your own, make sure
you replace both of these.
4. With the user created, we can now go ahead and grant all privileges to the user so that it
can interact with the database. This command will grant all permissions to our ―exampleuser‖
for all tables within our ―exampledb‖ database.
5. The final thing we need to do for both our MySQL database and user to be finalized is to
flush the privilege table. Without flushing the privilege table, the new user won‘t be able to
access the database.
FLUSH PRIVILEGES;
Insecure Method
If you have direct access to the remote server and aren't worried about security
Secure Method
If you can SSH into the remote server you can use this
INDUSTRIAL ELECTRONICS LAB
PCE/ECE/VI SEM/ 6EC10A
Viva question