Arduino To ESP32: How to Get Started!

Robonyx
12 Mar 202409:26

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

00:00

🛠️ 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.

05:01

🔌 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

Arduino is an open-source platform used for building electronics projects. It includes physical boards that can be programmed to control a variety of devices, and it's often used in educational settings and hobbyist projects. In the video, Arduino is used as a comparison to the ESP32, highlighting the difference in processing power and capabilities. The Arduino Uno is mentioned as a classic board with an ATmega328P chip, while Arduino boards with ESP chips are distinguished as a separate category.

💡ESP32

ESP32 is a series of low-cost, low-power microcontrollers with integrated Wi-Fi and dual-mode Bluetooth. It is designed for Internet of Things applications and is produced by Espressif Systems. The video focuses on upgrading from Arduino to ESP32 for wireless capabilities, discussing its superior processing power, as demonstrated by the prime number finding test, and its versatility in programming and connectivity.

💡DevKitC

ESP32 DevKitC is an entry-level development board for ESP32, designed by Espressif. It is recommended for beginners as it contains the standard ESP32 chip and has a built-in PCB antenna. The video suggests starting with this board for simplicity and mentions that it is widely available, even in clone versions, which are functionally similar.

💡Microcontroller

A microcontroller is a small computer on a single integrated circuit. It is used in embedded systems and is designed to govern a specific operation in an embedded system. In the video, both the Arduino Uno and the ESP32 are described as having microcontroller chips, with the ESP32 having a notably faster 240MHz Dual-Core processor compared to the 16MHz ATmega328P of the Arduino Uno.

💡GPIO Pins

GPIO stands for General Purpose Input/Output and refers to pins on a microcontroller that can be programmed to read or write data. These pins are used to connect external components to the microcontroller. The video mentions that both Arduino and ESP32 have GPIO pins, but the ESP32 has more versatile pins, with the ability to output PWM at a higher resolution.

💡Arduino IDE

Arduino IDE is a software application that provides a development environment for programming Arduino boards. It includes a code editor, a serial monitor, and a code uploader. The video explains that the ESP32 can be programmed using the Arduino IDE with a bit of setup, including installing the ESP32 board package.

💡PWM

PWM stands for Pulse Width Modulation, a technique used to encode a digital signal into an analog signal. It is commonly used for controlling the speed of motors or the brightness of LEDs. The video highlights that the ESP32 can output PWM with a resolution of 16 bits, compared to the 8 bits (0 to 255) on Arduino, allowing for more precise control.

💡ADC

ADC stands for Analog to Digital Converter, a system that converts continuous signals to discrete digital numbers. In the context of the video, the ESP32's 12-bit ADC is mentioned, which can read analog values from a range of 0 to 4095, compared to the 10-bit ADC of the Arduino Uno, which reads from 0 to 1023.

💡DAC

DAC stands for Digital to Analog Converter, which converts digital signals into analog signals. The video mentions that the ESP32 has two DACs, allowing it to generate analog signals, which is a feature not present in the Arduino Uno.

💡Level Shifter

A level shifter is a circuit that converts signals from one voltage level to another. In the video, it is mentioned as a solution for interfacing the 5V Arduino with the 3.3V ESP32, allowing them to communicate by converting the signal voltages appropriately.

💡Wi-Fi and Bluetooth

Wi-Fi and Bluetooth are wireless communication technologies. The video explains that the ESP32 has Wi-Fi and Bluetooth capabilities, which allow it to connect to the internet, interact with web-based APIs, and pair with other devices, setting it apart from standard Arduinos which do not have these features.

💡ESP-NOW

ESP-NOW is a communication protocol developed by Espressif that allows two ESP devices to communicate directly over Wi-Fi without the need for a router or access point. The video describes it as being more efficient than Bluetooth with a greater range and faster data transfer, making it a unique feature of the ESP32.

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

play00:00

If you're looking to upgrade your Arduino projects with wireless capabilities,

play00:03

this is how to get started with the ESP32.

play00:06

We'll cover quick spec comparisons,

play00:08

Picking your first board, how to program it, and other key features of the ESP32.

play00:13

Let's start by comparing the two boards.

play00:15

We use a classic Arduino Uno and the ESP32 DevKitC

play00:19

which is a Espressif’s entry-level development board.

play00:22

Both have a microcontroller chip, which is like the brains for each one.

play00:25

The UNO sports the 16MHz ATmega328P

play00:29

whilst the ESP’s got a 240MHz

play00:32

D0WDQ6 chip underneath this metal RF shield.

play00:36

Let's test their processing power by running a program that will make them

play00:39

find as many prime numbers as they can in 30 seconds.

play00:42

The Arduino Uno managed to find over 3000 primes,

play00:45

but the ESP32 destroys it with over 125,000 primes.

