100% found this document useful (1 vote)
145 views52 pages

Getting Started With Arduino and Esp32: A Beginner'S Guide With Wokwi

Getting started with esp32

Uploaded by

sawyerd1957
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
100% found this document useful (1 vote)
145 views52 pages

Getting Started With Arduino and Esp32: A Beginner'S Guide With Wokwi

Getting started with esp32

Uploaded by

sawyerd1957
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
You are on page 1/ 52

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/381765096

GETTING STARTED WITH ARDUINO AND ESP32: A Beginner’s Guide with


Wokwi

Book · June 2024

CITATIONS READS

0 1,440

1 author:

Nor Faizah Bt Zailani


Independent Researcher
12 PUBLICATIONS 6 CITATIONS

SEE PROFILE

All content following this page was uploaded by Nor Faizah Bt Zailani on 04 August 2024.

The user has requested enhancement of the downloaded file.


A Beginner's Guide with Wokwi

NOR FAIZAH BINTI ZAILANI @ HJ AHMAD


NOR ZAMIRA BINTI OTHMAN
A Beginner’s Guide with Wokwi
GETTING STARTED WITH ARDUINO AND ESP32

I
Copyright © 2024

All right reserved. No part of this publication may be reproduced, distributed, or transmitted
in any form or by any means, including photocopying, recording, or other electronic or
mechanical methods, without the prior written permission of the publisher, except in the case
of brief quotations embodied in critical reviews and certain other non-commercial uses
permitted by copyright law. For permission request, write to the publisher, addressed
“Attention: Permission Coordinator,” at the address below.

Politeknik Mersing,
Jalan Nitar,
86800 Mersing,
Johor Darul Ta’zim.
Telephone: (+6)077980001
Fax: (+6) 077980002
Website: https://pmj.mypolycc.edu.my/

Printed in Malaysia
First Printing 2024
e ISBN 978-967-2904-75-5

Authors:
Nor Faizah Binti Zailani @ Hj Ahmad
Nor Zamira Binti Othman

II
PREFACE

Welcome to the world of IoT (Internet of Things) powered by the ESP32 and Wokwi as
an Arduino simulator platform. This book is designed as a beginner's guide to understanding
and harnessing the potential of these powerful platforms for building your own smart devices.
The Internet of Things has rapidly transformed the way we interact with technology, enabling
everyday objects to communicate and exchange data seamlessly over the internet. With the
ESP32 microcontroller and the Arduino development environment, you have at your fingertips
the tools to bring your IoT ideas to life. Whether you're a hobbyist, a student, or a professional
looking to dive into the exciting realm of IoT, this book will provide you with the foundational
knowledge and hands-on experience needed to get started. No prior experience with
electronics or programming is required; we'll guide you through each step of the journey, from
setting up your development environment to building your first IoT project.

Throughout this book, you'll learn the fundamentals of electronics and programming,
explore the capabilities of the ESP32 microcontroller, and discover how to interface it with
various sensors, actuators, and communication modules. By the end of the book, you'll have
the skills and confidence to create your own IoT applications, whether it's a smart home
device, a weather station, or a remote-controlled robot. We've designed this book with a
hands-on approach, featuring plenty of practical examples and projects to reinforce your
learning. Each chapter builds upon the previous one, gradually expanding your knowledge
and understanding of IoT concepts and techniques.

“Explore, Create, Innovate with ESP32 and Arduino using this book”

III
GETTING START WITH ARDUINO AND ESP32

TABLE OF CONTENTS

TASK 1: INTRODUCTION TO WOKWI, ARDUINO IDE AND ESP32 ................................... 1


TASK 2: TRAFFIC LIGHT ................................................................................................... 10
TASK 3: CONTROL LED USING SWITCH.......................................................................... 12
TASK 4: POTENTIOMETER CONTROL LED BRIGHTNESS ............................................. 15
TASK 5: POTENTIOMETER CONTROL BUZZER SOUND ................................................ 18
TASK 6 : OBSTACLE DETECTOR USING ULTRASONIC SENSOR .................................. 22
TASK 7: DISPLAYING OBSTACLE DISTANCE ON AN OLED SCREEN. ........................... 25
TASK 8: TEMPERATURE AND HUMIDITY SENSOR ......................................................... 29
TASK 9: LDR LIGHT SENSOR MODULE ........................................................................... 35
TASK 10: MOTION DETECTOR USING PIR SENSOR ...................................................... 39
BIBLIOGRAPHY ................................................................................................................. 45

IV

A Beginner’s Guide with Wokwi


GETTING START WITH ARDUINO AND ESP32

TASK 1: INTRODUCTION TO WOKWI, ARDUINO IDE AND ESP32

1. Arduino IDE
The Arduino Integrated Design Environment (IDE) serves as the primary text editor for Arduino
programming.
✓ It is coded in C++ language.
✓ Arduino code is referred to as a "sketch" within the IDE.
✓ The sketch undergoes processing and compilation into machine language.
✓ Once uploaded, the compiled code remains stored in the chip for execution.
✓ Arduino IDE software is one of the open-source software that can be used for ESP32.
These tools include an editor, compiler, assembler and debugger.
• Verify / Upload - compile and upload source code to Arduino Board.
• Select Board & Port - detected Arduino boards automatically show up here, along
with the port number.
• Sketchbook - Arduino sketches are saved as .ino files, and must be stored in a
folder of the exact name.
• Boards Manager - browse through Arduino & third-party packages that can be
installed.
• Library Manager - browse through thousands of Arduino libraries, made by Arduino
& its community.
• Debugger - test and debug programs in real-time.
• Search - search for keywords in source code.
• Open Serial Monitor - opens the Serial Monitor tool, as a new tab in the console.

Figure 1: Arduino IDE interface

A Beginner’s Guide with Wokwi 1


GETTING START WITH ARDUINO AND ESP32

2. ESP32 board controller

The ESP32 has more GPIOs with more functionalities compared with the ESP8266. With the
ESP32, we can decide which pins are UART, I2C, or SPI by configuring the code. This is
possible due to the ESP32 chip’s multiplexing feature that allows the assignment of multiple
functions to the same pin. If we don’t set them on the code, the pins will be used as default.

