[go: up one dir, main page]

0% found this document useful (0 votes)
36 views49 pages

Esp32 Sample Document

The document discusses embedded systems, detailing their components such as microcontrollers, memory, input/output devices, and communication interfaces. It highlights the differences between embedded systems and general-purpose computers, emphasizing their specific functions and applications. Additionally, it covers the design and functionality of power supply circuits, including rectifiers and voltage regulators, and introduces the ESP32 chip for IoT applications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views49 pages

Esp32 Sample Document

The document discusses embedded systems, detailing their components such as microcontrollers, memory, input/output devices, and communication interfaces. It highlights the differences between embedded systems and general-purpose computers, emphasizing their specific functions and applications. Additionally, it covers the design and functionality of power supply circuits, including rectifiers and voltage regulators, and introduces the ESP32 chip for IoT applications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 49

[Type the document title]

ABSTRACT:

[Type text] Page 1


[Type the document title]

CHAPTER 1

INTRODUCTION

PROBLEM STATEMENT

EXISTING SYSTEM

PROPOSED SYSTEM

[Type text] Page 2


[Type the document title]

CHAPTER 2

LITERATURE SURVEY

[Type text] Page 3


[Type the document title]

CHAPTER 3

INTRODUCTION TO EMBEDDED SYSTEM

1.1 Introduction Embedded Systems:-

An embedded system is a combination of software and hardware to perform a dedicated


task. Some of the main devices used in embedded products are Microprocessors and
Microcontrollers.

Microprocessors are commonly referred to as general purpose processors as they simply


accept the inputs, process it and give the output. In contrast, a microcontroller not only accepts
the data as inputs but also manipulates it, interfaces the data with various devices, controls the
data and thus finally gives the result.

An Embedded System is a combination of computer hardware and software, and perhaps


additional mechanical or other parts, designed to perform a specific function. A good example is
the microwave oven. Almost every household has one, and tens of millions of them are used
every day, but very few people realize that a processor and software are involved in the
preparation of their lunch or dinner.

This is in direct contrast to the personal computer in the family room. It too is
comprised of computer hardware and software and mechanical components (disk drives, for
example). However, a personal computer is not designed to perform a specific function rather; it
is able to do many different things. Many people use the term general-purpose computer to make
this distinction clear. As shipped, a general-purpose computer is a blank slate; the manufacturer
does not know what the customer will do wish it. One customer may use it for a network file
server another may use it exclusively for playing games, and a third may use it to write the next
great American novel.

Frequently, an embedded system is a component within some larger system. For


example, modern cars and trucks contain many embedded systems. One embedded system
controls the anti-lock brakes, other monitors and controls the vehicle's emissions, and a third

[Type text] Page 4


[Type the document title]

displays information on the dashboard. In some cases, these embedded systems are connected by
some sort of a communication network, but that is certainly not a requirement.

At the possible risk of confusing you, it is important to point out that a general-purpose
computer is itself made up of numerous embedded systems. For example, my computer consists
of a keyboard, mouse, video card, modem, hard drive, floppy drive, and sound card-each of
which is an embedded system. Each of these devices contains a processor and software and is
designed to perform a specific function. For example, the modem is designed to send and receive
digital data over analog telephone line. That's it and all of the other devices can be summarized
in a single sentence as well.

3.2. OVERVIEW OF EMBEDDED SYSTEM :

Every embedded system consists of custom-built hardware built around a Central


Processing Unit (CPU). This hardware also contains memory chips onto which the software is
loaded. The software residing on the memory chip is also called the ‘firmware’.

The same architecture is applicable to any computer including a desktop


computer. However, there are significant differences. It is not compulsory to have an operating
system in every embedded system. For small appliances such as remote control units, air
conditioners, toys etc., there is no need foran operating system and you can write only the
software specific to that application.

For applications involving complex processing, it is advisable to have an operating


system. In such a case, you need to integrate the application software with the operating system
and then transfer the entire software on to the memory chip. Once the software is transferred to
the memory chip, the software will continue to run for a long time you don’t need to reload new
software. Now, let us see the details of the various building blocks of the hardware of an
embedded system. As shown in Fig. the building blocks are:

