You are on page 1of 10

University of Tunis El Manar Faculty of Sciences of Tunis 2023 / 2024

By: Lotfi Ben Abdelaziz Module : Architecture Atelier Arduino Duration : 1H 30min

TP 1 : Introduction to Arduino , ESP32 and DHT22


Level : TIC2

objectives:

1. Understanding Arduino: Students will grasp the fundamentals of Arduino


programming, including syntax, data types, variables, and control structures.
2. Exploring DHT22 Sensor: Students will learn how to interface and utilize the DHT22
temperature and humidity sensor to collect environmental data.
3. Introduction to ESP32: Students will familiarize themselves with the ESP32
microcontroller, its features, capabilities, and how to program it using the Arduino
IDE.

Tools:

1. Arduino Board
2. ESP32 Board
3. DHT22 Sensor
4. Connecting Wires
5. Bread Board
6. Arduino IDE

Introduction:

What is Arduino :

An electronic board, more precisely a programmable microcontroller that allows


prototypes to be made easily and quickly at a very low cost.Yes, but what's the essence ??
To control lights, motors, retrieve information from sensors and many other things.

1
Figure 1 : Arduino Uno

The strength of Arduino is the simplicity of coding and understanding how it works,
plus there are tons of ready-to-use modules that exempt you from knowing much
about electronics.

Temperature sensor :

The DHT11 and DHT22 sensors are used to measure temperature and relative humidity.
These are very popular among makers and electronics hobbyists.

Figure 2 : DHT22 & DHT11

These sensors contain a chip that does analog to digital conversion and spit out a
digital signal with the temperature and humidity. This makes them very easy to use
with any microcontroller.The DHT22 sensor has a better resolution and a wider
temperature and humidity measurement range.

2
Figure 3 : DHT22 & DHT11 Pinout

ESP32 Development Board :

The ESP32 is a series of low-cost and low-power System on a Chip (SoC) microcontrollers
developed by Espressif that include Wi-Fi and Bluetooth wireless capabilities and dual-core
processor. If you’re familiar with the ESP8266, the ESP32 is its successor, loaded with lots
of new features.

Figure 4: ESP32 DevKit

3
PART I : Arduino Basics

Exercise 1 :

Objective: Write a simple Arduino sketch to blink an LED connected to pin 13.

Instructions: Use the digitalWrite() function to turn the LED on and off at regular intervals
using delay().

Test:

To test your code using the schematic below for Arduino ,resistor and led. Please follow
these steps:

1. Ensure the correct connections according to the schematic.

2. Upload the Arduino code using the Arduino IDE .

3. Document test results, observations, and improvements made during the testing
process.

Figure 5: Code Blink

4
Figure 6: Blink Schematic

Exercise 2 :

Objective: Create an Arduino sketch to generate a pattern of LED blinking using loops.

Instructions:

1. Connect an LED to pin 13 of the Arduino board.


2. Write a sketch that generates a pattern of LED blinking using loops.
3. The pattern should consist of a series of blinks with varying durations and patterns.
4. Experiment with different loop structures (for loop) to create interesting blinking
patterns.
5. Test and observe the LED pattern on the Arduino board.

5
figure 6 : pattern of LED blinking using for loop

PART II: DHT22 Sensor Integration

Exercise 1 :

Objective: Interface the DHT22 sensor with Arduino and read temperature and humidity
values.

Instructions: Use the DHT library to read sensor data and display it on the serial monitor.

6
Test:

Follow these steps to test your code using the provided schematic ( below) for Arduino
and DHT22:

First, you need to install the DHT library if you haven't already. You can do this by going to
Sketch > Include Library > Manage Libraries in the Arduino IDE, then search for "DHT" and
install the library.

1. Ensure the correct connections according to the schematic.

2. Upload the Arduino code using the Arduino IDE .

3. Monitor the serial output for debugging or data transmission.

4. Test the functionality of the DHT22 sensor by observing temperature and humidity
readings.

5. Debug and troubleshoot any errors encountered during testing.

6. Document test results, observations, and improvements made during the testing
process.

7
Figure 7 : Arduino & DHT22 Schematic ( Fritzing software)

figure: dht22 sensor with arduino

8
PART III: ESP82 Introduction.

Exercise 1 :

Objective: The ESP82 has capacitive sensors that can be used as a touch button. These are
the famous “TOUCH” pins found on the pinouts. Ten are available on the uPesy ESP82
boards.

Instructions: use touchRead() function to read the capacitive measurement of pin 4 .

Figure 8: ESP82 TOUCH PIN

9
Support :

Programming | Arduino Documentation

Get Started - ESP32 - — ESP-IDF Programming Guide latest documentation


(espressif.com)

Random Nerd Tutorials | Learn ESP32, ESP8266, Arduino, and Raspberry Pi

uPesy Electronics - Boost your DIY projects

Arduino - Retro et geek

10

You might also like