0% found this document useful (0 votes)
2 views28 pages

Iot File

The document outlines several practical applications implemented on an Arduino board, including creating delay routines for LEDs, toggling LEDs with a switch, and interfacing with a DHT11 sensor to read temperature and humidity. It also details applications for monitoring temperature and humidity thresholds, smoke detection using an MQ2 gas sensor, water level measurement, and sending/receiving data using NodeMCU with HTTP requests. Each section includes components required, circuit diagrams, and code snippets for implementation.

Uploaded by

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

Iot File

The document outlines several practical applications implemented on an Arduino board, including creating delay routines for LEDs, toggling LEDs with a switch, and interfacing with a DHT11 sensor to read temperature and humidity. It also details applications for monitoring temperature and humidity thresholds, smoke detection using an MQ2 gas sensor, water level measurement, and sending/receiving data using NodeMCU with HTTP requests. Each section includes components required, circuit diagrams, and code snippets for implementation.

Uploaded by

N Thakore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Enrollment No.

: 202203103510031 Monalisa Padhy

Practical – 3

Aim: To implement following applications on Arduino board:


(a) Create (any) delay routine for buzzing LED(s).
(b) Toggle LED(s) by switching.

(a) Create (any) delay routine for buzzing LED(s).


➢ Components:

1. Arduino Uno
2. Red Led
3. Jumper Wire
4. Breadboard

➢ Code:

void setup ()
{
pinMode (LED_BUILTIN, OUTPUT);
}

void loop ()
{
digitalWrite (LED_BUILTIN,
HIGH);delay (3000); // Wait for
3000 millisecond(s) digitalWrite
(LED_BUILTIN, LOW);
delay (1000); // Wait for 1000 millisecond(s)
}

➢ Circuit:

Figure 1: Before Start Simulation

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

Figure 2: After Start Simulation

➢ Circuit Diagram:

Figure 3: Circuit Diagram

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

(b) Toggle LED(s) by switching.


➢ Components:

1. Arduino Uno
2. Red Led
3. Jumper Wire
4. Breadboard
5. 10 KΩ & 100Ω Resistor

➢ Circuit Diagram:

➢ Code:

const int ledPin= 13;


const int buttonPin = 2;

void setup(){
pinMode (ledPin, OUTPUT);

// Set the button pin as an input


pinMode (buttonPin, INPUT);
}

void loop () {
// Read the state of the push button
int buttonState = digitalRead(buttonPin);

// If the button is pressed, turnthe LED on


if
(buttonState==HIGH) {
digitalWrite (ledPin, HIGH); // Turn LED on

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

} else {
digitalWrite (ledPin, LOW); // Turn LED off
}
}

➢ Circuit:

Figure 1: Before Start Simulation

Figure 2: After Start Simulation

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

Practical:-4
Aim:
To interface a DHT11 sensor with Arduino and write a program to print temperature and
humidity readings on LCD displays.

➢ Components:
Arduino Uno
Jumper Wire
Breadboard
DTH 11 Sensor

➢ Circuit Diagram:

➢ Code:

#include <DHT.h> // Include DHT library

#define DHTPIN 7 // Pin connected to the DHT11 sensor


#define DHTTYPE DHT11 // Define sensor type as DHT11

DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor

void setup() {
Serial.begin(9600); // Start serial communication
dht.begin(); // Initialize the DHT sensor
}

void loop() {
delay(2000); // Wait 2 seconds between measurements

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

float humidity = dht.readHumidity(); // Read humidity


float temperature = dht.readTemperature(); // Read temperature in °C

// Check if reading failed


if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}

// Display temperature and humidity


Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");

Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
}

➢ Output:

➢ Serial Monitor Output:

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

Practical 5

Aim:To implement an application which senses temperature and humidity. If it is above the
predefined threshold value, then the application should glow the LED for notification.

➢ Components Required:

• Arduino Uno
• Jumper Wires
• Breadboard
• DHT11 Sensor
• LED

➢ Circuit Diagram:

➢ Code:
#include "DHT.h" // Include DHT library
#define DHTPIN 7 // Pin connected to DHT11 sensor
#define DHTTYPE DHT11 // Define DHT type
int led = 13; // LED connected to pin 13
DHT dht(DHTPIN, DHTTYPE); // Create DHT object
void setup() {
Serial.begin(9600); // Start serial communication
pinMode(led, OUTPUT); // Set LED as output
dht.begin(); // Initialize the DHT sensor
}
void loop() {
delay(2000); // Wait a few seconds between measurements
// Read humidity and temperature
float humi = dht.readHumidity();
float tempC = dht.readTemperature();
float tempF = dht.readTemperature(true);
// Check for reading errors
if (isnan(humi) || isnan(tempC) || isnan(tempF)) {
Serial.println("Failed to read from DHT sensor!");
UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)
Enrollment No.: 202203103510031 Monalisa Padhy

} else {
Serial.print("Humidity: ");
Serial.print(humi);
Serial.print("% | ");
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.print("°C ~ ");
Serial.print(tempF);
Serial.println("°F");
// Check temperature threshold
if (tempC > 29.00) {
digitalWrite(led, HIGH); // Turn LED ON if temperature > 29°C
} else {
digitalWrite(led, LOW); // Turn LED OFF otherwise
}
}
}