Figure 2: ESP32 pinout

3. Getting start with Wokwi Simulator

Wokwi is an online platform offering simulators for IoT and embedded systems, including
ESP32, STM32, Arduino, Raspberry Pi Pico, displays, sensors, motors, and WiFi simulations.

1. Open the web browser and type https://wokwi.com/ .

Figure 3: Sign up for the Wokwi account

2. Click sign in and follow the sign-up process. We can choose to sign up either using a
Google account, GitHub or other emails.

A Beginner’s Guide with Wokwi 2


GETTING START WITH ARDUINO AND ESP32

Figure 4: Sign-up process

3. To start a project in Wokwi we may choose any board controller as shown in Figure 3. In
this activity, we will use ESP32 as the board controller.
4. Click ESP32 → Starter templates → ESP32

Part 1: Serial Monitor

The Serial Monitor is a feature commonly found in integrated development environments


(IDEs) used for programming microcontrollers and other hardware, particularly in
environments like Arduino. It allows communication between a computer and a microcontroller
(or other hardware) via a serial connection.

Procedure :

1. Click the link below to view and test the simulation.


https://wokwi.com/projects/397207659167143937
2. Write the code as shown in Figure 5

Figure 5: Source code for displaying message on the serial monitor

3. Click on the Green button in Figure 6 to start the simulation.

A Beginner’s Guide with Wokwi 3


GETTING START WITH ARDUINO AND ESP32

Figure 6: Simulation for displaying message on the serial monitor

Explanation :

✓ When this code is uploaded to an ESP32 board and open the Serial Monitor. The message
“ Selamat Datang Ke Politeknik Mersing” will repeatedly display on the serial monitor every
second. It's a simple program to display welcoming messages and encourages learning
about IoT.

✓ void setup():This is a special function in Arduino programming. It's executed once when
the microcontroller starts. In this code, it initializes serial communication using
Serial.begin(9600). This means the microcontroller will communicate with the connected
computer at a baud rate of 9600 bits per second.

✓ void loop(): After the setup() function is executed, the microcontroller enters the loop()
function. This function contains the main code that will run repeatedly.

✓ Serial.println("Selamat Datang Ke Politeknik Mersing");: This line sends the string


"Selamat Datang Ke Politeknik Mersing" over the serial port.

A Beginner’s Guide with Wokwi 4


GETTING START WITH ARDUINO AND ESP32

Part 2: Serial monitor

Procedure :

1. Click the link below to view and test the simulation.


https://wokwi.com/projects/377763451910614017
2. Write the code as shown in Figure 7.

Figure 7: Source code for displaying message on the serial monitor

3. Click the simulation icon and view the output displayed on the serial monitor.

Figure 8: Simulation for displaying message on the serial monitor

A Beginner’s Guide with Wokwi 5


GETTING START WITH ARDUINO AND ESP32

Explanation :

✓ When this code is uploaded to an ESP32 board and open the Serial Monitor. The
messages “ Selamat Datang Ke Politeknik Mersing” and “Jom Kita Belajar IoT “will
repeatedly display on the serial monitor at every 1000 mili seconds.

✓ Serial.print("\n");: This sends a newline character over the serial port. This is effectively
a way to create a blank line, which makes the output more readable.

✓ delay(1000);: This function causes the microcontroller to pause for 1000 milliseconds (1
second) before executing the next iteration of the loop.

Part 3: Led Blinking

1. Breadboard

A breadboard is a prototyping tool used in electronics to quickly and easily build and test
circuits without soldering.

Connected

Connected

Not Connected

Figure 9: Breadboard connection

2. Resistor

Resistors are essential components in electronic circuits, providing crucial functionality in


various applications. The function of a resistor is to control the flow of electrical current in a
circuit by providing resistance to the flow of electrons. To read the value of a resistor, we need
to understand the resistor color code, which consists of colored bands on the resistor. Here is
how to interpret the resistor color code as illustrated in Figure 10:
✓ The first two bands represent the significant digits of the resistance value.
✓ The third band indicates the multiplier (number of zeros).
✓ The fourth/ five band (if present) signifies tolerance.

A Beginner’s Guide with Wokwi 6


GETTING START WITH ARDUINO AND ESP32

Figure 10: Resistor color code reading

3. Light-Emitting Diode (LED)

An LED, or Light-Emitting Diode, is a semiconductor device that emits light when an electric
current passes through it. The resistor connected in series with the LED helps limit the current
flowing through the LED, preventing it from being damaged by excessive current. This balance
between brightness and current protection is crucial for the proper functioning and longevity
of LEDs in various applications.

Figure 6: LED polarity

Figure 11: LED polarity

A Beginner’s Guide with Wokwi 7


GETTING START WITH ARDUINO AND ESP32

Procedure :

1. Click the link below to view and test the simulation.


https://wokwi.com/projects/377693999883206657

2. Write the code as shown in Figure 12.

Figure 12: Source code for LED blinking

3. Set up the circuit connection as shown in Figure 13 or Figure 14. To find or add a new
part, click

Figure 13: Connection between LED and resistor to ESP32 using breadboard

A Beginner’s Guide with Wokwi 8


GETTING START WITH ARDUINO AND ESP32

Figure 14: Connection between LED and resistor to ESP32 without using
breadboard

4. Click on the simulation icon to start the circuit operation.

Figure 15: Simulating LED blinking

Explanation :

This code essentially creates a blinking effect on an LED connected to pin 25, with each
blink lasting half a second or 500ms.
.

A Beginner’s Guide with Wokwi 9


GETTING START WITH ARDUINO AND ESP32

TASK 2: TRAFFIC LIGHT

Procedure :

1. Click the link below to view and test the simulation.


https://wokwi.com/projects/377660543168142337

Figure 1: Traffic light simulation circuit

2. Write the code as shown in Figure 2.

Figure 2: Source code for traffic light circuit

A Beginner’s Guide with Wokwi 10


GETTING START WITH ARDUINO AND ESP32

3. Click on the simulation icon to start the circuit operation.

Figure 3: Simulation for displaying traffic light function

Explanation :

