Esp32 Sample Document
Esp32 Sample Document
ABSTRACT:
CHAPTER 1
INTRODUCTION
PROBLEM STATEMENT
EXISTING SYSTEM
PROPOSED SYSTEM
CHAPTER 2
LITERATURE SURVEY
CHAPTER 3
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.
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.
f. Application-specific circuitry
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
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.
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
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.
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.
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
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.
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.
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.
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.
3. Circuit diagram:
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.
SPECIFICATIONS IC 7805
V out 5V
V - V Difference
ein out 5V - 20V
Output I max 1A
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.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
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.
• 802.11 b/g/n
• WMM
• Defragmentation
• 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
• 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
• External 2 MHz ~ 60 MHz crystal oscillator (40 MHz only for Wi-Fi/BT functionality)
• Two timer groups, including 2 × 64-bit timers and 1 × main watchdog in each group
• RTC watchdog
• 34 × programmable GPIOs
• 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
• IR (TX/RX)
• Motor PWM
• Hall sensor
1.4.4 SECURITY
• Secure boot
• Flash encryption
• Speech Recognition
• Image Recognition
• Mesh Network
• Home Automation – Light control – Smart plugs – Smart door locks • Smart Building – Smart
lighting – Energy monitoring
• Wi-Fi-enabled Toys – Remote control toys – Proximity sensing toys – Educational toys •
Wearable Electronics – Smart watches – Smart bracelets
OVERVIEW
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
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.
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.
GPIO Pins
ESP32 Wroom32 DevKit has total 25 GPIOs out of that few pins are Input only Pins,
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.
GPIO14
GPIO16
GPIO17
GPIO18
GPIO19
GPIO21
GPIO22
GPIO23
GPIO13
GPIO25
GPIO26
GPIO27
GPIO32
GPIO33
In arduino to use these pins you can simply use common commands
pinMode(22,INPUT_PULLUP);
pinMode(23,OUTPUT);
digitalWrite(23,HIGH);
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 .
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.
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
replace mechanical buttons. The capacitive touch pins can also be used to wake up the ESP32
from deep sleep.
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)
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.
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
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.
Serial
GPIO3 (U0RXD)
GPIO1(U0TXD)
GPIO16 (U2RXD).
GIIO17 (U2TXD).
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
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.
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.
Open your first project. Once the software starts, you have two options:
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.
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.
To install the ESP32 board in your Arduino IDE, follow these next instructions:
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…
4. Search for ESP32 and press install button for the “ESP32 by Espressif Systems“:
Plug the ESP32 board to your computer. With your Arduino IDE open, follow these steps:
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):
3. Open the following example under File > Examples > WiFi (ESP32) > WiFiScan
5. Press the Upload button in the Arduino IDE. Wait a few seconds while the code compiles and
uploads to your board.
8. Press the ESP32 on-board Enable button and you should see the networks available near your
ESP32:
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:
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:
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:
CODING:
WORKING:
CONCLUSION
REFERENCES: