Professional Documents
Culture Documents
IoT Lab Manual - VTU (21EC581) by Raviteja Balekai
IoT Lab Manual - VTU (21EC581) by Raviteja Balekai
IoT Lab Manual - VTU (21EC581) by Raviteja Balekai
Internet of Things
Lab Manual
Prepared By:
In Collaboration with
Exp.No Experiments
i. To interface LED/Buzzer with Arduino/Raspberry Pi and write a program to
turn ON LED for 1 sec after every 2 seconds.
EXPERIMENT – 1
i. To interface LED/Buzzer with Arduino/Raspberry Pi and write a program to turn
ON LED for 1 sec after every 2 seconds.
AIM: Write a program to turn ON LED/ Buzzer for 1 sec after every 2 seconds with
Arduino/ Raspberry Pi.
COMPONENTS REQUIRED:
CONNECTION DIAGRAM:
CODING:
Embedded C
Python code
import time
# blinking function
def blink(pin):
GPIO.output(pin,GPIO.HIGH)
time.sleep(1)
GPIO.output(pin,GPIO.LOW)
time.sleep(2)
return
ii. To interface Push button/Digital sensor (IR/LDR) with Arduino UNO and write a
program to turn ON LED when push button is pressed or at sensor detection.
CASE -1
AIM: Write a program to turn ON LED when push button is pressed using Arduino UNO.
COMPONENTS REQUIRED:
1. Arduino UNO.
2. Push button.
3. LED.
4. Resistor (10KΩ)
5. Connecting cable or USB cable.
6. Breadboard.
7. Jumper wires.
CONNECTION DIAGRAM:
CODING:
Embedded C
void setup()
{
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop()
{
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH)
{
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else
{
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
RESULT: Controlling LED by pressing push button using Arduino UNO has successfully
executed.
CASE -2
AIM: Write a program to turn ON LED at sensor (LDR) detection using Arduino UNO.
COMPONENTS REQUIRED:
1. Arduino UNO.
2. LDR.
3. LED.
4. Resistor (100KΩ)
5. Connecting cable or USB cable.
6. Breadboard.
7. Jumper wires.
CONNECTION DIAGRAM:
CODING:
Embedded C
if (sensorValue<400)
digitalWrite(13, HIGH);
else
digitalWrite(13, LOW);
delay(1000);
}
RESULT: Controlling LED by interfacing LDR with Arduino UNO has successfully executed.
CASE -3
AIM: Write a program to turn ON LED at sensor (IR) detection using Arduino UNO.
COMPONENTS REQUIRED:
1. Arduino UNO.
2. IR.
3. LED.
4. Resistor (220Ω)
5. Connecting cable or USB cable.
6. Breadboard.
7. Jumper wires.
CONNECTION DIAGRAM:
(c) IR sensor
CODING:
Embedded C
int IR=9;
int IRvalue;
int LED=13;
void setup()
{
Serial.begin(9600);
pinMode(IR, INPUT);
pinMode(LED, OUTPUT); // LED Pin Output
}
void loop()
{
IRvalue=digitalRead(IR);
if (IRvalue==1)
{
digitalWrite(LED, HIGH); // LED High
Serial.println("Object detected");
}
else
{
digitalWrite(LED, LOW);
Serial.println("Object is not detected");
}
delay(1000);
}
RESULT: Object detection by interfacing IR with Arduino UNO has successfully executed.
EXPERIMENT – 2
i. To interface DHT11 sensor with Arduino/Raspberry Pi and write a program to
print temperature and humidity readings.
COMPONENTS REQUIRED:
CONNECTION DIAGRAM:
CODING:
Embedded C
#define dht_dpin 2
#include<dht.h>
dht DHT;
void setup()
{
Serial.begin(9600);
Serial.println("Humidity and temperature\n\n");
}
void loop()
{
You need to install PIP before you can install the Adafruit_DHT module:
Python code
import time
#import sys
import Adafruit_DHT
while(1):
humidity, temperature = Adafruit_DHT.read_retry(11, 4) # Sensor ,GPIO Pin
print("-------------------------------------------")
print('Temp:{0:0.1f} C, Humidity:{1:0.1f} %'.format(temperature, humidity))
print("-------------------------------------------")
RESULT: Interfacing of DHT11 with Arduino UNO to print temperature and humidity
readings has successfully executed.
AIM: Write a program to interface OLED/ I2C LCD with Arduino to print temperature and
humidity readings.
COMPONENTS REQUIRED:
CONNECTION DIAGRAM:
Initially run I2C scanner which will find the address of I2C module that is connected to Arduino.
In this case address of I2C OLED module is 0x3C.
Initially run I2C scanner which will find the address of I2C module that is connected to Arduino.
In this case address of I2C LCD module is 0x27.
CODING:
Embedded C
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define dht_dpin 7
#include<dht.h>
dht DHT;
void setup()
{
Serial.begin(115200);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C))
{
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
delay(2000);
display.clearDisplay();
display.setTextColor(WHITE);
}
void loop()
{
delay(5000);
//clear display
display.clearDisplay();
// display temperature
DHT.read11(dht_dpin);
display.setTextSize(1);
display.setCursor(0, 0);
display.print("Temp=");
display.print(DHT.temperature); //print the temperature
display.print(" Celsius");
display.display();
// display humidity
display.setTextSize(1);
display.setCursor(0, 35);
display.print("Humidity=");
display.print(DHT.humidity); //print the humidity
display.print("%");
display.display();
(f) Displaying Temperature and Humidity values on I2C OLED using Arduino UNO
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#define dht_dpin 7
#include<dht.h>
dht DHT;
void setup()
{
Serial.begin(9600);
lcd.begin();
}
void loop()
{
DHT.read11(dht_dpin);
lcd.setCursor(0, 0);//(Col,ROW)
lcd.print("Temp=");
lcd.print(DHT.temperature); //print the temperature
lcd.print("Celsius");
lcd.setCursor(0, 1);//(Col,ROW)
lcd.print("Humidity=");
lcd.print(DHT.humidity); //print the humidity
lcd.print("%");
delay(2000);
}
(g) Displaying Temperature and Humidity values on I2C LCD using Arduino UNO
RESULT: Interfacing of OLED/ I2C LCD and DHT11 with Arduino UNO to print temperature
and humidity readings has successfully executed.
EXPERIMENT – 3
To interface motor using relay with Arduino/Raspberry Pi and write a program to turn
ON motor when push button is pressed.
AIM: Write a program to turn ON motor when push button is pressed using relay with Arduino
UNO.
COMPONENTS REQUIRED:
1. Arduino UNO.
2. Relay.
3. Resistor (10kΩ).
4. Motor.
5. Connecting cable or USB cable.
6. Breadboard.
7. Jumper wires.
CONNECTION DIAGRAM:
CODING:
Embedded C
if(buttonState == HIGH)
{
// Button is pressed, turn ON the motor via relay
digitalWrite(RELAY_PIN, HIGH);
delay(1000); // Delay for motor ON time (1 second in this case)
} else
{
// Button is not pressed, turn OFF the motor via relay
digitalWrite(RELAY_PIN, LOW);
}
}
(c) Interfacing motor with relay and push button using Arduino
RESULT: Motor turn ON/OFF operation when push button is pressed using relay with Arduino
UNO has successfully executed.
EXPERIMENT – 4
To interface Bluetooth with Arduino and write a program to turn LED ON/OFF when
'1'/'0' is received from smartphone using Bluetooth.
AIM: Write a program on ESP32 to turn LED ON/OFF from smartphone using Bluetooth when
'1'/'0' is received.
COMPONENTS REQUIRED:
1. ESP32.
2. LED.
3. Connecting cable or USB cable.
4. Breadboard.
5. Jumper wires.
CONNECTION DIAGRAM:
CODING:
Embedded C
(b) Turning LED ON/OFF operation in ESP32 though smartphone using Bluetooth.
RESULT: LED ON/OFF from smartphone using Bluetooth based on received '1'/'0' data with
ESP32 has successfully executed.
EXPERIMENT – 5
To interface Bluetooth with Arduino/Raspberry Pi and write a program to send sensor
data to smartphone using Bluetooth.
AIM: Write a program on ESP32 to send temperature value using DHT11 sensor to smartphone
using Bluetooth.
COMPONENTS REQUIRED:
1. ESP32.
2. DHT11.
3. Connecting cable or USB cable.
4. Breadboard.
5. Jumper wires.
CONNECTION DIAGRAM:
CODING:
Embedded C
// Interfacing DHT11 with ESP32 and sending data to mobile through Bluetooth
#include <BluetoothSerial.h>
BluetoothSerial SerialBT;
byte BTData;
#include "DHT.h"
DHT dht(2,DHT11); //D4 pin
void setup()
{
Serial.begin(115200);
SerialBT.begin();
Serial.println("Bluetooth Started! Ready to pair...");
}
void loop()
{
Serial.print("Temperature in c :");
Serial.println(dht.readTemperature( ));
String temperatureString = String(dht.readTemperature( ));
SerialBT.println(temperatureString);
delay(2000);
}
RESULT: Sending Temperature data using DHT11 sensor to smartphone using Bluetooth with
ESP32 has successfully executed.
EXPERIMENT – 6
Write a program on Arduino/Raspberry Pi to upload temperature and humidity data to
Thingspeak cloud.
AIM: Write a program on ESP32 to upload temperature and humidity value using DHT11 sensor
to Thingspeak cloud.
COMPONENTS REQUIRED:
1. ESP32.
2. DHT11.
3. Connecting cable or USB cable.
4. Breadboard.
5. Jumper wires.
CONNECTION DIAGRAM:
CODING:
Embedded C
#include <DHT.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <ThingSpeak.h>
#include <Adafruit_Sensor.h>
#define DHTPIN 4
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
const char* ssid = "GMIT";
const char* password = "DAVANGERE";
WiFiClient client;
unsigned long myChannelNumber = 12345;
const char * myWriteAPIKey = "ABCDEFGH";
uint8_t temperature, humidity;
void setup()
{
Serial.begin(9600);
dht.begin();
delay(10);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Print the IP address
Serial.println(WiFi.localIP());
ThingSpeak.begin(client);
}
void loop()
{
temperature = dht.readTemperature();
humidity = dht.readHumidity();
Serial.print("Temperature Value is :");
Serial.print(temperature);
Serial.println("C");
Serial.print("Humidity Value is :");
Serial.print(humidity);
Serial.println("%");
// Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to
store up to 8 different
RESULT: Sending temperature and humidity data using DHT11 sensor to Thingspeak cloud
with ESP32 has successfully executed.
EXPERIMENT – 7
Write a program on Arduino/Raspberry Pi to retrieve temperature and humidity data
from Thingspeak cloud.
AIM: Write a program on ESP32 to retrieve temperature and humidity values using DHT11
sensor from Thingspeak cloud.
COMPONENTS REQUIRED:
1. ESP32.
2. DHT11.
3. Connecting cable or USB cable.
4. Breadboard.
5. Jumper wires.
CONNECTION DIAGRAM:
CODING:
Embedded C
// Retrieving temperature and humidity data from Thingspeak cloud using ESP32
#include <WiFi.h>
#include <ThingSpeak.h>
WiFiClient client;
void setup()
{
Serial.begin(9600);
ThingSpeak.begin(client);
WiFi.disconnect();
delay(3000);
Serial.println("START");
WiFi.begin("GMIT","DAVANGERE");
while ((!(WiFi.status() == WL_CONNECTED))){
delay(300);
Serial.print("..");
}
Serial.println("Your IP is");
Serial.println((WiFi.localIP().toString()));
Serial.println("Connected");
}
void loop()
{
Serial.print("Temperature=");
Serial.println((ThingSpeak.readIntField(12345,1,"ABCDEFGH")));
Serial.print("Humidity=");
Serial.println((ThingSpeak.readIntField(12345,2,"ABCDEFGH")));
delay(3000);
}
(c) Displaying temperature and humidity data on serial monitor of Arduino IDE from Thingspeak cloud
RESULT: Retrieving temperature and humidity data from Thingspeak cloud with ESP32 has
successfully executed.
EXPERIMENT – 8
Write a program on Arduino/Raspberry Pi to publish temperature data to MQTT broker.
AIM: Write a program on ESP32 to publish temperature and humidity values using DHT11
sensor to MQTT broker.
COMPONENTS REQUIRED:
1. ESP32.
2. DHT11.
3. Connecting cable or USB cable.
4. Breadboard.
5. Jumper wires.
CONNECTION DIAGRAM:
CODING:
Embedded C
/****************************************************/
#include <WiFi.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include "DHT.h"
/************************* WiFi Access Point *********************************/
// Setup the MQTT client class by passing in the WiFi client and MQTT server and
login details.
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME,
AIO_KEY);
void MQTT_connect();
void setup() {
Serial.begin(115200);
delay(10);
Serial.println(F("Adafruit MQTT demo"));
Serial.println(WLAN_SSID);
WiFi.begin(WLAN_SSID, WLAN_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
uint32_t x=0;
void loop()
{
// Ensure the connection to the MQTT server is alive (this will make the first
// connection and automatically reconnect when disconnected).
// See the MQTT_connect
// function definition further below.
MQTT_connect();
Serial.print("Sensor 2 ");
Serial.println((dht.readHumidity( )));
Serial.print("...");
int Value1 = dht.readHumidity( );
delay(3000);
if (! sensor_2.publish(Value1))
{
Serial.println(F("Failed"));
}
else
{
Serial.println(F("OK!"));
}
delay(3000);
uint8_t retries = 3;
while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected
Serial.println(mqtt.connectErrorString(ret));
Serial.println("Retrying MQTT connection in 5 seconds...");
mqtt.disconnect();
delay(5000); // wait 5 seconds
retries--;
if (retries == 0) {
// basically die and wait for WDT to reset me
while (1);
}
}
Serial.println("MQTT Connected!");
}
(c) Displaying temperature and humidity data on serial monitor of Arduino IDE
RESULT: Published temperature and humidity data to MQTT broker with ESP32 has
successfully executed.
EXPERIMENT – 9
Write a program on Arduino/Raspberry Pi to subscribe to MQTT broker for temperature
data and print it.
AIM: Write a program on ESP32 to subscribe to MQTT broker for temperature data and print it.
COMPONENTS REQUIRED:
1. ESP32 - 2 Numbers.
2. DHT11.
3. Connecting cable or USB cable.
4. Breadboard.
5. Jumper wires.
CONNECTION DIAGRAM:
CODING:
Embedded C
#include <ESP8266WiFi.h>
#include <Adafruit_MQTT.h>
#include <Adafruit_MQTT_Client.h>
WiFiClient client;
Adafruit_MQTT_Client mqtt(&client, ADAFRUIT_SERVER, ADAFRUIT_PORT,
ADAFRUIT_USERNAME, ADAFRUIT_USERNAME, ADAFRUIT_KEY);
void MQTT_connect() {
int8_t ret;
Serial.println("MQTT Connected!");
}
void setup() {
Serial.begin(115200);
delay(10);
// Connect to Wi-Fi
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("WiFi connected");
Serial.println("IP Address: ");
Serial.println(WiFi.localIP());
mqtt.subscribe(&Temperature);
}
void loop() {
MQTT_connect();
Adafruit_MQTT_Subscribe *subscription;
while ((subscription = mqtt.readSubscription(5000)))
{
if (subscription == &Temperature)
{
Serial.print(F("Received temperature value is: "));
Serial.println((char *)Temperature.lastread);
}
}
}
RESULT: Program on ESP32 to subscribe to MQTT broker for temperature data and printing
the data has successfully executed.
EXPERIMENT – 10
Write a program to create UDP server on Arduino/Raspberry Pi and respond with
humidity data to UDP client when requested.
AIM: Write a program to create UDP server on NodeMCU (ESP8266) and respond with
humidity data to UDP client when requested.
COMPONENTS REQUIRED:
1. NodeMCU (ESP8266).
2. DHT11.
3. Connecting cable or USB cable.
4. Breadboard.
5. Jumper wires.
CONNECTION DIAGRAM:
CODING:
Embedded C
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include "DHT.h"
DHT dht(14,DHT11); //D5 on board numbering system & 14 GPIO numbering system
WiFiUDP udp;
void setup() {
Serial.begin(115200);
Serial.println("Connecting to WiFi...");
WiFi.begin(ssid, password);
Serial.println("WiFi connected.");
Serial.println("UDP server started");
udp.begin(udpPort);
}
void loop() {
char packetBuffer[255]; // buffer to hold incoming packet
float readHumidity()
{
(b) Receiving humidity on UDP client based on request to UDP server NodeMCU (ESP8266)
RESULT: Received humidity data to UDP client from UDP server on NodeMCU (ESP8266)
has successfully executed.
EXPERIMENT – 11
Write a program to create TCP server on Arduino/Raspberry Pi and respond with
humidity data to TCP client when requested.
AIM: Write a program to create TCP server on NodeMCU (ESP8266) and respond with
humidity data to TCP client when requested.
COMPONENTS REQUIRED:
1. NodeMCU (ESP8266).
2. DHT11.
3. Connecting cable or USB cable.
4. Breadboard.
5. Jumper wires.
CONNECTION DIAGRAM:
CODING:
Embedded C
#include <ESP8266WiFi.h>
#include "DHT.h"
DHT dht(5,DHT11); //D1 on board numbering system & 5 GPIO numbering system
// Replace with your network credentials
const char* ssid = "GMIT";
const char* password = "Davangere";
void setup() {
Serial.begin(115200);
delay(10);
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
void loop() {
WiFiClient client = server.available(); // Check for a client connection
if (client) {
Serial.println("New client connected");
float humidity = dht.readHumidity();
String response = "Humidity:"; // Replace this with your actual humidity data
(b) Receiving humidity on TCP client based on request to TCP server NodeMCU (ESP8266)
RESULT: Received humidity data to TCP client from TCP server on NodeMCU (ESP8266)
has successfully executed.
EXPERIMENT – 12
To install MySQL database on Raspberry Pi and perform basic SQL queries.
AIM: To perform basic SQL queries by installing MySQL database on Rsapberry Pi.
PROCEDURE:
1. Create:
In CRUD operations, 'C' is an acronym for create, which means to add or insert data into the
SQL table. So, firstly we will create a table using CREATE command and then we will use the
INSERT INTO command to insert rows in the created table.
where,
Prior to the creation of a table in SQL, we need to create a database or select an existing
database. Since we already had a database, we will select the database with the USE command.
To ensure that the table is created as per the column names, data types and sizes which we
have assigned during table creation, we will execute the following query:
Execute the following query to insert multiple records in the employee table:
2. Read:
In CRUD operations, 'R' is an acronym for read, which means retrieving or fetching the data
from the SQL table. So, we will use the SELECT command to fetch the inserted records from the
SQL table. We can retrieve all the records from a table using an asterisk (*) in a SELECT query.
There is also an option of retrieving only those records which satisfy a particular condition by
using the WHERE clause in a SELECT query.
Example :Write a query to fetch all the records stored in the employee table.
Here, an asterisk is used in a SELECT query. This means all the column values for every record
will be retrieved.
You will get the following output after executing the above query:
3. Update:
In CRUD operations, 'U' is an acronym for the update, which means making updates to the
records present in the SQL tables. So, we will use the UPDATE command to make changes in
the data present in tables.
Syntax:
Here in the SELECT query, we have used the SET keyword to update an employee's last name
as 'Bose'. We want to update an employee's last name only for the employee with id 6, so we
have specified this condition using the WHERE clause.
To ensure that an employee's last name with employee id 6 is updated successfully, we will
execute the SELECT query.
4. Delete:
In CRUD operations, 'D' is an acronym for delete, which means removing or deleting the
records from the SQL tables. We can delete all the rows from the SQL tables using the DELETE
query. There is also an option to remove only the specific records that satisfy a particular
condition by using the WHERE clause in a DELETE query.
Example:Write a query to delete the employee record from the employee table whose salary is
above 34000.
Here we have applied the DELETE query on the employee table. We want to delete only the
employee record whose salary is 34000, so we have specified this condition using the WHERE
clause.
execute the SELECT query to ensure that the employee record with salary as 34000 is deleted
successfully.
To remove all the records from the employee table, we will execute the DELETE query on the
employee table.
Execute the SELECT query to ensure that all the records are deleted successfully from
the employee table.
RESULT: Performed basic SQL queries by installing MySQL database on Rsapberry Pi.
• Inexpensive
• Cross -Platform
• Simple, clear programming environment
• Open source and extensible software
(The Arduino software is published as open source tools, available for extension by experienced
programmers)
MEGA LILYPAD
ESPLORA DUE
Running Code
Stand-Alone
the Embedded C
Programming Language
• ACTUATORS
• SENSORS
• A Light-Emitting Diode
(LED) is a two lead
semiconductor device that
emits visible light when an
electric current passes
through it.
• An basic LED has two
terminals
– Anode (+)
– Cathode (-)
Technical Specification
• Supply Voltage: 2.7 V to 5.5 V
• Supply Current up to 50uA
• Ramp-Up Rate 3°C/sec
• Ramp-Down Rate −6°C/sec
• Offset Voltage: 0.5V
• Output voltage at 25°C: 750mV
• Device turning ON time: 0.5ms
• Operating Temperature Range: −55°C to +150°C
• Storage Temperature Range: −65°C to +160°C
Mr.Raviteja Balekai, Asst.Professor, Dept of
38
ECE, GMIT, Davangere
GAS SENSOR
APPLICATIONS
• Industrial automation systems
• Authentication and security
Mr. Raghudathesh G P,
Assistant Professor-Senior Scale,
Manipal School of Information Sciences, Manipal
Dr. Prathviraj N,
Associate Professor,
Manipal School of Information Sciences, Manipal
EXPERIMENT – 1
Step 2 :
• 802.11 b/g/n
• Integrated low power 32-bit MCU (Xtensa@ Single- Core)
• Typical frequency of 80MHz
• SRAM- 160 Kbytes
• SPI Flash, up to 16 MBytes
• Integrated 10-bit ADC
• Integrated TCP/IP protocol stack
• SDIO (Secure Digital Input Output) 2.0, (H) SPI, UART, I2C, I2S (Inter IC Sound),
IRDA(Infrared Data Association), PWM, GPIO
• Supports antenna diversity
• Integrated PLL, regulators, and power management unit
• Wi-Fi 2.4 GHz, support WPA(Wi-Fi Protected Access)/WPA2
• Support STA( Station) /AP ( Access point) /STA+AP operation modes
• Operating temperature range -40C ~ 125C
PIN DIAGRAM
How to Use Arduino IDE to
Program NodeMCU
1. Start Arduino IDE and open Preferences window from File
2. Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into
Additional Board Manager URLs field
3. Open Boards Manager from Tools > Board menu and find esp8266 platform
ESP32
• ESP32 is a low-cost System on Chip (SoC)
Microcontroller from Espressif Systems, the
developers of the famous ESP8266 SoC. It is a
successor to ESP8266 SoC and comes in both single-
core and dual-core variations of the Tensilica’s 32-bit
Xtensa LX6 Microprocessor with integrated Wi-Fi and
Bluetooth.
Specifications of ESP32
• Single or Dual-Core 32-bit LX6 Microprocessor with clock frequency up to
240 MHz.
• 520 KB of SRAM, 448 KB of ROM and 16 KB of RTC SRAM.
• Supports 802.11 b/g/n Wi-Fi connectivity with speeds up to 150 Mbps.
• Support for both Classic Bluetooth v4.2 and BLE specifications.
• 34 Programmable GPIOs.
• Up to 18 channels of 12-bit SAR ADC and 2 channels of 8-bit DAC
• Serial Connectivity include 4 x SPI, 2 x I2C, 2 x I2S, 3 x UART.
• Ethernet MAC for physical LAN Communication (requires external PHY).
• 1 Host controller for SD/SDIO/MMC and 1 Slave controller for SDIO/SPI.
• Motor PWM and up to 16-channels of LED PWM.
• Secure Boot and Flash Encryption.
• Cryptographic Hardware Acceleration for AES, Hash (SHA-2), RSA, ECC and
RNG.
ESP32 Module
How to Use Arduino IDE to
Program ESP32
1. Start Arduino IDE and open Preferences window from File
2. Enter https://raw.githubusercontent.com/espressif/arduino-esp32/gh-
pages/package_esp32_index.json into Additional Board Manager URLs field
3. Open Boards Manager from Tools > Board >Board Manager Search for ESP32 and
press install button for the “ESP32 by Espressif Systems“
EXPERIMENT – 4
ThingSpeak
• With ThingSpeak you can create sensor-logging
applications, location-tracking applications, and a
social network of things with status updates, so that
you could have your home thermostat control itself
based on your current location.
IoT End – End Architecture
ThingSpeak Features
Tweet-sized data
Push data from devices
Use data in apps
Data Types:
Sensor Data
Text Data
Geolocation Data
• Data Visualization
– Charts
– Maps
Contd…
ThingSpeak Features
• Data Processing
• Twitter Integration
– Send Tweets
– Use data collected by Twitter
– Twitter callbacks
Channel Creation
Use this API Key in your Arduino Code for Sensor data update to Cloud
Private/Public View
Installing ThingSpeak Library
2
Designing Your Dashboard
• Click on “+” Symbol.
By:
Raghudathesh G P
Asst. Professor
MSOIS, MAHE, MANIPAL
Why
Raspberry PI ?
Introduction
• A credit card size single board, low cost computer.
• Developed in UK by Raspberry-pi foundation in May 2009. Supported by
“University of Cambridge Computer laboratory & tech firm Broadcom”
• Designed to promote the teaching of basic computer science schools in developing
countries, but increasingly use by researchers to build real time applications, DIY
enthusiasts to build cool projects, companies to build POC’s as well as products.
• Add to its popularity, now a days Raspberry Pi’s are used for the purpose of mining
cryptocurrency by infecting a linux trojan named Linux.MulDrop.14
• According to the Raspberry Pi Foundation, over 37 million* Raspberry Pi’s have
been sold till date, making it the best-selling British computer.
• The Raspberry Pi uses Linux kernel based operating systems. Raspbian, a Debian-
based free operating system optimized for the Raspberry Pi hardware.
*https://www.raspberrypi.org/blog/raspberry-pi-silicon-pico-now-on-sale/
Raspberry Pi v/s Other Single
Board Computer
Raspberry Pi Applications
Features
• Ultra Low Cost Device $35 or Rs 2275
• Ultra Low-power 1.1W
• Credit-card sized, fanless, instant start-up.
• Complete easy-to-use program computer
• Easy and fun environment for experimenting with programming and electronics.
Technology
• Raspberry Pi 3 has a Broadcom BCM2837 system on a chip (SoC), which includes an
ARMCortex-A53, 1.2GHz processor.
• Video Core (GPU): Broadcom VideoCore
• Originally Shipped with 256 Mb of RAM, now Upgraded to 1 GB.
• Does not have a built-in hard disk, but uses an SD card for booting and storage.
• Video outputs: Composite RCA, HDMI, DSI
• Audio outputs : 3.5 mm jack, HDMI, I²S audio
• Onboard network:10/100 Ethernet only on Model-B
• Onboard storage: SD card slot
• Low-level peripherals: 40 × GPIO, UART, I²C bus, SPI bus with two chip selects, I²S audio,
+3.3 V, +5 V, ground
• Power ratings: via MicroUSB
– 5v, 1.5-2.5 amp (3.5 W) for Model-B
Know Your Raspberry Pi Board
Know Your Raspberry Pi Board
Know Your Raspberry Pi Board
Basic Hardware Setups required to work with Your RPi Board
1. Raspberry Pi Board
2. Display
3. Audio
4. Keyboard and Mouse
5. Flashed SD Card
6. Power Supply
7. Cables
Display
Options for Connecting Display device
a. HDMI(High Definition Multimedia Interface)
video
b. Composite video (RCA)
c. DSI(Display Serial Interface) video
Audio
Options for Connecting Audio device
a. In-built (with HDMI)
b. a black 3.5 mm audio jack (for DVI-D monitors
and composite video RCA output)
Keyboard and Mouse
➢ For Connecting Keyboard & mouse you can use USB Hub
➢ Any standard USB keyboard and mouse should work.
Flashed SD Card
➢ A Bootable SD Card with Ported Linux OS.
➢ The minimum sized SD card you can use is 16GB, but it is recommended to use at
least 8GB if you want to add additional programs to the OS image .
Power Supply
The Model B requires a 5 V supply capable of providing a 1.5 – 2.5 A current, depending
upon the hardware connected top it
Cables
More or less you will be needing…
• HDMI-A cable
• HDMI-A cable + DVI adapter
• Composite video cable
• Composite video cable + SCART adaptor
• Audio cable (not needed if you use the HDMI video connection to a TV)
• Ethernet/LAN cable
• Connecting wires if required to connect peripherals in the GPIO pins
Raspberry Pi OS Setup
• Hardware Requirements:
– Card Reader
– Micro SD (minimum of 4 Gb) Card Class 10
• Software Requirements:
– Raspberry PI OS Image: download from below link and unzip it
https://www.raspberrypi.org/downloads/raspbian/
– Unzip the file that you just downloaded
– Right click on the file and choose “Extract all”.
– Follow the instructions you will end up with a file ending in .img
Continue …
– Download SD Formatter to format your Card
https://www.sdcard.org/downloads/formatter_4/index.html/
– Install the SD Formatter tool as you install normal software on windows machine.
– Select SD card Volume Label
– Click on option and select format
adjustment option to ON
Continue …
– Download the Win32DiskImager software
– https://win32-disk-imager.en.uptodown.com/windows/
– Unzip it in the same way you did the Raspbian .zip file
– You now have a new folder called
win32diskimager-binary
▪ Writing Raspbian to the SD card
▪ Plug your SD card into your PC
▪ Run the file named Win32DiskImager.exe from the folder you made earlier
• If the SD card (Device) you are using isn’t found automatically then click on the
drop down box and select it
• In the Image File box, choose the Raspbian .img file that you downloaded
▪ Click Write
▪ After a few minutes you will have an SD card that you can use in your Raspberry Pi
RPI Connection Setup
•
RPI First Boot
You will see the desktop home window like this
First Boot Configuration
Continue …
• First, update your system's package list by entering the following
command in LXTerminal or from the command line:
sudo apt-get update
• Next, upgrade all your installed packages to their latest versions with
the command:
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get raspi-upgrade (doute ful)
DHT 11 to RPI
1 → VCC (pin 1)
2 → GPIO 4
3 → No Connection
4 → GND (pin 6)
LED to RPI
+ve → GPIO 21
-ve → GND
RPI - LED
INTERFACING
LED PINOUTS
RPI - LED
LED
+ Ve → GPIO 17
Cathode → PIN 6
Code RPI - LED
RPI – DHT11
INTERFACING
DHT11 PINOUTS
Specification
DHT11 DHT22
• Ultra low cost • Low cost
• 3 to 5V power and I/O • 3 to 5V power and I/O
• 2.5 mA max current • 2.5 mA max current
• Good for 20-80% humidity • Good for 0-100% humidity
readings with 5% accuracy readings with 2-5% accuracy
• Good for 0-50°C temperature • Good for -40 to 125°C
readings ±2°C accuracy temperature readings ±0.5°C
accuracy
Received Data:
Example 1: 40 bits of data is received:
0011 0101 0000 0000 0001 1000 0000 0000 0100 1101
High humidity (8) , Low humidity (8), High temp. (8), Low temp.(8), Parity bit (8)
Calculate:
0011 0101+0000 0000+0001 1000+0000 0000= 0100 1101
Received data is correct:
Humidity:0011 0101=35H=23%RH
Temperature:0001 1000=18H=24℃
1 → VCC (pin 2)
2 → GPIO 4
3 → No Connection
4 → GND (pin 6)
CODE
• 1_dht11_Terminal_Display-1
• 1_dht11_Terminal_Display-2
Configurations on MQTT.Cool
• Go to following URL– “https://testclient-
cloud.mqtt.cool/”
• Select a Broker: tcp://test.mosquito.org/
• Cilck on connect.
Configuring MQTT.Cool
• For Subscribe:
– Write Topic filter as “jitdvg“ with QoS0
– Click Subscribe
• For Publish:
– Write destination as “jitdvg“
– Write message to be sent
– Click Publish
Configurations on Android Phone
• In Playstore download and install My MQTT
Procedure to Create MQTT Instance
• Configure as per the image below
Configuring MY MQTT
– To SUBSCRIBE
• Enter topic name as “jitdvg”
• Cilck on subscribe
– To PUBLISH
• Enter topic name as “jitdvg”
• Enter the message to be sent.
• Click on ‘Create’
Thank You ☺
Database
By,
Dr. Prathiviraj N , MSIS, MAHE, Manipal
Prof. Raghudathesh G P, MSIS, MAHE, Manipal
Databases
• A program that
– Manages possibly huge quantities of data
– Facilitates fast and easy access
– Makes data integrity guarantees
– Has A LOT under the covers
ACID - http://en.wikipedia.org/wiki/ACID
Databases (cont.)
• Applications
– Amazon.com, Facebook, IMDB, digg.com, banks,
Google, etc
• Implementations
– MySQL, Postgre, Oracle, Microsoft SQL Server
MySQL (MariaDb)
• MySQL is a popular open-source relational
database management system.
• It allows users to perform various operations on
data, including Create, Read, Update, and Delete
(CRUD).
• CRUD operations are essential to managing and
manipulating data in any database system.
Database Organization
• A single database has multiple tables
• A table has multiple rows
• Each row has multiple columns
• Each column represents a different data
category
Table of actors:
Database Structure
• Column types
– INT, VARCHAR (String), DOUBLE…
• Schemas
– What tables exist?
– What types of columns are in each table?
Database Operations (CRUD)
• Create data in a table
– A new actor has just appeared in a film
Note that the order of values depends on the way the table was created
Read (SELECT)
Get all rows and only the id column from the “actors” table
SELECT id
FROM actors;
Get all rows and columns from the “actors” table whose name field is “Tom Cruise.”
SELECT *
FROM actors
WHERE name = ‘Tom Cruise’;
Get all rows and columns from the “actors” table whose name field is either “Tom Cruise” or
“Katie Holmes.”
SELECT *
FROM actors
WHERE name = ‘Tom Cruise’
OR name = ‘Katie Holmes’;
Update (UPDATE)
Change Tom Cruise’s gender
UPDATE actors
SET gender = ‘F’
WHERE name = ‘Tom Cruise’;