Output:

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

Practical 6

Aim:To implement an application which senses smoke with senses smoke with the help of
smoke detector & an alarm using Arduino Uno.

➢ Components Required:

• Arduino Uno
• MQ2 Gas Sensor
• 5V LED
• 100 ohm resistor
• Jumper wires

➢ Circuit Diagram:

➢ Code:

const int MQ135Pin = A0; // Analog pin connected to MQ135 sensor


const int BuzzerPin = 9; // Digital pin connected to Buzzer
int sensorValue; // Variable to store sensor reading

void setup() {
pinMode(MQ135Pin, INPUT); // Set MQ135 pin as input
pinMode(BuzzerPin, OUTPUT); // Set Buzzer pin as output
Serial.begin(9600); // Start serial communication
}

void loop() {
sensorValue = analogRead(MQ135Pin); // Read gas level from sensor
Serial.print("Gas Sensor Value: ");
Serial.println(sensorValue);

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

if (sensorValue > 400) { // Threshold value (adjust as needed)


digitalWrite(BuzzerPin, HIGH); // Turn buzzer ON
} else {
digitalWrite(BuzzerPin, LOW); // Turn buzzer OFF
}

delay(1000); // Read every second


}

➢ Output:

➢ Serial Monitor Output:

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

Practical 7

Aim:To implement the following applications on Arduino board: Measure water level using
Arduino Uno.

➢ Components Required:

• Arduino Uno
• Water level sensor
• Jumper Wire
• Breadboard

➢ Circuit Diagram:

➢ Code:

const int analogInPin = A0; // Analog input pin


int sensorValue = 0; // Variable to store sensor reading

void setup() {
// Declare LED pins as outputs
pinMode(2, OUTPUT); // LED 1
pinMode(3, OUTPUT); // LED 2

Serial.begin(9600); // Start serial communication


}

void loop() {
sensorValue = analogRead(analogInPin); // Read analog input

Serial.print("Sensor = ");
Serial.println(sensorValue);
delay(2);

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

// Control LEDs based on sensor value ranges


if ((sensorValue >= 100) && (sensorValue <= 200)) {
digitalWrite(2, HIGH); // Turn ON LED 1
delay(1000);
digitalWrite(2, LOW); // Turn OFF LED 1 after delay
}
else if ((sensorValue >= 500) && (sensorValue <= 800)) {
digitalWrite(3, HIGH); // Turn ON LED 2
delay(5000);
digitalWrite(3, LOW); // Turn OFF LED 2 after delay
}
}

➢ Output:

➢ Serial Monitor Output:

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

Practical 8

Aim:To develop an application to send and receive data with NodeMCU using HTTP requests.

➢ Components Required:

• DHT22
• Jumper wire
• Breadboard
• Node MCU

➢ Diagram:

➢ Code:

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>

const char* ssid = "REPLACE_WITH_YOUR_SSID";


const char* password = "REPLACE_WITH_YOUR_PASSWORD";

//Your Domain name with URL path or IP address with path


String serverName = "http://192.168.1.106:1880/update-sensor";

// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastTime = 0;
// Timer set to 10 minutes (600000)
//unsigned long timerDelay = 600000;
// Set timer to 5 seconds (5000)
unsigned long timerDelay = 5000;

void setup() {

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

Serial.begin(115200);

WiFi.begin(ssid, password);
Serial.println("Connecting");
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println(WiFi.localIP());

Serial.println("Timer set to 5 seconds (timerDelay variable), it will take 5 seconds


before publishing the first reading.");
}

void loop() {
// Send an HTTP POST request depending on timerDelay
if ((millis() - lastTime) > timerDelay) {
//Check WiFi connection status
if(WiFi.status()== WL_CONNECTED){
WiFiClient client;
HTTPClient http;

String serverPath = serverName + "?temperature=24.37";

// Your Domain name with URL path or IP address with path


http.begin(client, serverPath.c_str());

// If you need Node-RED/server authentication, insert user and password below


//http.setAuthorization("REPLACE_WITH_SERVER_USERNAME",
"REPLACE_WITH_SERVER_PASSWORD");

// Send HTTP GET request


int httpResponseCode = http.GET();

if (httpResponseCode>0) {
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
String payload = http.getString();
Serial.println(payload);
}
else {
Serial.print("Error code: ");
Serial.println(httpResponseCode);
}
// Free resources
http.end();
}
else {

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

Serial.println("WiFi Disconnected");
}
lastTime = millis();
}
}

