Professional Documents
Culture Documents
Experiment: 1.1
2. Tool Used:
ESP32, LED, Resistor, Breadboard, Arduino.
#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.
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.
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.
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:
· 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.
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-
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");
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.
Initializes the WiFi library's network settings and provides the current status.
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.
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
Serial.println("HIGH");
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
Serial.println("LOW");
delay(500);
Syntax
digitalWrite(pin, value)
Description
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
void setup() {
// Initializing Serial
communication.
Serial.begin(9600);
Serial.println("Init...
T1_Intro");
University Institute of Engineering
Department of Computer Science & Engineering
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());
Serial.print("\nRSSI: ");
Serial.println(WiFi.RSSI());
Serial.print("WiFi connected. IP
address: ");
University Institute of Engineering
Department of Computer Science & Engineering
1. (Internet of Things) - all devices connected to internet is called iOT / smart device.
3. Reset buttons does not delete the data. It starts from beganing.