a. Central Processing Unit (CPU)


b. Memory (Read-only Memory and Random Access Memory)
c. Input Devices
d. Output devices
e. Communication interfaces

[Type text] Page 5


[Type the document title]

f. Application-specific circuitry

Fig: 3.1 Building blocks of the hardware of an embedded system

 CENTRAL PROCESSING UNIT (CPU):


The Central Processing Unit (processor, in short) can be any of the following:
microcontroller, microprocessor or Digital Signal Processor (DSP). A micro-controller is a low-
cost processor. Its main attraction is that on the chip itself, there will be many other components
such as memory, serial communication interface, analog-to digital converter etc.
So, for small applications, a micro-controller is the best choice as the number of external
components required will be very less. On the other hand, microprocessors are more powerful,
but you need to use many external components with them. D5P is used mainly for applications in
which signal processing is involved such as audio and video processing.
 MEMORY:
The memory is categorized as Random Access 11emory (RAM) and Read Only Memory
(ROM). The contents of the RAM will be erased if power is switched off to the chip, whereas
ROM retains the contents even if the power is switched off. So, the firmware is stored in the
ROM. When power is switched on, the processor reads the ROM; the program is program is
executed.

[Type text] Page 6


[Type the document title]

 INPUT DEVICES:
Unlike the desktops, the input devices to an embedded system have very limited
capability. There will be no keyboard or a mouse, and hence interacting with the embedded
system is no easy task. Many embedded systems will have a small keypad-you press one key to
give a specific command. A keypad may be used to input only the digits. Many embedded
systems used in process control do not have any input device for user interaction; they take inputs
from sensors or transducers 1’fnd produce electrical signals that are in turn fed to other systems.
 OUTPUT DEVICES:
The output devices of the embedded systems also have very limited capability. Some
embedded systems will have a few Light Emitting Diodes (LEDs) to indicate the health status of
the system modules, or for visual indication of alarms. A small Liquid Crystal Display (LCD)
may also be used to display some important parameters.
 COMMUNICATION INTERFACES:
The embedded systems may need to, interact with other embedded systems at they may
have to transmit data to a desktop. To facilitate this, the embedded systems are provided with one
or a few communication interfaces such as RS232, RS422, RS485, Universal Serial Bus (USB),
IEEE 1394, Ethernet etc.
 APPLICATION-SPECIFIC CIRCUITRY:
Sensors, transducers, special processing and control circuitry may be required fat an
embedded system, depending on its application. This circuitry interacts with the processor to
carry out the necessary work. The entire hardware has to be given power supply either through
the 230 volts main supply or through a battery. The hardware has to design in such a way that the
power consumption is minimized.

CHAPTER 4

[Type text] Page 7


[Type the document title]

BLOCK DIAGRAM AND HARDWARE DISCRIPTION

4.1. BLOCK DIAGRAM:

POWER SUPPLY
[Type text] Page 8
[Type the document title]

All digital circuits require regulated power supply. In this article we are going to learn how to get
a regulated positive supply from the mains supply.

Figure 1 shows the basic block diagram of a fixed regulated power supply.

Let us go through each block.

TRANSFORMER

A transformer consists of two coils also called as “WINDINGS” namely PRIMARY &
SECONDARY. They are linked together through inductively coupled electrical conductors also
called as CORE. A changing current in the primary causes a change in the Magnetic Field in the
core & this in turn induces an alternating voltage in the secondary coil. If load is applied to the

[Type text] Page 9


[Type the document title]

secondary then an alternating current will flow through the load. If we consider an ideal
condition then all the energy from the primary circuit will be transferred to the secondary circuit
through the magnetic field.

So

The secondary voltage of the transformer depends on the number of turns in the Primary as well as
in the secondary.

Rectifier

A rectifier is a device that converts an AC signal into DC signal. For rectification purpose we use
a diode, a diode is a device that allows current to pass only in one direction i.e. when the anode
of the diode is positive with respect to the cathode also called as forward biased condition &
blocks current in the reversed biased condition.

Rectifier can be classified as follows:

1) Half Wave rectifier.

[Type text] Page 10


[Type the document title]