➢ HTTP GET Request:

In the loop() is where you actually make the HTTP GET request every 5 seconds with
sample data:

String serverPath = serverName + "?temperature=24.37";

// Your Domain name with URL path or IP address with path


http.begin(client, serverPath.c_str());

// If you need Node-RED/server authentication, insert user and password below


//http.setAuthorization("REPLACE_WITH_SERVER_USERNAME",
"REPLACE_WITH_SERVER_PASSWORD");

// Send HTTP GET request


int httpResponseCode = http.GET();

Output:

➢ HTTP POST Request:


#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>

const char* ssid = "REPLACE_WITH_YOUR_SSID";


const char* password = "REPLACE_WITH_YOUR_PASSWORD";

//Your Domain name with URL path or IP address with path


const char* serverName = "http://192.168.1.106:1880/update-sensor";

// the following variables are unsigned longs because the time, measured in

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastTime = 0;
// Timer set to 10 minutes (600000)
//unsigned long timerDelay = 600000;
// Set timer to 5 seconds (5000)
unsigned long timerDelay = 5000;

void setup() {
Serial.begin(115200);

WiFi.begin(ssid, password);
Serial.println("Connecting");
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println(WiFi.localIP());

Serial.println("Timer set to 5 seconds (timerDelay variable), it will take 5 seconds


before publishing the first reading.");
}

void loop() {
//Send an HTTP POST request every 10 minutes
if ((millis() - lastTime) > timerDelay) {
//Check WiFi connection status
if(WiFi.status()== WL_CONNECTED){
WiFiClient client;
HTTPClient http;

// Your Domain name with URL path or IP address with path


http.begin(client, serverName);

// If you need Node-RED/server authentication, insert user and password below


//http.setAuthorization("REPLACE_WITH_SERVER_USERNAME",
"REPLACE_WITH_SERVER_PASSWORD");

// Specify content-type header


http.addHeader("Content-Type", "application/x-www-form-urlencoded");
// Data to send with HTTP POST
String httpRequestData =
"api_key=tPmAT5Ab3j7F9&sensor=BME280&value1=24.25&value2=49.54&valu
e3=1005.14";
// Send HTTP POST request
int httpResponseCode = http.POST(httpRequestData);

// If you need an HTTP request with a content type: application/json, use the
following:

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

//http.addHeader("Content-Type", "application/json");
//int httpResponseCode =
http.POST("{\"api_key\":\"tPmAT5Ab3j7F9\",\"sensor\":\"BME280\",\"value1\":\"
24.25\",\"value2\":\"49.54\",\"value3\":\"1005.14\"}");

// If you need an HTTP request with a content type: text/plain


//http.addHeader("Content-Type", "text/plain");
//int httpResponseCode = http.POST("Hello, World!");

Serial.print("HTTP Response code: ");


Serial.println(httpResponseCode);

// Free resources
http.end();
}
else {
Serial.println("WiFi Disconnected");
}
lastTime = millis();
}
}

Output:

Those values are also sent to 3 Gauges and are displayed in Node-RED Dashboard:

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

Practical 9

Aim:To develop an application that measures the room temperature and post the temperature
value on Thingspeak cloud platform.

➢ Components Required:

• Arduino Uno
• DHT22
• Jumper wire
• Breadboard
• LCD Display

➢ Circuit Diagram:
➢ Code:
#include <LiquidCrystal.h>
#include <DHT.h>
// Initialize the LCD (RS, EN, D4, D5, D6, D7)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define DHTPIN 7 // Pin connected to DHT11 sensor
#define DHTTYPE DHT11 // Define sensor type
DHT dht(DHTPIN, DHTTYPE); // Create DHT object
void setup() {
lcd.begin(16, 2); // Initialize 16x2 LCD
lcd.print("DHT11 Sensor");

Serial.begin(9600); // Start serial communication


dht.begin(); // Initialize DHT sensor

delay(2000); // Wait for sensor to stabilize


}
void loop() {
float humidity = dht.readHumidity(); // Read humidity
float temperature = dht.readTemperature(); // Read temperature (°C)
// Check if readings are valid

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

if (isnan(humidity) || isnan(temperature)) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Sensor Error!");
return;
}
// Display on LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print("C");

lcd.setCursor(0, 1);
lcd.print("Humidity: ");
lcd.print(humidity);
lcd.print("%");