✓ This Arduino code initializes three LEDs connected to digital pins 25, 26, and 27. In the
setup() function, it configures these pins as outputs using pinMode().

✓ In the loop() function, it alternates turning on each LED while turning off the others in
sequence, creating a blinking effect.

✓ Each LED is turned on for one second (delay(1000)), and then the next LED is turned on
while the previous one is turned off. This cycle repeats indefinitely, creating a looping
pattern of LED blinking.

A Beginner’s Guide with Wokwi 11


GETTING START WITH ARDUINO AND ESP32

TASK 3: CONTROL LED USING SWITCH

A slide switch is a mechanical device employed for regulating electrical current flow within a
circuit. By shifting the slider from the OFF (open) to the ON (closed) position, it manages the
current flow without requiring manual wire cutting. These switches remain fixed in a position
until manually adjusted to a different one.

Figure 1: Slide switch symbol Figure 2 :Slide switch construction

Procedure :

1. Click the link below to view and test the simulation.


https://wokwi.com/projects/377659546501791745

2. Setup the circuit connection as illustrated in Figure 3.

*Can use any of two


terminals switch.

Figure 3 : Control LED using switch circuit

A Beginner’s Guide with Wokwi 12


GETTING START WITH ARDUINO AND ESP32

3. Write the code as shown in Figure 4.

const int buttonPin =5; // the number of the pushbutton pin


const int ledPin = 25; // the number of the LED pin
// variable for storing the pushbutton status
int buttonState = 0;
void setup() {
Serial.begin(9600);
// initialize the pushbutton pin as an input
pinMode(buttonPin, INPUT);
// initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the state of the pushbutton value
buttonState = digitalRead(buttonPin);
Serial.println(buttonState);
// 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);
}
}

Figure 4: Source code for control LED using switch

4. Click on the simulation icon to start the circuit operation.

Figure 5: Simulating a circuit when the switch slides ON and OFF

A Beginner’s Guide with Wokwi 13


GETTING START WITH ARDUINO AND ESP32

Explanation :

✓ This code creates a basic pushbutton-controlled LED circuit, where pressing the button
turns the LED on and releasing it turns the LED off. The push button can be replaced with
a slide switch to observe the same effect as shown in Figure 5.

✓ Initialization buttonPin and ledPin to specify the pins where the pushbutton and LED are
connected, respectively. It also initializes a variable buttonState to store the state of the
pushbutton.

✓ Loop Function ():


o The code continuously reads the state of the pushbutton using the digitalRead()
function and stores it in the buttonState variable.
o The current value of buttonState is then printed to the serial monitor using
Serial.println() for debugging purposes.
o The code then checks if the pushbutton is pressed. If buttonState is HIGH,
indicating that the pushbutton is pressed, the LED connected to ledPin is turned
on by setting its state to HIGH using digitalWrite().
o If the pushbutton is not pressed (i.e., buttonState is LOW), the LED is turned off by
setting its state to LOW.
o This process repeats continuously in the loop, allowing the LED to respond in real-
time to the state of the pushbutton.

A Beginner’s Guide with Wokwi 14


GETTING START WITH ARDUINO AND ESP32

TASK 4: POTENTIOMETER CONTROL LED BRIGHTNESS

A potentiometer, equipped with three terminals, features a sliding or rotating contact, enabling
it to establish an adaptable voltage divider. When employing solely two terminals, specifically
one end and the wiper, it functions as either a variable resistor or a rheostat. Following is the
examples of applications that utilize potentiometers:
✓ Volume Control in Audio Devices
✓ Brightness Control in Lighting Systems
✓ Speed Control in Motorized Devices
✓ Temperature Control in Heating Systems
✓ User Interface Controls in Electronic Devices

Figure 1: Potentiometer connection pin and symbol


Procedure :

1. Click the link below to view and test the simulation.


https://wokwi.com/projects/377896378837978113

2. Set up the circuit connection as illustrated in Figure 2.

Figure 2: Controlling LED brightness circuit

A Beginner’s Guide with Wokwi 15


GETTING START WITH ARDUINO AND ESP32

3. Write the code as shown in Figure 3.

/*control led brightness */

#define POTENTIOMETER_PIN 35 // ESP32 pin GPIO35 (ADC0) connected to


Potentiometer pin
#define LED_PIN 26 // ESP32 pin GPIO26 connected to LED's pin

//The setup routine runs once when you press reset:


void setup() {

// initialize serial communication at 9600 bits per second:


Serial.begin(9600);

// declare LED pin to be an output:


pinMode(LED_PIN, OUTPUT);
}

// the loop routine runs over and over again forever:


void loop() {
// reads the input on analog pin A0 (value between 0 and 4095)
int analogValue = analogRead(POTENTIOMETER_PIN);

// scales it to brightness (value between 0 and 255)


int brightness = map(analogValue, 0, 4095, 0, 255);

// sets the brightness LED that connects to pin 3


analogWrite(LED_PIN, brightness);

// print out the value


Serial.print("Analog value = ");
Serial.print(analogValue);
Serial.print(" => brightness = ");
Serial.println(brightness);
delay(100);
}

Figure 3: Source code for controlling LED brightness

A Beginner’s Guide with Wokwi 16


GETTING START WITH ARDUINO AND ESP32

4. Click on the simulation icon to start the circuit operation.

Figure 4: Circuit simulation for controlling LED brightness

Explanation:

✓ This code essentially adjusts the LED brightness based on the position of the
potentiometer. As the potentiometer is adjusted, the analog input changes, resulting in
different brightness levels for the LED. This code defines two constants:
• POTENTIOMETER_PIN: Specifies the pin connected to the potentiometer, which
is set to GPIO pin 35 on the ESP32.
• LED_PIN: Specifies the pin connected to the LED, set to GPIO pin 26 on the
ESP32.

✓ In the loop() function, it reads the analog input from the potentiometer connected to pin 35
(A0 on the ESP32), which provides values between 0 and 4095. The analog input value
scale the brightness value between 0 and 255 using the map() function.

✓ The analog value and corresponding brightness level are printed to the serial monitor for
debugging purposes.