play00:50

The other sections on each board are for voltage regulation

play00:53

programing ICs and GPIO pins to connect to other components.

play00:57

They've both got reset buttons, but the ESP has an additional boot button.

play01:01

Also, when I refer to Arduino, I'm referring to the original boards

play01:05

that use the ATmega chips and not the recent Arduinos

play01:07

that have ESP chips in them.

play01:09

If you're just getting started, you may be wondering what ESP32 model

play01:13

should I get? Checking the official website,

play01:15

You can see that Espressif produces their own chips.

play01:18

These chips create their series, which includes development

play01:21

boards or 'DevKits' that you can buy from their distributors.

play01:24

You may also come across ESP boards made by other companies

play01:27

like NodeMCU, Sparkfun and Adafruit.

play01:31

This is because Espressif open sources their schematics and PCBs!

play01:36

for simplicity though start with the ESP32 DevKitC.

play01:39

This is the one that has the standard ESP32 chip.

play01:43

A simple search on Amazon shows this model mass produced by other manufacturers.

play01:47

The one used for this video is a clone and they pretty much work all the same.

play01:51

It has a built in PCB antenna and 38 pins, so you can do more than a 30 pin one.

play01:57

There's a link in the description for a 3-pack of these DevKitC boards

play02:01

So if you happen to fry one or something, it's no big deal.

play02:04

Now onto the programming stuff

play02:06

The easiest way to program the ESP32 is with the Arduino IDE.

play02:11

It's just like working with an Arduino.

play02:13

There's just a bit of setup though...

play02:15

You need to get the ESP32 board package.

play02:17

Here's how. Open the Board Manager in the IDE

play02:20

search for ESP32 and install the latest version.

play02:24

Once installed, you can pick your board in the IDE.

play02:27

For this ESP32 Dev one choose the ESP32

play02:30

Dev Module and now our code runs just fine.

play02:33

And also if you use

play02:34

Arduino functions in your sketch, make sure to include Arduino.h at the top.

play02:40

Some libraries are incompatible

play02:42

with the ESP and only work with Arduinos like the Servo and the TimerOne.

play02:46

Not to worry though, most popular libraries have an ESP32 version

play02:50

that does basically the same thing like ESP32Servo and ESP32TimerInterrupt.

play02:55

Now after the software is all set up, we need to know how to power this thing.

play02:59

You can power the ESP32 in three ways.

play03:01

1. using the cable and plugging it in.

play03:04

2. supplying 5V to the 5V and GND pins

play03:07

or 3. supplying 3.3V to 3.3V and GND pins.

play03:11

But be careful not to supply more voltage at this pin or it's gonna be fried.

play03:16

The only exception on this board is the 5V pin since it's

play03:19

got a voltage regulator.

play03:21

Great! Now everything is powered,

play03:22

Let's look at the pinout

play03:24

this ESP has 38 pins, 6 of which are for power and 6 can't be used.

play03:29

So that leaves us with 26 GPIO pins.

play03:32

These 26 are extremely versatile.

play03:34

22 of them can output PWM with a resolution of 16 bits.

play03:39

So on Arduino, you're used to analogWriting values from 0 to 255,

play03:44

but with 16 bits on an ESP32,

play03:47

you can analogWrite from 0 to 65535.

play03:52

16 pins can read

play03:54

analog signals with its 12 bit ADCs.

play03:57

12 bits means it can read analog values from a range of 0 to 4095.

play04:02

The Arduino

play04:03

for comparison has a 10 bit ADC, so when you use the analogRead function,

play04:07

it will read analog values from a range of 0 to 1023.

play04:11

ESPs also have 2 DACs or Digital to

play04:14

Analog Converters, so you can generate analog signals.

play04:18

For a more detailed look of the pinout, you can pause right here

play04:21

to see the official diagram of the DevKitC.

play04:23

with the specs and the legend at the bottom.

play04:26

Now you know the pinout let's connect peripherals like sensors, drivers

play04:29

and displays.

play04:30

ESPs operate on 3.3V, while Arduinos operate on 5V.

play04:35

This means that all peripherals, whether they’re input or output ones,

play04:39

can only use 3.3V when sending data to or receiving data

play04:43

from the ESP. For components that will send signals to the ESP

play04:47

like this IR sensor, we need to check if it will output a signal of 3.3V

play04:51

or lower. If the module can operate on 3.3V, it will output signals

play04:56

at or below 3.3V, which is suitable for interfacing with the ESP.

play05:00

Let's keep going!💥 For components that receive signals from the ESP32,

play05:04

like this motor driver,

play05:06

We need to check the datasheet to know if a 3.3 volt signal

play05:09

was sent to the motor driver is considered as HIGH.

play05:12

It says input high voltage 2.3 volts,