This is the simplest type of rectifier as you can see in the diagram a half wave rectifier consists
of only one diode. When an AC signal is applied to it during the positive half cycle the diode is
forward biased & current flows through it. But during the negative half cycle diode is reverse
biased & no current flows through it. Since only one half of the input reaches the output, it is
very inefficient to be used in power supplies.

2) Full wave rectifier.

Half wave rectifier is quite simple but it is very inefficient, for greater efficiency we would like
to use both the half cycles of the AC signal. This can be achieved by using a center tapped
transformer i.e. we would have to double the size of secondary winding & provide connection to
the center. So during the positive half cycle diode D1 conducts & D2 is in reverse biased
condition. During the negative half cycle diode D2 conducts & D1 is reverse biased. Thus we get

[Type text] Page 11


[Type the document title]

both the half cycles across the load. One of the disadvantages of Full Wave Rectifier design is
the necessity of using a center tapped transformer, thus increasing the size & cost of the circuit.
This can be avoided by using the Full Wave Bridge Rectifier.

3) Bridge Rectifier

As the name suggests it converts the full wave i.e. both the positive & the negative half cycle
into DC thus it is much more efficient than Half Wave Rectifier & that too without using a center
tapped transformer thus much more cost effective than Full Wave Rectifier. Full Bridge Wave
Rectifier consists of four diodes namely D1, D2, D3 and D4. During the positive half cycle
diodes D1 & D4 conduct whereas in the negative half cycle diodes D2 & D3 conduct thus the
diodes keep switching the transformer connections so we get positive half cycles in the output.

[Type text] Page 12


[Type the document title]

If we use a center tapped transformer for a bridge rectifier we can get both positive & negative
half cycles which can thus be used for generating fixed positive & fixed negative voltages.

FILTER CAPACITOR

Even though half wave & full wave rectifier give DC output, none of them provides a constant
output voltage. For this we require to smoothen the waveform received from the rectifier. This
can be done by using a capacitor at the output of the rectifier this capacitor is also called as
“FILTER CAPACITOR” or “SMOOTHING CAPACITOR” or “RESERVOIR CAPACITOR”.
Even after using this capacitor a small amount of ripple will remain. We place the Filter
Capacitor at the output of the rectifier the capacitor will charge to the peak voltage during each
half cycle then will discharge its stored energy slowly through the load while the rectified
voltage drops to zero, thus trying to keep the voltage as constant as possible.

[Type text] Page 13


[Type the document title]

If we go on increasing the value of the filter capacitor then the Ripple will decrease. But then the costing will
increase. The value of the Filter capacitor depends on the current consumed by the circuit, the frequency of
the waveform & the accepted ripple.

Where,

Vr = accepted ripple voltage.( should not be more than 10% of the voltage)
I = current consumed by the circuit in Amperes.
F = frequency of the waveform. A half wave rectifier has only one peak in one cycle so F=25hz

Where as a full wave rectifier has Two peaks in one cycle so F=100hz.

[Type text] Page 14


[Type the document title]

VOLTAGE REGULATOR

A Voltage regulator is a device which converts varying input voltage into a constant regulated
output voltage. Voltage regulator can be of two types
1) Linear Voltage Regulator Also called as Resistive Voltage regulator because they
dissipate the excessive voltage resistively as heat.
2) Switching Regulators They regulate the output voltage by switching the Current
ON/OFF very rapidly. Since their output is either ON or OFF it dissipates very low
power thus achieving higher efficiency as compared to linear voltage regulators. But
they are more complex & generate high noise due to their switching action. For low
level of output power switching regulators tend to be costly but for higher output
wattage they are much cheaper than linear regulators.

The most commonly available Linear Positive Voltage Regulators are the 78XX series where the
XX indicates the output voltage. And 79XX series is for Negative Voltage Regulators.

After filtering the rectifier output the signal is given to a voltage regulator. The maximum input
voltage that can be applied at the input is 35V.Normally there is a 2-3 Volts drop across the
regulator so the input voltage should be at least 2-3 Volts higher than the output voltage. If the
input voltage gets below the Vmin of the regulator due to the ripple voltage or due to any other
reason the voltage regulator will not be able to produce the correct regulated voltage.

[Type text] Page 15


[Type the document title]