A Beginner’s Guide with Wokwi 17


GETTING START WITH ARDUINO AND ESP32

TASK 5: POTENTIOMETER CONTROL BUZZER SOUND

A buzzer, often referred to as a beeper, is an auditory signaling apparatus frequently employed


for alerts, alarms, or notifications. It may operate through mechanical, electromechanical, or
piezoelectric means, generating sound upon the application of an electrical signal. The
connections are pretty simple:
✓ Connect the Supply wire (RED) of the buzzer to the board controller through a 100-
ohm resistor. The resistor is used to protect the board/microcontroller from any damage
due to the audio output device.
✓ Connect the Ground wire (BLACK) of the buzzer to any Ground Pin on the Arduino
board controller.

Figure 1: Buzzer
Procedure :

1. Click the link below to view and test the simulation


https://wokwi.com/projects/377929616932715521

2. Set up the circuit connection as illustrated in Figure 2.

Figure 2 : Buzzer sound control using potentiometer circuit

A Beginner’s Guide with Wokwi 18


GETTING START WITH ARDUINO AND ESP32

3. Write the code as shown in Figure 3.

// Control buzzer sound

#define POTENTIOMETER_PIN 35 // ESP32 pin GPIO35 (ADC0) connected to


Potentiometer pin
#define BUZZER_PIN 21 // ESP32 pin GPIO21 connected to Buzzer's pin
#define ANALOG_THRESHOLD 1000

void setup() {
pinMode(BUZZER_PIN, OUTPUT); // set ESP32 pin to output mode
Serial.begin(9600); // initialize serial communication
}
void loop() {
int analogValue = analogRead(POTENTIOMETER_PIN); // read the input on
analog pin
if (analogValue > ANALOG_THRESHOLD) {
digitalWrite(BUZZER_PIN, HIGH); // turn on Piezo Buzzer
Serial.println("Buzzer is ON"); // print message to serial monitor
} else {
digitalWrite(BUZZER_PIN, LOW); // turn off Piezo Buzzer
Serial.println("Buzzer is OFF"); // print message to serial monitor
}

delay(100); // delay100ms for stability


}

Figure 3: Source code for controlling buzzer sound using a potentiometer

4. Click on the simulation icon to start the circuit operation.

Figure 4: Simulating buzzer sound controller using a potentiometer

A Beginner’s Guide with Wokwi 19


GETTING START WITH ARDUINO AND ESP32

Explanation :

This code essentially controls a piezo buzzer based on the input from a potentiometer. When
the potentiometer reading exceeds the threshold, the buzzer turns on, indicating the
condition has met a certain level determined by the threshold value.
✓ POTENTIOMETER_PIN: Specifies the pin connected to the potentiometer, set to
GPIO pin 35 (ADC0) on the ESP32.
✓ BUZZER_PIN: Specifies the pin connected to the buzzer, set to GPIO pin 21 on the
ESP32.
✓ ANALO G_THRESHOLD: Sets a threshold value for the analog input, defined as
1000.
✓ In loop function():
o The code reads the analog value from the potentiometer using the analogRead()
function. This function reads the voltage level applied to the potentiometer and
converts it into a digital value ranging from 0 to 4095 on the ESP32.
o If the analog value read from the potentiometer (analogValue) is greater than
the defined threshold (ANALOG_THRESHOLD), indicating that the
potentiometer is turned past a certain point, the buzzer is turned on by setting
the buzzer pin (BUZZER_PIN) to HIGH using digitalWrite(). Additionally, a
message "Buzzer is ON" is printed to the serial monitor.
o If the analog value is below the threshold, the buzzer is turned off by setting the
buzzer pin to LOW, and a message "Buzzer is OFF" is printed to the serial
monitor.
o The loop then repeats, continuously reading the analog value from the
potentiometer and adjusting the buzzer accordingly.
.

Question :

Modify the code in Figure 3 to display the potentiometer value in the serial monitor and activate
the buzzer if the threshold value exceeds 1500.

A Beginner’s Guide with Wokwi 20


GETTING START WITH ARDUINO AND ESP32

Answer :

// Control buzzer sound

#define POTENTIOMETER_PIN 35 // ESP32 pin GPIO35 (ADC0) connected to


Potentiometer pin
#define BUZZER_PIN 21 // ESP32 pin GPIO21 connected to Buzzer's
pin
#define ANALOG_THRESHOLD 1500

void setup() {
pinMode(BUZZER_PIN, OUTPUT); // set ESP32 pin to output mode
Serial.begin(9600); // initialize serial communication.
}

void loop() {
int analogValue = analogRead(POTENTIOMETER_PIN); // read the input on
analog pin
Serial.print("Potentiometer Reading: ");
Serial.println(analogValue);

if (analogValue > ANALOG_THRESHOLD) {


digitalWrite(BUZZER_PIN, HIGH); // turn on Piezo Buzzer
Serial.println("Buzzer is ON"); // print message to serial monitor.
} else {
digitalWrite(BUZZER_PIN, LOW); // turn off Piezo Buzzer
Serial.println("Buzzer is OFF"); // print message to serial monitor.
}

delay(500); // delay 500ms for stability


}

A Beginner’s Guide with Wokwi 21


GETTING START WITH ARDUINO AND ESP32

TASK 6 : OBSTACLE DETECTOR USING ULTRASONIC SENSOR

The ultrasonic sensor (HC-SR04) uses sonar to determine the distance to an object.
Refer to Figure 1, the ultrasound transmitter (trig pin) emits a high-frequency sound (40 kHz).
The sound travels through the air. If it finds an object, it bounces back to the module. The
ultrasound receiver (echo pin) receives the reflected sound (echo).

Figure 1: Ultrasonic sensor measure object distance and pin connection

Ultrasonic sensors have a wide range of uses, including detecting objects, sensing proximity,
avoiding obstacles, and measuring levels in industries like robotics, automation, automotive,
and industrial processes.

Procedure :
1. Click the link below to view and test the simulation.
https://wokwi.com/projects/378210688300606465
2. Set up the circuit connection as illustrated in Figure 2.

Figure 2: Ultrasonic sensor measure object distance circuit