play05:15

which means that the motor driver will see anything above this as a high signal.

play05:19

Nice!

play05:20

However, some peripherals like this ultrasonic sensor require 5V.

play05:24

Most of the time there are 3.3V alternatives like this module.

play05:28

But if you absolutely must use a component that operates on 5V,

play05:32

then you can use a level shifter.

play05:34

For example, if you wanted to have an Arduino communicating

play05:37

to an ESP, a level shifter would go in between and convert the 5V

play05:41

signals to 3.3V and the 3.3V signals to 5V.

play05:45

This way we can establish communication between the Arduino and the ESP.

play05:50

Let's see how the ESP and Arduino communicate.

play05:53

Hey ESP32

play05:55

Wanna hear a joke? Yeah, What?

play05:57

Why did the ESP32 go to the beach? Why?

play06:01

To surf the net! Bruh...

play06:04

So all jokes

play06:04

aside, the communication actually goes pretty quick.

play06:08

Just like that.

play06:09

Now, here's a brief rundown of the code.

play06:10

First, we define the pins for each board.

play06:13

Then we start serial communication for the computer, since we'll be printing

play06:16

to the serial monitor.

play06:18

They will also need to print to each other,

play06:20

so we begin that one too.

play06:21

There's a two second delay to give everything time to fully setup.

play06:24

I then initiated the first line

play06:26

from the Arduino with the println command and the ESP has an If statement,

play06:30

so when the line reaches the ESP through the level shifter,

play06:32

it will say received from Arduino.

play06:34

And then the ESP will spit back another line and they will just keep talking.

play06:38

You may have heard of communication protocols such as UART, I2C

play06:42

and SPI.

play06:43

Different devices require you to talk to it in the specific protocol. For UART,

play06:47

The Uno has one port,

play06:49

while the ESP32 has 3. For I2C and SPI,

play06:53

Uno has one dedicated port each while ESP32 is a little more complex.

play06:58

Many GPIO pins can be software configured for SPI or I2C.

play07:03

Now onto Wi-Fi and Bluetooth capabilities,

play07:05

the stuff that really sets the ESP32 apart! The ESP32 can operate in three

play07:11

Wi-Fi modes: Station, Access Point and Dual Mode. In Station Mode,

play07:16

the ESP32 connects

play07:17

to an existing Wi-Fi network, just like a smartphone or a laptop.

play07:21

This mode enables the ESP32 to access Internet

play07:24

services, download data and interact with web based APIs.

play07:28

This gives you the ability to build weather displays and even integrate

play07:31

GPT abilities into your projects. In Access Point Mode,

play07:35

The ESP creates its own wireless network that other devices can discover

play07:40

and connect to.

play07:41

You can also create a web server so that devices can send information to your ESP.

play07:46

Here I created a network that I connected to with my phone and by using a web

play07:50

browser, I can access this web server and send information wirelessly.

play07:56

Lastly, there's Dual Mode where it can simultaneously connect

play07:59

to an existing Wi-Fi network and also act as an access point.

play08:03

This means it can maintain Internet access while providing a direct connection

play08:07

for other devices.

play08:08

So if we had data received from local devices, in Access Point Mode, you

play08:12

then forward this to a server on the internet in Station Mode or vice versa.

play08:17

ESP also supports Bluetooth connectivity.

play08:20

Just like how you can pair your headphones to your phone, you can pair

play08:23

your ESP32 with any other devices to transmit information to each other.

play08:27

I'm using an app called “Dabble”

play08:29

and this lets me send information from my phone to the ESP.

play08:33

In addition to Wi-Fi and Bluetooth, the ESP has another

play08:36

communication feature, the ESP-NOW protocol.

play08:39

It's a unique protocol developed by Espressif,

play08:42

which basically allows two ESPs to communicate.

play08:45

This protocol operates on the Wi-Fi band, meaning it's the same

play08:48

radio frequency as Wi-Fi, but doesn't need a router or Access Point.

play08:52

It's like Bluetooth in terms of efficiency and low power usage,

play08:56

but as a greater range and faster data transfer.

play08:59

So it sits between Wi-Fi and Bluetooth.

play09:01

So yeah, that's just a quick briefer on the differences,

play09:04

features, what board to get and how to use it.

play09:07

If you're looking for a high performance microcontroller with some wireless perks,

play09:11

the ESP32 is a pretty good next step from standard Arduinos.

play09:15

If you want to get started with ESP32, there's a link down below

play09:18

and that's pretty much all the basics. Have fun!

Rate This

5.0 / 5 (0 votes)

Связанные теги
Arduino UpgradeESP32Wireless MCUMicrocontrollerIoTProgrammingWi-FiBluetoothDIYTech Tutorial
Вам нужно краткое изложение на английском?