3. Circuit diagram:

Fig 2.3 Circuit Diagram of power supply

IC 7805:
7805 is an integrated three-terminal positive fixed linear voltage regulator. It supports an input
voltage of 10 volts to 35 volts and output voltage of 5 volts. It has a current rating of 1 amp
although lower current models are available. Its output voltage is fixed at 5.0V. The 7805 also
has a built-in current limiter as a safety feature. 7805 is manufactured by many companies,
including National Semiconductors and Fairchild Semiconductors. The 7805 will automatically
reduce output current if it gets too hot.The last two digits represent the voltage; for instance, the
7812 is a 12-volt regulator. The 78xx series of regulators is designed to work in complement
with the 79xx series of negative voltage regulators in systems that provide both positive and
negative regulated voltages, since the 78xx series can't regulate negative voltages in such a
system. The 7805 & 78 is one of the most common and well-known of the 78xx series
regulators, as it's small component count and medium-power regulated 5V make it useful for
powering TTL devices.

[Type text] Page 16


[Type the document title]

SPECIFICATIONS IC 7805

V out 5V

V - V Difference
ein out 5V - 20V

Operation Ambient Temp 0 - 125°C

Output I max 1A

Table 2.1. Specifications of IC7805

[Type text] Page 17


[Type the document title]

CHAPTER 4

CONTROLLER

ESP32

ESP32 is a single 2.4 GHz Wi-Fi-and-Bluetooth combo chip designed with the TSMC ultra-low-
power 40 nm technology. It is designed to achieve the best power and RF performance, showing
robustness, versatility and reliability in a wide variety of applications and power scenarios. The
ESP32 series of chips includes ESP32-D0WD-V3, ESP32-D0WDQ6-V3, ESP32-D0WD,
ESP32-D0WDQ6, ESP32-D2WD, ESP32-S0WD, and ESP32-U4WDH, among which, ESP32-
D0WD-V3, ESP32-D0WDQ6-V3, and ESP32-U4WDH are based on ECO V3 wafer

1.1 Featured Solutions

1.1.1 Ultra LowPower Solution ESP32 is designed for mobile, wearable electronics, and
Internet-of-Things (IoT) applications. It features all the state-of-the-art characteristics of low-
power chips, including fine-grained clock gating, multiple power modes, and dynamic power
scaling. For instance, in a low-power IoT sensor hub application scenario, ESP32 is woken up
periodically and only when a specified condition is detected. Low-duty cycle is used to minimize
the amount of energy that the chip expends. The output of the power amplifier is also adjustable,
thus contributing to an optimal trade-off between communication range, data rate and power
consumption

1.1.2 Complete Integration Solution ESP32 is a highly-integrated solution for Wi-Fi-and-


Bluetooth IoT applications, with around 20 external components. ESP32 integrates an antenna
switch, RF balun, power amplifier, low-noise receive amplifier, filters, and power management
modules. As such, the entire solution occupies minimal Printed Circuit Board (PCB) area. ESP32
uses CMOS for single-chip fully-integrated radio and baseband, while also integrating advanced

[Type text] Page 18


[Type the document title]

calibration circuitries that allow the solution to remove external circuit imperfections or adjust to
changes in external conditions.

As such, the mass production of ESP32 solutions does not require expensive and specialized Wi-
Fi testing equipment.

1.2 WIFI KEY FEATURES

• 802.11 b/g/n

• 802.11 n (2.4 GHz), up to 150 Mbps

• WMM

• TX/RX A-MPDU, RX A-MSDU

• Immediate Block ACK

• Defragmentation

• Automatic Beacon monitoring (hardware TSF)

• 4 × virtual Wi-Fi interfaces

• Simultaneous support for Infrastructure Station, SoftAP, and Promiscuous modes Note that
when ESP32 is in Station mode, performing a scan, the SoftAP channel will be changed.

• Antenna diversity

1.3 BT KEY FEATURES

• Compliant with Bluetooth v4.2 BR/EDR and BLE specifications

• Class-1, class-2 and class-3 transmitter without external power amplifier

• Enhanced Power Control

• +12 dBm transmitting power

• NZIF receiver with –94 dBm BLE sensitivity