A Beginner’s Guide with Wokwi 22


GETTING START WITH ARDUINO AND ESP32

3. Write the code as shown in Figure 3.

const int trigPin = 5;


const int echoPin = 18;

//define sound speed in cm/uS


#define SOUND_SPEED 0.034
#define CM_TO_INCH 0.393701

long duration;
float distanceCm;
float distanceInch;

void setup() {
Serial.begin(115200); // Starts the serial communication
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
}

void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);

// Calculate the distance


distanceCm = duration * SOUND_SPEED/2;

// Convert to inches
distanceInch = distanceCm * CM_TO_INCH;

// Prints the distance in the Serial Monitor


Serial.print("Distance (cm): ");
Serial.println(distanceCm);
Serial.print("Distance (inch): ");
Serial.println(distanceInch);

delay(1000);
}

Figure 3: Source code for measuring object distance using ultrasonic sensor

A Beginner’s Guide with Wokwi 23


GETTING START WITH ARDUINO AND ESP32

4. Click on the simulation icon to start the circuit operation.

Can adjust
to change
the distance

Figure 4: Simulating circuit for measuring the distance using ultrasonic sensor

Explanation :

This code continuously measures the distance using an ultrasonic sensor and prints the
results to the serial monitor.
✓ const int trigPin = 5; and const int echoPin = 18; define the GPIO pins used for the
trigger and echo signals of the ultrasonic sensor
✓ #define SOUND_SPEED 0.034 and #define CM_TO_INCH 0.393701 define constants
for sound speed in centimeters per microsecond and centimeters to inches conversion
factor, respectively.
✓ The loop() function:
o It counts the duration—the amount of time it takes for the pulses to bounce
back—by repeatedly triggering the ultrasonic sensor to transmit pulses.
o It calculates the distance based on the duration and the speed of sound, and
then converts the distance to inches.
o Finally, it prints the distance in both centimeters and inches to the serial monitor
and waits for 1 second before the next iteration.

A Beginner’s Guide with Wokwi 24


GETTING START WITH ARDUINO AND ESP32

TASK 7: DISPLAYING OBSTACLE DISTANCE ON AN OLED


SCREEN.

The OLED display is typically 0.96 inches in size and utilizes the SSD1306 driver. It can display
text, draw shapes, and even display bitmap images. This combination of ESP32 and OLED
display is commonly used in various IoT (Internet of Things) projects, wearable devices, and
embedded systems where low power consumption and compact size are essential.

Figure 1: OLED

✓ If we’re using I2C communication protocol. The most suitable pins for I2C
communication in the ESP32 are GPIO 22 (SCL) and GPIO 21 (SDA).
✓ If we’re using an OLED display with SPI communication protocol, use GPIO 18
(CLK), GPIO 19(MISO), GPIO 23 (MOSI), and GPIO 5 (CS).

Procedure :

1. Click the link below to view and test the simulation.


https://wokwi.com/projects/378216617965060097

2. Set up the circuit connection as illustrated in Figure 2.

Circuit connection
ESP32 HC-SR04
Vin VCC
D5 Trig
D18 Echo
GND GND
OLED
GND GND
VCC VCC
D21 SCL
D22 SDA

Figure 2: Circuit connection for OLED displaying obstacle distance detected by


ultrasonic sensor

A Beginner’s Guide with Wokwi 25


GETTING START WITH ARDUINO AND ESP32

3. To use this example, make sure you have the Adafruit SSD1306 and Adafruit GFX libraries
installed. You can install these libraries through the Library Manager.
4. To install the library click icon and search Adafruit SSD1306 and Adafruit GFX libraries
as shown in Figure 3.
5. After installing the libraries, click the simulation icon to show circuit functionality.

Figure 3: Library Manager

6. Write the code as shown in Figure 4.


#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)


Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

const int trigPin = 5;


const int echoPin = 18;

//define sound speed in cm/uS


#define SOUND_SPEED 0.034
#define CM_TO_INCH 0.393701

long duration;
int distanceCm;
int distanceInch;

void setup() {
Serial.begin(115200);
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input

if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));

A Beginner’s Guide with Wokwi 26


GETTING START WITH ARDUINO AND ESP32

for(;;);
}
delay(500);
display.clearDisplay();

display.setTextSize(2);
display.setTextColor(WHITE);
}
void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds


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

// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);

// Calculate the distance


distanceCm = duration * SOUND_SPEED/2;

// Convert to inches
distanceInch = distanceCm * CM_TO_INCH;

// Prints the distance in the Serial Monitor


Serial.print("Distance (cm): ");
Serial.println(distanceCm);
Serial.print("Distance (inch): ");
Serial.println(distanceInch);

display.clearDisplay();
display.setCursor(0, 25);
//Display distance in cm
display.print(distance);
display.print(" cm");

// Display distance in inches


/* display.print(distanceInch);
display.print(" in");*/
display.display();

delay(500);
}
Figure 4: Source code for OLED displaying obstacle distance detected
by ultrasonic sensor

A Beginner’s Guide with Wokwi 27


GETTING START WITH ARDUINO AND ESP32

7. Click on the simulation icon to start the circuit operation.

Can adjust
to change
the distance

Figure 5: Simulating circuit of OLED displaying obstacle distance detected


by ultrasonic sensor

Explanation :
✓ This code is for an Arduino project that measures distance using an ultrasonic sensor
and displays the result on an OLED display. The code includes necessary libraries,
Wire.h for I2C communication, Adafruit_GFX.h for graphics, and Adafruit_SSD1306.h
for controlling the SSD1306 OLED display.
✓ The trigger pin is briefly set to LOW and then HIGH to trigger the ultrasonic sensor.
✓ The duration for the sound wave to return is measured using the pulseIn() function.
✓ The distance in centimeters and inches is calculated based on the duration and sound
speed.

A Beginner’s Guide with Wokwi 28


GETTING START WITH ARDUINO AND ESP32

TASK 8: TEMPERATURE AND HUMIDITY SENSOR

A temperature sensor for Arduino is a device that measures the ambient temperature and
converts it into an electrical signal that the Arduino can interpret. In this task, we will learn
about DHT11 and DHT22. The DHT11 and DHT22 are both digital temperature and humidity
sensors commonly used with Arduino and other microcontrollers. Here are the key differences
between them:

