You are on page 1of 9

University Institute of Engineering

Department of Computer Science & Engineering

Experiment: 1.1

Student Name: ANURAG BHARTI UID: 21BCS11044


Branch: Computer Science & Engineering Section/Group: 502-A
Semester: II Date of Performance: 19/02/2022
Subject Name: DISRUPTIVE TECHNOLOGIES - 2
Subject Code: 22E-21ECH-103

1. Aim of the practical:


Introduction to open-source IoT Platform and basic interfacing Hands-on.

2. Tool Used:
ESP32, LED, Resistor, Breadboard, Arduino.

3. Basic Concept/ Command Description:


Step 1:

#include<WiFi.h>

We need to include the WiFi.h library, which will allow us to connect to the network. The WiFi library for esp32 is
part of the esp32 Arduino boards package. don't install it separately. put #include <WiFi.h>.

This library is automatically “installed” when you install the ESP32 add-on in your Arduino IDE.

Step 2: #define LED 2


University Institute of Engineering
Department of Computer Science & Engineering

As a best practice, we use some defines to keep the pin number for the LED- The Pin the LED is connected to.
Also, in the future if we want to change the LED from pin 2 to another pin, we can modify this line without touching
anything else in the code.

Step 3: #define WIFISSID "WiFi Name"

A service set identifier (SSID) is a sequence of characters that uniquely names a wireless local area network
(WLAN). An SSID is sometimes referred to as a "network name." This name allows stations to connect to the
desired network when multiple independent networks operate in the same physical area.

SSIDs are a sequence of alphanumeric characters (letters or numbers), are case sensitive and can have a
maximum length of 32 characters.

Step 4: #define PASSWORD "WiFi Password"

It is a User Defined password.

Step 5: void setup()

Every Arduino sketch includes void setup() and void loop(). Without them, your program won’t run!

 The code that you put inside void setup() will only run once, and that will be at the beginning of your
program. One example is when you want to turn your robot on — that does not happen multiple
times!

As the void setup function is called only once at the very beginning of the program, this will be the place to:

· Initialize variables’ values.

· Setup communications (ex: Serial).

· Setup modes for digital pins (input/output).

· Initialize any hardware component (sensor/actuator) plugged to the Arduino.

· Etc.
University Institute of Engineering
Department of Computer Science & Engineering

The void setup, as its name suggest, is made for you to do any setup required at the beginning of the
program. Don’t write the core functionalities here, just the initialization code.

Step 6: Serial.begin(9600);

Firstly, we have the command 'Serial.begin(9600)'. This starts serial communication, so that the Arduino can
send out commands through the USB connection. The value 9600 is called the 'baud rate' (data rate in bits per
second) of the connection. This is how fast the data is to be sent. You can change this to a higher value, but you
will also have to change the Arduio Serial monitor to the same value.

Step 7: Serial.println("Init... T1_Intro");

Prints data to the serial port as human-readable ASCII text. This command can take many forms. Numbers are
printed using an ASCII character for each digit. Floats are similarly printed as ASCII digits, defaulting to two
decimal places. Bytes are sent as a single character. Characters and strings are sent as is. For example-

· Serial.print(78) gives "78"

· Serial.print(1.23456) gives "1.23"

· Serial.print('N') gives "N"

· Serial.print("Hello world.") gives "Hello world."

Step 8: pinMode(LED, OUTPUT);

Syntax pinMode(pin,

mode)

The pinMode() function is used to configure a specific pin to behave either as an input or an output. Step

9: Serial.print("\n\nConnecting to");

Step 10: Serial.println(WIFISSID);


University Institute of Engineering
Department of Computer Science & Engineering

Printing a text string is simple: Serial. print("hello world"); sends the text string “hello world” to a device at the other
end of the serial port. If you want your output to print a new line after the output, use Serial. println() instead of
Serial.

Step 11: WiFi.begin(WIFISSID,PASSWORD);

Initializes the WiFi library's network settings and provides the current status.

Step 12: while (WiFi.status() != WL_CONNECTED){

delay(500);

Serial.print(".");

The while() loop will keep looping as long as WiFi.status() is other than WL_CONNECTED. The loop will exit only if
the status changes to WL_CONNECTED.

Step 13: Serial.println("WiFi connected.IP address:");

Step 14: Serial.println(WiFi.localIP())

Gets the WiFi IP address

Step 15: void loop()

 In void loop(), your code will repeat over and over again. Examples are when your robot is driving or
using its sensor to check for obstacles.
 Theloop()function will run over-and-over-and-overuntil the Arduino is reset.

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

digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)

Serial.println("HIGH");

delay(500); // wait for half a second

digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW

Serial.println("LOW");

delay(500);

Syntax

digitalWrite(pin, value)

Description

Write a HIGH or a LOW value to a digital pin.

If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V
(or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.

4. Code:

#include

<WiFi.h>

#define LED 2

#define WIFISSID "labno605" // Your WiFi Name


#define PASSWORD "123456789" // Your WiFi Password

void setup() {
// Initializing Serial
communication.
Serial.begin(9600);
Serial.println("Init...
T1_Intro");
University Institute of Engineering
Department of Computer Science & Engineering

// Setup up WiFi and Connecting to an active


hotspot. Serial.print("\n\nCnonnecting to ");
Serial.println(WIFISSID);

WiFi.begin(WIFISSID, PASSWORD);
while (WiFi.status() != WL_CONNECTED) { // Waiting for successful
connection delay(1000);
Serial.print(".");
}

Serial.print("\nRSSI: ");
Serial.println(WiFi.RSSI());

Serial.print("WiFi connected. IP
address: ");
Serial.println(WiFi.localIP());

// the loop function runs over and over again


forever void loop() {
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
//Serial.println("HIGH");
delay(1000); // wait for a second
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
//Serial.println("LOW");
delay(1000); // wait for a second

Serial.print("\nRSSI: ");
Serial.println(WiFi.RSSI());

Serial.print("WiFi connected. IP
address: ");
University Institute of Engineering
Department of Computer Science & Engineering

5. Observations, Simulation Screen Shots and Discussions:


University Institute of Engineering
Department of Computer Science & Engineering

6. Result and Summary:

 The ESP32 boards can be programmed using many different programming


languages. For example, you can program your ESP32 board in C++
language(like the Arduino) or Micro Python. And to make use of all of the ESP32
features Espressif has officially provided the Espressif IoT Development
Framework.
 For beginners, Arduino IDE is the easiest way to get started in programming the
ESP32 board
University Institute of Engineering
Department of Computer Science & Engineering

7. Additional Creative Inputs (If Any):

Learning outcomes (What I have learnt):

1. (Internet of Things) - all devices connected to internet is called iOT / smart device.

devices --> internet-->interface-->micro-controller

2. Arduino: uno: it does not connect with internet

ESP 32 – can connect to internet as well as Bluetooth.

3. Reset buttons does not delete the data. It starts from beganing.

4.Arduino is the microcontroller used in our experiment (ESP32)

5. Language used is embedded C.

Evaluation Grid (To be filled by Faculty):


Sr. Parameters Marks Obtained Maximum Marks
No.
1. Worksheet completion including 10
writinglearning objectives/Outcomes.
(To besubmitted
at the end of the day)
2. Post Lab Quiz Result. 5
3. Student Engagement in 5
Simulation/Demonstration/Performance
and Controls/Pre-Lab Questions.
Signature of Faculty (with Date): Total Marks Obtained: 20

You might also like