[Type text] Page 19


[Type the document title]

• Adaptive Frequency Hopping (AFH)

• Standard HCI based on SDIO/SPI/UART

• High-speed UART HCI, up to 4 Mbps

• Bluetooth 4.2 BR/EDR BLE dual mode controller

• Synchronous Connection-Oriented/Extended (SCO/eSCO)

• CVSD and SBC for audio codec

• Bluetooth Piconet and Scatternet

• Multi-connections in Classic BT and BLE

• Simultaneous advertising and scanning

1.4 MCU and Advanced Features

1.4.1 CPU AND MEMORY

• Xtensa® single-/dual-core 32-bit LX6 microprocessor(s), up to 600 MIPS (200 MIPS for
ESP32-S0WD/ESP32-U4WDH, 400 MIPS for ESP32-D2WD)

• 448 KB ROM

• 520 KB SRAM

• 16 KB SRAM in RTC

• QSPI supports multiple flash/SRAM chips

1.4.2 CLOCKS AND TIMERS

• Internal 8 MHz oscillator with calibration

[Type text] Page 20


[Type the document title]

• Internal RC oscillator with calibration

• External 2 MHz ~ 60 MHz crystal oscillator (40 MHz only for Wi-Fi/BT functionality)

• External 32 kHz crystal oscillator for RTC with calibration

• Two timer groups, including 2 × 64-bit timers and 1 × main watchdog in each group

• One RTC timer

• RTC watchdog

1.4.3 ADVANCED PERIPHERAL INTERFACES

• 34 × programmable GPIOs

• 12-bit SAR ADC up to 18 channels

• 2 × 8-bit DAC

• 10 × touch sensors

• 4 × SPI

• 2 × I²S

• 2 × I²C

• 3 × UART

• 1 host (SD/eMMC/SDIO)

• 1 slave (SDIO/SPI)

• Ethernet MAC interface with dedicated DMA and IEEE 1588 support

• Two-Wire Automotive Interface (TWAI®, compatible with ISO11898-1)

• IR (TX/RX)

• Motor PWM

[Type text] Page 21


[Type the document title]

• LED PWM up to 16 channels

• Hall sensor

1.4.4 SECURITY

• Secure boot

• Flash encryption

• 1024-bit OTP, up to 768-bit for customers

• Cryptographic hardware acceleration: – AES – Hash (SHA-2) – RSA – ECC – Random


Number Generator (RNG)

1.5 APPLICATIONS (A NONEXHAUSTIVE LIST)

• Generic Low-power IoT Sensor Hub

• Generic Low-power IoT Data Loggers

• Cameras for Video Streaming

• Over-the-top (OTT) Devices

• Speech Recognition

• Image Recognition

• Mesh Network

• Home Automation – Light control – Smart plugs – Smart door locks • Smart Building – Smart
lighting – Energy monitoring

• Industrial Automation – Industrial wireless control – Industrial robotics

• Smart Agriculture – Smart greenhouses – Smart irrigation – Agriculture robotics • Audio


Applications – Internet music players – Live streaming devices – Internet radio players – Audio
headsets

[Type text] Page 22


[Type the document title]

• Health Care Applications – Health monitoring – Baby monitors

• Wi-Fi-enabled Toys – Remote control toys – Proximity sensing toys – Educational toys •
Wearable Electronics – Smart watches – Smart bracelets

• Retail & Catering Applications – POS machines – Service robots

OVERVIEW

ESP32-WROOM-32 is a powerful, generic Wi-Fi+BT+BLE MCU module that targets a wide


variety of applications, ranging from low-power sensor networks to the most demanding tasks,
such as voice encoding, music streaming and MP3 decoding.

At the core of this module is the ESP32-D0WDQ6 chip*. The chip embedded is designed to be
scalable and adaptive. There are two CPU cores that can be individually controlled, and the CPU
clock frequency is adjustable from 80 MHz to 240 MHz. The user may also power off the CPU

[Type text] Page 23


[Type the document title]

and make use of the low-power co-processor to constantly monitor the peripherals for changes or
crossing of thresholds. ESP32 integrates a rich set of peripherals, ranging from capacitive touch
sensors, Hall sensors, SD card interface, Ethernet, high-speed SPI, UART, I2S and I2C.