Accuracy: The DHT22 provides more accurate temperature and humidity readings compared
to the DHT11
Temperature Range: The DHT22 has a wider temperature range of -40°C to 80°C, while the
DHT11 operates in a range of 0°C to 50°C
Humidity Range: Both sensors have a humidity range of 20% to 80%, but the DHT22 has a
more accurate measurement within this range
Price: The DHT11 is generally cheaper compared to the DHT22, making it a more budget-
friendly option for basic temperature and humidity sensing applications

DHT 11 and DHT 22 Pinout

Figure 1: DHT11 and DHT 22 pinout

Procedure :

1. Click the link below to view and test the simulation.


https://wokwi.com/projects/378326466234394625

A Beginner’s Guide with Wokwi 29


GETTING START WITH ARDUINO AND ESP32

2. Set up the circuit connection as illustrated in Figure 2.

Figure 2 : Circuit connection for weather station project

3. Write the code as shown in Figure 3.

#include "DHT.h"
#define DHTPIN 4 // Digital pin connected to the DHT sensor
// Feather HUZZAH ESP8266 note: use pins 3, 4, 5, 12, 13 or 14 --
// Pin 15 can work but DHT must be disconnected during program upload.

// Uncomment whatever type you're using!


#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(9600);
Serial.println(F("DHTxx test!"));

dht.begin();
}

void loop() {
// Wait a few seconds between measurements.
delay(2000);

A Beginner’s Guide with Wokwi 30


GETTING START WITH ARDUINO AND ESP32

// Reading temperature or humidity takes about 250 milliseconds!


// Sensor readings may also be up to 2 seconds 'old' (its a very slow
sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);

// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}

// Compute heat index in Fahrenheit (the default)


float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);

Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);
Serial.print(F("°F Heat index: "));
Serial.print(hic);
Serial.print(F("°C "));
Serial.print(hif);
Serial.println(F("°F"));
}

Figure 3: Source code for weather station project

5. To use this example, make sure you have the DHT Sensor Library. You can install this
through the Library Manager.

Figure 4 : DHT sensor library

6. Click on the simulation icon to start the circuit operation.

A Beginner’s Guide with Wokwi 31


GETTING START WITH ARDUINO AND ESP32

Figure 5 : Simulating weather station project circuit


Explanation :

This code continuously measures temperature and humidity using the DHT22 sensor and
outputs the readings to the serial monitor.
✓ #include "DHT.h": Includes the DHT sensor library, necessary for communicating with
the DHT22 sensor.
✓ #define DHTPIN 4: Defines the digital pin to which the DHT sensor is connected to
pin 4 for data communication with the sensor.
✓ #define DHTTYPE DHT22: Defines the type of DHT sensor being used.
✓ DHT dht(DHTPIN, DHTTYPE): Creates a DHT object named dht, specifying the pin
and sensor type.
✓ In Loop Function ():
o The readTemperature() and readHumidity( function are used to retrieve
temperature and humidity information from the DHT sensor.
o The temperature is read both in Celsius (t) and Fahrenheit (f) by default.
o The computeHeatIndex() function is used to calculate the heat index, taking
into account temperature and humidity values.
o If any of the readings fail (isnan() checks), an error message is printed, and
the loop restarts.
o At last, the temperature, humidity, and heat index values are displayed on the
serial monitor, appearing in both Celsius and Fahrenheit scales

A Beginner’s Guide with Wokwi 32


GETTING START WITH ARDUINO AND ESP32

Question :

Revise source code in Figure 3 to activate the Red LED when the temperature exceeds 33
degrees. Extend the circuit connection by incorporating a RED LED, following the arrangement
illustrated in Figure 2. Demonstrate the application of the updated code.

Answer :

#include "DHT.h"
#define DHTPIN 4 // Digital pin connected to the DHT sensor
#define RED_LED_PIN 5 // Digital pin connected to the red LED
// Feather HUZZAH ESP8266 note: use pins 3, 4, 5, 12, 13 or 14 --
// Pin 15 can work but DHT must be disconnected during program upload.

// Uncomment whatever type you're using!


#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
dht.begin();
pinMode(RED_LED_PIN, OUTPUT); // Set red LED pin as output
}

void loop() {
// Wait a few seconds between measurements.
delay(2000);

// Reading temperature or humidity takes about 250 milliseconds!


// Sensor readings may also be up to 2 seconds 'old' (its a very slow
sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();

// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}

A Beginner’s Guide with Wokwi 33


GETTING START WITH ARDUINO AND ESP32

// Activate red LED if temperature exceeds 33 degrees Celsius


if (t > 33) {
digitalWrite(RED_LED_PIN, HIGH); // Turn on red LED
} else {
digitalWrite(RED_LED_PIN, LOW); // Turn off red LED
}

// Print temperature and humidity readings


Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.println(F("°C"));
}

A Beginner’s Guide with Wokwi 34


GETTING START WITH ARDUINO AND ESP32

TASK 9: LDR LIGHT SENSOR MODULE

LDR (Light Dependent Resistor), sensor module is a low-cost digital sensor as well as an
analog sensor module, which is capable of measuring and detecting light intensity. This sensor
also is known as the Photoresistor sensor. This sensor has an onboard LDR that helps it to
detect light. The output of the module goes high in the absence of light and it becomes low in
the presence of light. The sensitivity of the sensor can be adjusted using the onboard
potentiometer.

Figure 1 : Light Dependent Resistor module

Figure 1: LDR light sensor module

The LDR light sensor module can sense and measure light around the sensor. It has two
outputs:
i. Digital output that can be either LOW or HIGH
ii. Analog Output

The LDR sensor module has 4 pins:


✓ VCC : Connect this pin to the power source (between 3.3Vto 5V)
✓ GND : Connect this pin to the ground (0V)
✓ D0 : This is a digital output pin. It gives a HIGH signal when it’s dark and LOW
when it’s light. The threshold between dark and light can adjust using a built-
in potentiometer.
✓ A0 : This is a analog output pin. The value decreases as the light get brighter and
increases as the light gets darker.

