Arduino To ESP32: How to Get Started!
Summary
TLDRThis video offers a beginner's guide to integrating wireless capabilities into Arduino projects using the ESP32. It compares the ESP32 DevKitC with the Arduino Uno, highlighting the ESP32's superior processing power. The video guides viewers on selecting the right ESP32 model, setting up the board with the Arduino IDE, and programming it. It also covers powering the ESP32, understanding its pinout, and connecting peripherals, emphasizing the importance of voltage compatibility. The ESP32's Wi-Fi and Bluetooth capabilities, along with the ESP-NOW protocol, are showcased, positioning the ESP32 as an excellent choice for high-performance microcontrollers with wireless features.
Takeaways
- 🚀 **ESP32 vs Arduino Uno**: The ESP32 DevKitC has a 240MHz Dual-core processor compared to Arduino Uno's 16MHz ATmega328P, making it significantly more powerful.
- 🔍 **Performance Test**: In a prime number finding test, the ESP32 found over 125,000 primes in 30 seconds, vastly outperforming the Arduino Uno which found over 3000.
- 🛠️ **Board Features**: Both boards have microcontrollers, voltage regulation, programming ICs, and GPIO pins, but the ESP32 also includes a boot button.
- 🏭 **ESP32 Models**: Espressif produces official ESP32 DevKits, but there are also many third-party boards available due to open-sourced schematics and PCBs.
- 🛒 **Getting Started**: For beginners, the ESP32 DevKitC is recommended as it is a standard model with a built-in PCB antenna and 38 pins.
- 💻 **Programming with Arduino IDE**: The ESP32 can be programmed using the Arduino IDE with a simple setup process involving installing the ESP32 board package.
- 🔌 **Powering the ESP32**: The ESP32 can be powered in three ways: through a USB cable, by supplying 5V to the 5V and GND pins, or by supplying 3.3V to the 3.3V and GND pins.
- 📍 **Pinout and Capabilities**: The ESP32 has 38 pins with 26 GPIO pins, 22 of which can output PWM with 16-bit resolution and 16 pins can read analog signals with 12-bit ADCs.
- ⚙️ **Peripheral Compatibility**: ESP32 operates on 3.3V, so peripherals must be compatible with this voltage. Level shifters can be used for components requiring 5V.
- 🌐 **Communication Protocols**: The ESP32 supports UART, I2C, and SPI protocols with multiple software-configurable GPIO pins for I2C and SPI.
- 📡 **Wi-Fi and Bluetooth**: The ESP32 can operate in Station, Access Point, and Dual Mode for Wi-Fi, and supports Bluetooth connectivity for device pairing and data transmission.
- 📶 **ESP-NOW Protocol**: A unique protocol by Espressif that allows two ESP32s to communicate directly over Wi-Fi band without needing a router or Access Point.
Q & A
What is the primary difference between the Arduino Uno and the ESP32 DevKitC in terms of processing power?
-The Arduino Uno has a 16MHz ATmega328P chip, while the ESP32 DevKitC has a 240MHz Dual Core Xtensa®-32 D0WDQ6 chip, resulting in the ESP32 being significantly more powerful in processing tasks such as finding prime numbers.
How does the ESP32 outperform the Arduino Uno in a prime number finding test?
-In a test where both boards were programmed to find as many prime numbers as possible in 30 seconds, the Arduino Uno found over 3000 primes, while the ESP32 found over 125,000 primes, demonstrating its superior processing power.
What additional button does the ESP32 have compared to the Arduino Uno?
-The ESP32 has an additional boot button besides the reset button, which is not present on the Arduino Uno.
Why does the ESP32's open-source schematics and PCBs allow other companies to produce ESP boards?
-Espressif's decision to open source their schematics and PCBs enables other companies to create their own versions of ESP boards, increasing the availability and variety of ESP32 products in the market.
What is the recommended ESP32 model for beginners according to the script?
-For beginners, the recommended ESP32 model is the ESP32 DevKitC, which is Espressif’s entry-level development board with the standard ESP32 chip.
How can one program the ESP32 using the Arduino IDE?
-To program the ESP32 with the Arduino IDE, one must install the ESP32 board package through the Board Manager, select the board in the IDE, and include 'Arduino.h' at the top of the sketch if using Arduino functions.
What are the three ways to power the ESP32 mentioned in the script?
-The ESP32 can be powered by using a USB cable, supplying 5V to the 5V and GND pins, or supplying 3.3V to the 3.3V and GND pins.
How many GPIO pins does the ESP32 have and what can they be used for?
-The ESP32 has 26 usable GPIO pins. 22 of them can output PWM with a resolution of 16 bits, and 16 pins can read analog signals with 12-bit ADCs. It also has 2 DACs for generating analog signals.
What is the significance of the ESP32's 16-bit PWM resolution compared to the Arduino's 10-bit?
-The ESP32's 16-bit PWM resolution allows for analogWrite values from 0 to 65535, providing a much finer control over the analog output compared to the Arduino's 10-bit resolution which allows values from 0 to 1023.
How can one ensure that 5V peripherals are compatible with the 3.3V operating ESP32?
-One can use a level shifter to convert 5V signals to 3.3V for peripherals that require 5V, allowing them to communicate with the ESP32 safely.
What are the three Wi-Fi modes the ESP32 can operate in?
-The ESP32 can operate in Station Mode, Access Point Mode, and Dual Mode. Station Mode allows it to connect to existing Wi-Fi networks, Access Point Mode lets it create its own network, and Dual Mode enables it to do both simultaneously.
Outlines
🛠️ Getting Started with ESP32
This paragraph introduces the ESP32 as an upgrade for Arduino projects seeking wireless capabilities. It compares the Arduino Uno and ESP32 DevKitC boards, highlighting their microcontroller chips: the Uno's 16MHz ATmega328P versus the ESP32's 240MHz DOWDQ6. A prime number-finding program illustrates the ESP32's superior processing power, with the Uno finding over 3000 primes and the ESP32 over 125,000 in 30 seconds. The paragraph also discusses the boards' sections for voltage regulation, programming ICs, and GPIO pins, as well as the additional boot button on the ESP32. It advises beginners to start with the ESP32 DevKitC, which is mass-produced by various manufacturers and has a built-in PCB antenna and 38 pins. The programming process using the Arduino IDE is outlined, including installing the ESP32 board package and selecting the board in the IDE. The paragraph also mentions the incompatibility of some Arduino libraries with the ESP32 and the availability of ESP32 versions of popular libraries. Finally, it covers the different ways to power the ESP32 and its pinout, which includes 26 versatile GPIO pins capable of PWM output and analog signal reading.
🔌 Powering and Interfacing ESP32
The second paragraph delves into powering the ESP32, with options including using a cable, supplying 5V or 3.3V to specific pins, and cautioning against over-voltage. It details the ESP32's pinout, with 38 pins in total, 26 of which are GPIO and capable of various functions like PWM output with 16-bit resolution and analog signal reading with 12-bit ADCs. The paragraph contrasts this with the Arduino's 10-bit ADC. It also discusses the need for level shifting when interfacing the 3.3V ESP32 with 5V peripherals, using an ultrasonic sensor as an example and suggesting 3.3V alternatives where possible. The communication between an Arduino and an ESP32 is exemplified through a joke and a brief code rundown, highlighting serial communication setup and data exchange. The paragraph further explains communication protocols like UART, I2C, and SPI, with the ESP32's ability to software-configure many GPIO pins for these protocols. It concludes with an overview of the ESP32's Wi-Fi and Bluetooth capabilities, including Station, Access Point, and Dual Mode for Wi-Fi, and the ESP-NOW protocol for direct ESP-to-ESP communication without a router, positioning the ESP32 as a high-performance microcontroller with wireless features.
Mindmap
Keywords
💡Arduino
💡ESP32
💡DevKitC
💡Microcontroller
💡GPIO Pins
💡Arduino IDE
💡PWM
💡ADC
💡DAC
💡Level Shifter
💡Wi-Fi and Bluetooth
💡ESP-NOW
Highlights
Introduction to upgrading Arduino projects with wireless capabilities using ESP32.
Comparison between Arduino Uno and ESP32 DevKitC boards.
Processing power test showing ESP32's superior performance over Arduino Uno.
Explanation of voltage regulation, programming ICs, and GPIO pins on both boards.
Recommendation for beginners on which ESP32 model to choose.
Advantage of starting with the ESP32 DevKitC for simplicity.
How to program the ESP32 using the Arduino IDE.
Instructions on installing the ESP32 board package in the Arduino IDE.
Caution about incompatible libraries and the availability of ESP32 versions.
Different ways to power the ESP32 and cautions regarding voltage levels.
Detailed pinout of the ESP32 with 38 pins and their capabilities.
Ability of ESP32 to output PWM with 16-bit resolution.
ESP32's 12-bit ADC capability compared to Arduino's 10-bit ADC.
ESP32's 2 DACs for generating analog signals.
Guidance on connecting peripherals to the ESP32 considering voltage levels.
Use of level shifters for components requiring different voltage levels.
Demonstration of communication between Arduino and ESP32.
Overview of communication protocols supported by ESP32: UART, I2C, and SPI.
ESP32's Wi-Fi capabilities in Station, Access Point, and Dual Mode.
ESP32's Bluetooth connectivity and its ability to pair with other devices.
Introduction to ESP-NOW protocol for direct ESP-to-ESP communication.
Conclusion on the benefits of ESP32 for high-performance microcontroller projects with wireless features.
Transcripts
If you're looking to upgrade your Arduino projects with wireless capabilities,
this is how to get started with the ESP32.
We'll cover quick spec comparisons,
Picking your first board, how to program it, and other key features of the ESP32.
Let's start by comparing the two boards.
We use a classic Arduino Uno and the ESP32 DevKitC
which is a Espressif’s entry-level development board.
Both have a microcontroller chip, which is like the brains for each one.
The UNO sports the 16MHz ATmega328P
whilst the ESP’s got a 240MHz
D0WDQ6 chip underneath this metal RF shield.
Let's test their processing power by running a program that will make them
find as many prime numbers as they can in 30 seconds.
The Arduino Uno managed to find over 3000 primes,
but the ESP32 destroys it with over 125,000 primes.
The other sections on each board are for voltage regulation
programing ICs and GPIO pins to connect to other components.
They've both got reset buttons, but the ESP has an additional boot button.
Also, when I refer to Arduino, I'm referring to the original boards
that use the ATmega chips and not the recent Arduinos
that have ESP chips in them.
If you're just getting started, you may be wondering what ESP32 model
should I get? Checking the official website,
You can see that Espressif produces their own chips.
These chips create their series, which includes development
boards or 'DevKits' that you can buy from their distributors.
You may also come across ESP boards made by other companies
like NodeMCU, Sparkfun and Adafruit.
This is because Espressif open sources their schematics and PCBs!
for simplicity though start with the ESP32 DevKitC.
This is the one that has the standard ESP32 chip.
A simple search on Amazon shows this model mass produced by other manufacturers.
The one used for this video is a clone and they pretty much work all the same.
It has a built in PCB antenna and 38 pins, so you can do more than a 30 pin one.
There's a link in the description for a 3-pack of these DevKitC boards
So if you happen to fry one or something, it's no big deal.
Now onto the programming stuff
The easiest way to program the ESP32 is with the Arduino IDE.
It's just like working with an Arduino.
There's just a bit of setup though...
You need to get the ESP32 board package.
Here's how. Open the Board Manager in the IDE
search for ESP32 and install the latest version.
Once installed, you can pick your board in the IDE.
For this ESP32 Dev one choose the ESP32
Dev Module and now our code runs just fine.
And also if you use
Arduino functions in your sketch, make sure to include Arduino.h at the top.
Some libraries are incompatible
with the ESP and only work with Arduinos like the Servo and the TimerOne.
Not to worry though, most popular libraries have an ESP32 version
that does basically the same thing like ESP32Servo and ESP32TimerInterrupt.
Now after the software is all set up, we need to know how to power this thing.
You can power the ESP32 in three ways.
1. using the cable and plugging it in.
2. supplying 5V to the 5V and GND pins
or 3. supplying 3.3V to 3.3V and GND pins.
But be careful not to supply more voltage at this pin or it's gonna be fried.
The only exception on this board is the 5V pin since it's
got a voltage regulator.
Great! Now everything is powered,
Let's look at the pinout
this ESP has 38 pins, 6 of which are for power and 6 can't be used.
So that leaves us with 26 GPIO pins.
These 26 are extremely versatile.
22 of them can output PWM with a resolution of 16 bits.
So on Arduino, you're used to analogWriting values from 0 to 255,
but with 16 bits on an ESP32,
you can analogWrite from 0 to 65535.
16 pins can read
analog signals with its 12 bit ADCs.
12 bits means it can read analog values from a range of 0 to 4095.
The Arduino
for comparison has a 10 bit ADC, so when you use the analogRead function,
it will read analog values from a range of 0 to 1023.
ESPs also have 2 DACs or Digital to
Analog Converters, so you can generate analog signals.
For a more detailed look of the pinout, you can pause right here
to see the official diagram of the DevKitC.
with the specs and the legend at the bottom.
Now you know the pinout let's connect peripherals like sensors, drivers
and displays.
ESPs operate on 3.3V, while Arduinos operate on 5V.
This means that all peripherals, whether they’re input or output ones,
can only use 3.3V when sending data to or receiving data
from the ESP. For components that will send signals to the ESP
like this IR sensor, we need to check if it will output a signal of 3.3V
or lower. If the module can operate on 3.3V, it will output signals
at or below 3.3V, which is suitable for interfacing with the ESP.
Let's keep going!💥 For components that receive signals from the ESP32,
like this motor driver,
We need to check the datasheet to know if a 3.3 volt signal
was sent to the motor driver is considered as HIGH.
It says input high voltage 2.3 volts,
which means that the motor driver will see anything above this as a high signal.
Nice!
However, some peripherals like this ultrasonic sensor require 5V.
Most of the time there are 3.3V alternatives like this module.
But if you absolutely must use a component that operates on 5V,
then you can use a level shifter.
For example, if you wanted to have an Arduino communicating
to an ESP, a level shifter would go in between and convert the 5V
signals to 3.3V and the 3.3V signals to 5V.
This way we can establish communication between the Arduino and the ESP.
Let's see how the ESP and Arduino communicate.
Hey ESP32
Wanna hear a joke? Yeah, What?
Why did the ESP32 go to the beach? Why?
To surf the net! Bruh...
So all jokes
aside, the communication actually goes pretty quick.
Just like that.
Now, here's a brief rundown of the code.
First, we define the pins for each board.
Then we start serial communication for the computer, since we'll be printing
to the serial monitor.
They will also need to print to each other,
so we begin that one too.
There's a two second delay to give everything time to fully setup.
I then initiated the first line
from the Arduino with the println command and the ESP has an If statement,
so when the line reaches the ESP through the level shifter,
it will say received from Arduino.
And then the ESP will spit back another line and they will just keep talking.
You may have heard of communication protocols such as UART, I2C
and SPI.
Different devices require you to talk to it in the specific protocol. For UART,
The Uno has one port,
while the ESP32 has 3. For I2C and SPI,
Uno has one dedicated port each while ESP32 is a little more complex.
Many GPIO pins can be software configured for SPI or I2C.
Now onto Wi-Fi and Bluetooth capabilities,
the stuff that really sets the ESP32 apart! The ESP32 can operate in three
Wi-Fi modes: Station, Access Point and Dual Mode. In Station Mode,
the ESP32 connects
to an existing Wi-Fi network, just like a smartphone or a laptop.
This mode enables the ESP32 to access Internet
services, download data and interact with web based APIs.
This gives you the ability to build weather displays and even integrate
GPT abilities into your projects. In Access Point Mode,
The ESP creates its own wireless network that other devices can discover
and connect to.
You can also create a web server so that devices can send information to your ESP.
Here I created a network that I connected to with my phone and by using a web
browser, I can access this web server and send information wirelessly.
Lastly, there's Dual Mode where it can simultaneously connect
to an existing Wi-Fi network and also act as an access point.
This means it can maintain Internet access while providing a direct connection
for other devices.
So if we had data received from local devices, in Access Point Mode, you
then forward this to a server on the internet in Station Mode or vice versa.
ESP also supports Bluetooth connectivity.
Just like how you can pair your headphones to your phone, you can pair
your ESP32 with any other devices to transmit information to each other.
I'm using an app called “Dabble”
and this lets me send information from my phone to the ESP.
In addition to Wi-Fi and Bluetooth, the ESP has another
communication feature, the ESP-NOW protocol.
It's a unique protocol developed by Espressif,
which basically allows two ESPs to communicate.
This protocol operates on the Wi-Fi band, meaning it's the same
radio frequency as Wi-Fi, but doesn't need a router or Access Point.
It's like Bluetooth in terms of efficiency and low power usage,
but as a greater range and faster data transfer.
So it sits between Wi-Fi and Bluetooth.
So yeah, that's just a quick briefer on the differences,
features, what board to get and how to use it.
If you're looking for a high performance microcontroller with some wireless perks,
the ESP32 is a pretty good next step from standard Arduinos.
If you want to get started with ESP32, there's a link down below
and that's pretty much all the basics. Have fun!
浏览更多相关视频
Speech To Text using ESP32
ESP32 Servo Motor Web Server with Arduino IDE
Monitoring Suhu Dan Kelembaban Menggunakan ESP32 + DHT22 Dengan Protokol MQTT
Meet the NetGotchi: A New Firmware for ESP32 boards Packed with Defensive Tools
Sistem Mikrokontroler - 01 - Pengantar Mikrokontroler
Home Assistant 2024 - How To Add Bluetooth Proxy & Sensors
5.0 / 5 (0 votes)