For more details Read ESP32-WROOM32 Data sheet

The integration of Bluetooth, Bluetooth LE and Wi-Fi ensures that a wide range of applications
can be targeted, and that the module is future proof: using Wi-Fi allows a large physical range
and direct connection to the internet through a Wi-Fi router, while using Bluetooth allows the
user to conveniently connect to the phone or broadcast low energy beacons for its detection. The
sleep current of the ESP32 chip is less than 5 μA, making it suitable for battery powered and
wearable electronics applications. ESP32 supports a data rate of up to 150 Mbps, and 20.5 dBm
output power at the antenna to ensure the widest physical range. As such the chip does offer
industry-leading specifications and the best performance for electronic integration, range, power
consumption, and connectivity. The operating system chosen for ESP32 is freeRTOS with LwIP;
TLS 1.2 with hardware acceleration is built in as well. Secure (encrypted) over the air (OTA)
upgrade is also supported, so that developers can continually upgrade their products even after
their release.

ESP32 WROOM32 DevKit Pinout

[Type text] Page 24


[Type the document title]

ESP32 Peripherals Features

 18 Analog-to-Digital Converter (ADC) channels


 10 Capacitive sensing GPIOs
 3 UART interfaces
 3 SPI interfaces
 2 I2C interfaces
 16 PWM output channels
 2 Digital-to-Analog Converters (DAC)
 2 I2S interfaces

GPIO Pins

ESP32 Wroom32 DevKit has total 25 GPIOs out of that few pins are Input only Pins,

Input Only Pins

[Type text] Page 25


[Type the document title]

 GPIO 34
 GPIO 35
 GPIO 36
 GPIO 39

Not all pins have input pullup, you need external pullup on these pins when using as input
pullup.

Pins with internal pull up INPUT_PULLUP

 GPIO14
 GPIO16
 GPIO17
 GPIO18
 GPIO19
 GPIO21
 GPIO22
 GPIO23

Pins without internal pull up

 GPIO13
 GPIO25
 GPIO26
 GPIO27
 GPIO32
 GPIO33

In arduino to use these pins you can simply use common commands

Example: To make GPIO22 as input and GPIO23 as output

pinMode(22,INPUT_PULLUP);

[Type text] Page 26


[Type the document title]

pinMode(23,OUTPUT);

digitalWrite(23,HIGH);

Analog Input Pins

Note that only a subset of ADC pins and functions are exposed. First, the supplied drivers expose
only ADC1. The board layout of the ESP32-DevKitC only exposes some of the pins.
Specifically, the following are exposed: ADC1_CH0 , ADC1_CH3 , ADC1_CH4 ,
ADC1_CH5 , ADC1_CH6 and ADC1_CH7 .

see ESP32 Analog Read Example

Analog to digital conversion is the ability to read a voltage level found on a pin between 0 and
some maximum value and convert that analog value into a digital representation. Varying the
voltage applied to the pin will change the value read. The ESP32 has an analog to digital
converter built into it with a resolution of up to 12 bits which is 4096 distinct values. What that
means is that 0 volts will produce a digital value of 0 while the maximum voltage will produce
a digital value of 4095 and voltage ranges between these will produce a correspondingly scaled
digital value.
One of the properties on the analog to digital converter channels is attenuation. This is a voltage
scaling factor. Normally the input range is 0-1V but with different attenuations we can scale the
input voltage into this range. The available scales beyond the 0-1V include 0-1.34V, 0-2V and 0-
3.6V.

Capacitive touch GPIOs

ESP32 Capacitive Touch Example Code

The ESP32 has 10 internal capacitive touch sensors. These can sense variations in anything that
holds an electrical charge, like the human skin. So they can detect variations induced when
touching the GPIOs with a finger. These pins can be easily integrated into capacitive pads, and

[Type text] Page 27


[Type the document title]

replace mechanical buttons. The capacitive touch pins can also be used to wake up the ESP32
from deep sleep.