A Beginner’s Guide with Wokwi 35


GETTING START WITH ARDUINO AND ESP32

Procedure :

1. Click the link below to view and test the simulation.


https://wokwi.com/projects/378622524029754369

2. Set up the circuit connection as illustrated in Figure 2.

Figure 2: Circuit connection connecting LDR sensor and ESP32

3. Write the code as shown in Figure 3.


4.
/*ldr sensor module */

#define DO_PIN 13 // ESP32's pin GPIO13 connected to DO pin of the


ldr module
void setup() {
// initialize serial communication
Serial.begin(9600);
// initialize the ESP32's pin as an input
pinMode(DO_PIN, INPUT);
}
void loop() {
int lightState = digitalRead(DO_PIN);
if (lightState == HIGH)
Serial.println("It is dark");
else
Serial.println("It is light");
}
Figure 3 : Source code for LDR sensor application project

A Beginner’s Guide with Wokwi 36


GETTING START WITH ARDUINO AND ESP32

5. Click on the simulation icon to start the circuit operation.

Figure 4: Simulating LDR application circuit.

Explanation :

✓ This code continually monitors the state of the LDR sensor module, detecting changes in
light intensity, and prints corresponding messages to the serial monitor indicating whether
it is dark or light.
✓ Inside the loop function, the code reads the digital state of the DO_PIN (Pin 13) using the
digitalRead() function and stores it in the lightState variable.
✓ If lightState is HIGH, indicating that the LDR detects low light intensity (darkness), the code
prints "It is dark" via the serial interface.
✓ Otherwise, if lightState is LOW, indicating high light intensity (brightness), the code prints
"It is light" via the serial interface.

Question :

1. Revise the code in Figure 3 to activate the Red LED when the sensor reading exceeds the
threshold value (500). Extend the circuit connection by incorporating a RED LED, following
the arrangement illustrated in Figure 2. Demonstrate the application of the updated code.

A Beginner’s Guide with Wokwi 37


GETTING START WITH ARDUINO AND ESP32

Answer :

Figure 5: LDR sensor control LED brightness circuit

/*control LED brightness*/

// constants won't change


#define LIGHT_SENSOR_PIN 13 // ESP32 pin GPIO13 connected to light sensor
#define LED_PIN 22 // ESP32 pin GPIO22 connected to LED
#define ANALOG_THRESHOLD 500

void setup() {
pinMode(LED_PIN, OUTPUT); // set ESP32 pin to output mode
}

void loop() {
int analogValue = analogRead(LIGHT_SENSOR_PIN); // read the value on analog
pin

if (analogValue < ANALOG_THRESHOLD)


digitalWrite(LED_PIN, HIGH); // turn on LED
else
digitalWrite(LED_PIN, LOW); // turn off LED
}

Figure 6: Source code for LDR sensor control LED brightness.

Simulation result : https://wokwi.com/projects/378622775884086273

A Beginner’s Guide with Wokwi 38


GETTING START WITH ARDUINO AND ESP32

TASK 10: MOTION DETECTOR USING PIR SENSOR

A PIR (Passive Infrared) sensor is an electronic sensor that detects motion by sensing
changes in infrared radiation levels emitted by surrounding objects, such as humans or
animals. When an object moves within the sensor's field of view, it detects the change in
infrared heat radiation and triggers an output signal. The PIR sensor has only 3 pins as
follows:

✓ GND – connect to ground


✓ OUT – connect to an Arduino digital pin
✓ 5V – connect to 5V

Spesification :
• Operating voltage range: DC 5-20V.
• Detection Range: 3m-6.5m.
• Quiescent Current: <50uA.
• Angle Sensor: <100 cone angle.
• Operation Temp: -15 to 70 degrees.

Figure 1 : PIR motion sensor (HC SR501)

Procedure :

1. Click the link below to view and test the simulation.


https://wokwi.com/projects/378221370331045889

A Beginner’s Guide with Wokwi 39


GETTING START WITH ARDUINO AND ESP32

2. Set up the circuit connection as illustrated in Figure 2.

Figure 2 : Circuit connection for motion detector using PIR sensor.

3. Write the code as shown in Figure 3.

define timeSeconds 10

// Set GPIOs for LED and PIR Motion Sensor


const int led = 4;
const int motionSensor = 27;

// Timer: Auxiliary variables


unsigned long now = millis();
unsigned long lastTrigger = 0;
boolean startTimer = false;
boolean motion = false;

// Checks if motion was detected, sets LED HIGH and starts a timer
void IRAM_ATTR detectsMovement() {
digitalWrite(led, HIGH);
startTimer = true;
lastTrigger = millis();
}
void setup() {
// Serial port for debugging purposes
Serial.begin(115200);

// PIR Motion Sensor mode INPUT_PULLUP


pinMode(motionSensor, INPUT_PULLUP);

A Beginner’s Guide with Wokwi 40


GETTING START WITH ARDUINO AND ESP32

// Set motionSensor pin as interrupt, assign interrupt function and


set RISING mode
attachInterrupt(digitalPinToInterrupt(motionSensor),
detectsMovement, RISING);

// Set LED to LOW


pinMode(led, OUTPUT);
digitalWrite(led, LOW);
}

void loop() {
// Current time
now = millis();
if((digitalRead(led) == HIGH) && (motion == false)) {
Serial.println("MOTION DETECTED!!!");
motion = true;
}
// Turn off the LED after the number of seconds defined in the
timeSeconds variable
if(startTimer && (now - lastTrigger > (timeSeconds*1000))) {
Serial.println("Motion stopped...");
digitalWrite(led, LOW);
startTimer = false;
motion = false;
}
}

Figure 3 : Source code for motion detector using PIR sensor.

A Beginner’s Guide with Wokwi 41


GETTING START WITH ARDUINO AND ESP32

4. Click on the simulation icon to start the circuit operation.

Figure 4 : Simulating circuit for motion detecting by PIR sensor.

Explanation :