// Print to Serial Monitor


Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
delay(2000); // Update every 2 seconds
}

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

Practical 10

Aim:
To develop an application for measuring the distance using ultrasonic sensors and post distance
value on Thingspeak cloud platform.

➢ Components Required:

• Arduino Uno
• Ultrasonic Sensors
• Wi-Fi Module
• Jumper Wire

➢ Circuit Diagram:

➢ Code:

int trigPin = 3; // Trigger pin connected to Arduino pin 3


int echoPin = 2; // Echo pin connected to Arduino pin 2

long duration; // Variable to store pulse duration


long cm, inches; // Variables to store distance in cm and inches

void setup() {
Serial.begin(9600); // Start serial communication
pinMode(trigPin, OUTPUT); // Set trigger pin as output
pinMode(echoPin, INPUT); // Set echo pin as input
}

void loop() {
// Clear the trigger
digitalWrite(trigPin, LOW);

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

delayMicroseconds(2);

// Send a 10 microsecond pulse to trigger


digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

// Read the echo pulse


duration = pulseIn(echoPin, HIGH);

// Calculate distance
cm = (duration / 2) / 29.1; // Convert to centimeters
inches = (duration / 2) / 74; // Convert to inches

// Display results on Serial Monitor


Serial.print("Distance: ");
Serial.print(inches);
Serial.print(" in, ");
Serial.print(cm);
Serial.println(" cm");

delay(250); // Wait 250ms before next reading


}

➢ Output:

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

Practical 11

Aim:To develop an application that measures the moisture of soil and post the sensed data
over Google Firebase cloud platform.

➢ Components Required:

• Nodemcu (ESP8266)
• Soil Moisture Sensor Module (with analog output)
• Jumper Wires
• Breadboard
• USB Cable

➢ Circuit Diagram:

➢ Code:
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include <DHT.h>

#define FIREBASE_HOST "dn_iot_project.firebaseio.com"


#define FIREBASE_AUTH "KjlgjR2awesfjeIlbifsowSflksj"
#define WIFI_SSID "Your’ Prime 11 5G"
#define WIFI_PASSWORD "Hello@IoT"

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

#define DHTPIN D2 // Digital pin connected to DHT11


#define DHTTYPE DHT11 // Initialize dht type as DHT 11
DHT dht(DHTPIN, DHTTYPE);

void setup()
{
Serial.begin(115200);
dht.begin(); //reads dht sensor data

WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to ");
Serial.print(WIFI_SSID);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}

Serial.println();
Serial.print("Connected");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP()); //prints local IP address
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); // connect to
the firebase

void loop()
{
float h = dht.readHumidity(); // Read Humidity
float t = dht.readTemperature(); // Read temperature

if (isnan(h) || isnan(t)) // Checking sensor working


{
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
Serial.print("Humidity: ");
Serial.print(h);
String fireHumid = String(h) + String("%"); //Humidity integer to
string conversion

Serial.print("% Temperature: ");


Serial.print(t);
Serial.println("°C ");
String fireTemp = String(t) + String("°C"); //Temperature integer to
string conversion
delay(5000);

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

Firebase.pushString("/DHT11/Humidity", fireHumid); //setup path to send


Humidity readings
Firebase.pushString("/DHT11/Temperature", fireTemp); //setup path to send
Temperature readings
if (Firebase.failed())
{

Serial.print("pushing /logs failed:");


Serial.println(Firebase.error());
return;
}
}

➢ Output:

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

Firebase Realtime Database

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

Practical 12

Aim:To develop an application for controlling LED with a switch using Raspberry Pi.

➢ Components Required:

• Raspberry pi
• Blynk App
• LED
• Resistor (250 ohm)
• Jumper Wires
• Breadboard

➢ Circuit Diagram:

➢ Code:
import RPi.GPIO as GPIO
import BlynkLib
import time

BLYNK_AUTH = 'YourAuthToken'

# Setup GPIO
led = 17 # GPIO17 pin
GPIO.setmode(GPIO.BCM)
GPIO.setup(led, GPIO.OUT)

# Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)

# Register handler for Virtual Pin V0

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)


Enrollment No.: 202203103510031 Monalisa Padhy

@blynk.VIRTUAL_WRITE(0)
def my_write_handler(value):
if int(value[0]) == 1:
GPIO.output(led, GPIO.HIGH)
print("LED ON")
else:
GPIO.output(led, GPIO.LOW)
print("LED OFF")

while True:
blynk.run()
time.sleep(0.1)

➢ Output:

UTU/CGPIT/B.TECH/CE/SEM-7/B-1/Internet of Things (IT6002)

You might also like