Those internal touch sensors are connected to these GPIOs:

 T0 (GPIO 4)
 T1 (GPIO 0)
 T2 (GPIO 2)
 T3 (GPIO 15)
 T4 (GPIO 13)
 T5 (GPIO 12)
 T6 (GPIO 14)
 T7 (GPIO 27)
 T8 (GPIO 33)
 T9 (GPIO 32)

Digital to Analog Converter (DAC)

Example code is available here

There are 2 x 8 bits DAC channels on the ESP32 to convert digital signals into analog voltage
signal outputs. These are the DAC channels:

 DAC1 (GPIO25)
 DAC2 (GPIO26)

RTC GPIOs

There is RTC GPIO support on the ESP32. The GPIOs routed to the RTC low-power subsystem
can be used when the ESP32 is in deep sleep. These RTC GPIOs can be used to wake up the
ESP32 from deep sleep when the Ultra Low Power (ULP) co-processor is running. The
following GPIOs can be used as an external wake up source.

[Type text] Page 28


[Type the document title]

 RTC_GPIO0 (GPIO36)
 RTC_GPIO3 (GPIO39)
 RTC_GPIO4 (GPIO34)
 RTC_GPIO5 (GPIO35)
 RTC_GPIO6 (GPIO25)
 RTC_GPIO7 (GPIO26)
 RTC_GPIO8 (GPIO33)
 RTC_GPIO9 (GPIO32)
 RTC_GPIO10 (GPIO4)
 RTC_GPIO11 (GPIO0)
 RTC_GPIO12 (GPIO2)
 RTC_GPIO13 (GPIO15)
 RTC_GPIO14 (GPIO13)
 RTC_GPIO15 (GPIO12)
 RTC_GPIO16 (GPIO14)
 RTC_GPIO17 (GPIO27)

PWM

PWM Example Code is here

The ESP32 LED PWM controller has 16 independent channels that can be configured to
generate PWM signals with different properties. All pins that can act as outputs can be used as
PWM pins (Input only pin GPIOs 34 to 39 can’t generate PWM).

To set a PWM signal, you need to define these parameters in the code:

 Signal’s frequency;
 Duty cycle;
 PWM channel;
 GPIO where you want to output the signal.

[Type text] Page 29


[Type the document title]

Serial

Hardware Serial2 Example Code

ESP32 has three serial ports

First Serial RX0, TX0 is used for programming,

 GPIO3 (U0RXD)
 GPIO1(U0TXD)

Another Serial port is available on

 GPIO16 (U2RXD).
 GIIO17 (U2TXD).

When programming it is named as Serial2.

I2C

When using the ESP32 with the Arduino IDE, you should use the ESP32 I2C default pins
(supported by the Wire library):

 GPIO 21 (SDA)
 GPIO 22 (SCL)

SPI

By default, the pin mapping for SPI is:

SPI MOSI MISO CLK CS

VSPI GPIO 23 GPIO 19 GPIO 18 GPIO 5

[Type text] Page 30


[Type the document title]

HSPI GPIO 13 GPIO 12 GPIO 14 GPIO 15

Interrupts

All GPIOs can be configured as interrupts.

Enable (EN)

Enable (EN) is the 3.3V regulator’s enable pin. It’s pulled up, so connect to ground to disable the
3.3V regulator. This means that you can use this pin connected to a pushbutton to restart your
ESP32.

CHAPTER-5

SOFTWARE

Software introduction:

Arduino IDE Software. You can get different versions of Arduino IDE from the Download page
on the Arduino Official website. You must select your software, which is compatible with your
operating system (Windows, IOS, or Linux). After your file download is complete, unzip the file.

[Type text] Page 31


[Type the document title]

Fig. 3.1 Opening arduino-nightly-windows.zip

Launch Arduino IDE. After your Arduino IDE software is downloaded, you need to unzip the
folder. Inside the folder, you can find the application icon with an infinity label (application.exe).
Doubleclick the icon to start the IDE.

[Type text] Page 32


[Type the document title]

Fig:3.2 Launch Arduino IDE

Open your first project. Once the software starts, you have two options:

 Create a new project.

 Open an existing project example.

To create a new project, select File --> New

[Type text] Page 33


[Type the document title]

Fig:3.2 Create a new project

Fig: 3.3Open an existing project example

[Type text] Page 34


[Type the document title]