✓ This code essentially detects motion using a PIR sensor, turns on an LED when motion is
detected, and turns it off after a certain period of inactivity.
✓ Pin 4 is assigned to the LED, and pin 27 is assigned to the motion sensor. Timer and
variables initialization is to manage time and motion detection.
✓ Now and lastTrigger are used to keep track of time, startTimer is a boolean flag to start a
timer when motion is detected, and motion is a boolean flag to indicate whether motion
has been detected.
✓ If the LED is HIGH (indicating motion detected) and no motion has been detected
previously, a message "MOTION DETECTED!!!" is printed to the serial monitor and motion
is set to true.
✓ The LED turns off and the serial monitor prints the message "Motion stopped..." if
startTimer is true and the amount of time since the last motion detection is more than the
specified timeSeconds. Motion and startTimer are set to false.

A Beginner’s Guide with Wokwi 42


GETTING START WITH ARDUINO AND ESP32

Question :

Modify the source code in Figure 3 by incorporating an additional yellow LED that turns ON if
no motion is detected, while the existing red LED turns ON if motion is detected. Demonstrate
the application of the updated code.

Answer :

#define timeSeconds 10
// Set GPIOs for LEDs and PIR Motion Sensor
const int redLed = 4;
const int yellowLed = 5; // Define pin for yellow LED
const int motionSensor = 27;

// Timer: Auxiliary variables


unsigned long now = millis();
unsigned long lastTrigger = 0;
boolean startTimer = false;
boolean motion = false;

// Checks if motion was detected, sets LED HIGH and starts a timer
void IRAM_ATTR detectsMovement() {
digitalWrite(redLed, HIGH); // Turn on red LED when motion is detected
digitalWrite(yellowLed, LOW); // Turn off yellow LED
startTimer = true;
lastTrigger = millis();
}

void setup() {
// Serial port for debugging purposes
Serial.begin(115200);

// PIR Motion Sensor mode INPUT_PULLUP


pinMode(motionSensor, INPUT_PULLUP);
// Set motionSensor pin as interrupt, assign interrupt function and set
RISING mode
attachInterrupt(digitalPinToInterrupt(motionSensor), detectsMovement,
RISING);

// Set LED pins to OUTPUT


pinMode(redLed, OUTPUT);
pinMode(yellowLed, OUTPUT);

// Turn off LEDs initially


digitalWrite(redLed, LOW);
digitalWrite(yellowLed, LOW);
}
void loop() {

A Beginner’s Guide with Wokwi 43


GETTING START WITH ARDUINO AND ESP32

// Current time
now = millis();

// Check if motion is detected and yellow LED is off


if (digitalRead(redLed) == HIGH && motion == false) {
Serial.println("MOTION DETECTED!!!");
motion = true;
}

// Check if motion is stopped and turn on yellow LED


if (startTimer && (now - lastTrigger > (timeSeconds * 1000))) {
Serial.println("Motion stopped...");
digitalWrite(redLed, LOW);
digitalWrite(yellowLed, HIGH); // Turn on yellow LED
startTimer = false;
motion = false;
}
}

A Beginner’s Guide with Wokwi 44


GETTING START WITH ARDUINO AND ESP32

BIBLIOGRAPHY

Amalia, D., IGAAMOka, Igaamo., Septiani, V., & Fazal, M. R. (2020). Designing of
Mikrokontroler E-Learning Course: Using Arduino and TinkerCad. Journal of
Airport Engineering Technology (JAET), 1(1), 8–14.
https://doi.org/10.52989/jaet.v1i1.2

Carlson, C. (2023, March 1). How ultrasonic sensors work. MaxBotix. Retrieved February
10, 2024, from https://maxbotix.com/blogs/blog/how-ultrasonic-sensors-work

Mohapatra, B. N., Mohapatra, R. K., Joshi, J., & Zagade, S. (2020). Easy Performance
Based Learning of Arduino and Sensors Through Tinkercad. International Journal
of Open Information Technologies, 8(10), 73–76.

Nguyen Tai Tuyen. (2022). On an application in supporting practical teaching of IoT


course and embedded programming. Global Journal of Engineering and
Technology Advances, 13(3), 039–044.
https://doi.org/10.30574/gjeta.2022.13.3.0199

PIR Motion Sensor. (2014, January 28). Adafruit Learning System. Retrieved November 10,
2023, from https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor

Rahman, N. A., Idris, M. R., & Baharudin, K. S. (2020). Development of educational kit for
IOT online learning. International Journal of Technology, Innovation and
Humanities, 1(1), 26–32. https://doi.org/10.29210/881001

Santos, R., & Santos, R. (2023, October 2). Getting Started with the ESP32 Development
Board | Random Nerd Tutorials. Random Nerd Tutorials. Retrieved November 10,
2023, https://randomnerdtutorials.com/getting-started-with-esp32/

Zailani , N. F., Abu Bakar, A., Ahmad, N. H., & Hanzah, N. (2021). Easy Learning Basic
Arduino And Sensors For Beginner Using Thinkercad. In Penyelidikan dan Inovasi
Hijau MPCCSustAWARD21 (pp. 39–45). Politeknik Sultan Idris Shah.

A Beginner’s Guide with Wokwi 45


View publication stats

Throughout my career as polytechnic lecturer focusing in Internet of


Things course , I've had the opportunity to work extensively with
platforms like the ESP32 and Arduino, honing my skills in hardware
design, software development, and project implementation. Now, I'm
excited to share that knowledge and experience with you.

In this book, I've carefully crafted a learning journey that caters to


beginners by guiding through the fundamentals of electronics and
programming, exploring the capabilities of the ESP32 microcontroller,
and inspiring you to unleash your creativity through hands-on projects
using Wokwi as an Arduino simulator platform.

~Nor Faizah Binti Zailani @ Hj Ahmad~

With a background in Electrical Engineering and experience


in embedded systems development, I bring a unique
perspective to this collaboration, enriching the content with
insights and experiences gained through my own endeavors
in the field.

In this book, we have meticulously crafted a learning


experience tailored to beginners, guiding you through the
essential concepts of electronics and programming,
exploring the functionalities of the ESP32 microcontroller, and
inspiring you with practical projects to ignite your creativity.

~Nor Zamira Binti Othman~

You might also like