Here, we are selecting just one of the examples with the name Blink. It turns the LED on and off
with some time delay. You can select any other example from the list Select your serial port.
Select the serial device of the Arduino board. Go to Tools -> Serial Port menu. This is likely to
be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find
out, you can disconnect your Arduino board and re-open the menu, the entry that disappears
should be of the Arduino board. Reconnect the board and select that serial port.

Fig:3.4 Select your serial port

There’s an add-on for the Arduino IDE that allows you to program the ESP32 using the Arduino
IDE and its programming language. In this tutorial we’ll show you how to install the ESP32
board in Arduino IDE whether you’re using Windows, Mac OS X or Linux

Before starting this installation procedure, make sure you have the latest version of the Arduino
IDE installed in your computer. If you don’t, uninstall it and install it again. Otherwise, it may
not work.

Having the latest Arduino IDE software installed from arduino.cc/en/Main/Software, continue
with this tutorial.

[Type text] Page 35


[Type the document title]

Do you need an ESP32 board? You can buy it here.

Installing ESP32 Add-on in Arduino IDE

To install the ESP32 board in your Arduino IDE, follow these next instructions:

1. In your Arduino IDE, go to File> Preferences

2. Enter https://dl.espressif.com/dl/package_esp32_index.json into the


“Additional Board Manager URLs” field as shown in the figure below. Then,
click the “OK” button:

[Type text] Page 36


[Type the document title]

Note: if you already have the ESP8266 boards URL, you can separate the URLs
with a comma as follows:
https://dl.espressif.com/dl/package_esp32_index.json,
http://arduino.esp8266.com/stable/package_esp8266com_index.json

3. Open the Boards Manager. Go to Tools > Board > Boards Manager…

[Type text] Page 37


[Type the document title]

4. Search for ESP32 and press install button for the “ESP32 by Espressif Systems“:

[Type text] Page 38


[Type the document title]

5. That’s it. It should be installed after a few seconds.

Testing the Installation

Plug the ESP32 board to your computer. With your Arduino IDE open, follow these steps:

[Type text] Page 39


[Type the document title]

1. Select your Board in Tools > Board menu (in my case it’s the DOIT ESP32 DEVKIT V1)

2. Select the Port (if you don’t see the COM Port in your Arduino IDE, you need to install
the CP210x USB to UART Bridge VCP Drivers):

[Type text] Page 40


[Type the document title]

3. Open the following example under File > Examples > WiFi (ESP32) > WiFiScan

[Type text] Page 41


[Type the document title]

4. A new sketch opens in your Arduino IDE:

[Type text] Page 42


[Type the document title]

5. Press the Upload button in the Arduino IDE. Wait a few seconds while the code compiles and
uploads to your board.

6. If everything went as expected, you should see a “Done uploading.” message.

[Type text] Page 43


[Type the document title]

7. Open the Arduino IDE Serial Monitor at a baud rate of 115200:

8. Press the ESP32 on-board Enable button and you should see the networks available near your
ESP32:

[Type text] Page 44


[Type the document title]

Troubleshooting

If you try to upload a new sketch to your ESP32 and you get this error message “A fatal error
occurred: Failed to connect to ESP32: Timed out… Connecting…“. It means that your ESP32 is
not in flashing/uploading mode.
Having the right board name and COM por selected, follow these steps:

 Hold-down the “BOOT” button in your ESP32 board

[Type text] Page 45


[Type the document title]

 Press the “Upload” button in the Arduino IDE to upload your sketch:

 After you see the “Connecting….” message in your Arduino IDE, release the
finger from the “BOOT” button:

 After that, you should see the “Done uploading” message

[Type text] Page 46


[Type the document title]

That’s it. Your ESP32 should have the new sketch running. Press the “ENABLE” button to
restart the ESP32 and run the new uploaded sketch. You’ll also have to repeat that button
sequence every time you want to upload a new sketch. But if you want to solve this issue once
for all without the need to press the BOOT button, follow the suggestions in the next guide:

[Type text] Page 47


[Type the document title]

CODING:

WORKING:

CONCLUSION

[Type text] Page 48


[Type the document title]

REFERENCES:

[Type text] Page 49

You might also like