Introduction to ESP...
 
Notifications
Clear all

Introduction to ESP32 - Getting Started

Page 1 / 2

DroneBot Workshop
(@dronebot-workshop)
Workshop Guru Admin
Joined: 3 years ago
Posts: 1096
Topic starter  

Today we will get started with the ESP32, a low-cost and extremely versatile microcontroller with integrated WiFi and Bluetooth. I’ll show you how to set up your Arduino IDE for the ESP32 and then we’ll try out several example sketches.

Full Article with code: https://dbot.ws/esp32

I apologize for the delay in getting another video out for you, the current situation has greatly impacted me as I’m sure it has you. Please stay safe and isolate!

After many requests, I am finally bringing the ESP32 into the workshop, and it’s here to stay - I’ll be doing a lot of ESP32 projects going forward. And when you see all of the features that this incredible microcontroller has I’m sure you see why!

The ESP32 is a microcontroller from Espressif Systems that has a wealth of features, including multiple I/O ports, analog inputs AND outputs, WiFi, Bluetooth and BLE, touch switches, timers, and real-time clocks, and much more.

This inexpensive processor is available on a number of modules, some of which include displays, microSD card sockets or even cameras.

Today we will get started using the ESP32. And the first thing we will do is set up our Arduino IDE to add the ESP32 boards to it.

After we get our programming environment ready we'll write the obligatory “hello world” program, which for microcontrollers is the good old Blink sketch. You’ll see how uploading code to the ESP32 differs from the Arduino AVR boards we are used to using.

After that, we will go through some of the many example sketches that get installed with the ESP32 board manager, including examples for WiFi and Bluetooth.

It’s a long video (like always LOL) so here’s a breakdown if you want to skip directly to a specific section:

0:00 - Intro
1:56 - ESP32 Introduction
6:11 - ESP32 Boards
10:24 - Setting up the Arduino IDE
12:33 - ESP32 Hookup
14:10 - ESP32 Blink Sketch
19:04 - WiFi Introduction
21:05 - WiFi Scanner
24:23 - WiFi Access Point
26:51 - WiFi Simple Server
30:09 - Bluetooth Introduction
31:20 - Serial to Serial Bluetooth
34:37 - Simple Time
39:17 - Hall Sensor
40:48 - LED Software Fade
42:27 - Repeat Timer
43:40 - Touch Read

You can use just about any ESP32 board with these experiments, and the only other components you’ll need are an LED (with dropping resistor), a push-button switch and something metal to use as a touch sensor.

"Never trust a computer you can’t throw out a window." — Steve Wozniak


Quote
jfabernathy
(@jfabernathy)
Estimable Member
Joined: 2 years ago
Posts: 148
 

I've been going thru this video and doing the examples on an Adafruit ESP32 Huzzah which means I have to pick different I/O pins.  Really not an issue until I hit the Repeat timer.  I had the switch on GPIO 32 so I made that change, but that's it.  I get nothing from the serial monitor after reset except the usual ESP power on info. Anyone else have any issues with this?

 

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


ReplyQuote
MadMisha
(@madmisha)
Reputable Member
Joined: 2 years ago
Posts: 319
 

@jfabernathy

Posting your code here would really help. The usual applies here, make sure your serial monitor is on the correct com port and baud rate. Now that the obvious is said, I would print lines just as a check to see how far its gotten, or even to see if it made it past the setup.

 

ESPs are a little tricky sometimes. With so many manufactures, some don't behave how you would expect and you need to use alternate methods to accomplish your goal. Expect pins to be a little different and always do your best to find a good pinout. At least Adafruit does a good job of documentation. Although the documentation does seem to match what I saw, some ESPs do not necessarily use the same number printed on the PCB as the GPIO.

 

You might also try different pins.

 

Edit: I should note that I was half listening and typing at the same time. I did not copy and paste. I will have to see if I entered something by habit that needs to be there but I really doubt I caught something that Bill did not.


Centari liked
ReplyQuote
jfabernathy
(@jfabernathy)
Estimable Member
Joined: 2 years ago
Posts: 148
 

My code is attached which other than pin numbers and a printf statement is the same as Bill's example, which is the same as the Arduino ESP32 example.

I tried this on PlatformIO with a JTAG debugger and not getting very far other than to tell it's looping deep inside the FREERTOS part of ESP32 Arduino.

The only console out I have is at the end of setup and pressing the button does nothing.  I've not played with timers used this way on a ESP32.  However I do use a WDT on an ESP32 to protect me from weirdness.

 

ets Jul 29 2019 1246

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv0x00
mode:DIO, clock div:1
load4
load1044
load8896
load5816
entry 0x400806ac
end of setup

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


ReplyQuote
jfabernathy
(@jfabernathy)
Estimable Member
Joined: 2 years ago
Posts: 148
 

Okay, I figured it out.  Turns out on my ESP32, I needed a Pullup resistor on the pin side of the button.  It was staying '0' so nothing ever started. 

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


MadMisha liked
ReplyQuote
tedbear
(@tedbear)
Trusted Member
Joined: 3 years ago
Posts: 60
 

I've watched Bills excellent tutorial about getting started with the ESP32.  I thought I understood the two different Wi-Fi approaches, Station and Soft Access Point.  I gathered that Station requires Internet Access and the ESP32 board and my phone or computer use the Internet to communicate back/forth.  I tried the examples and they seem to work.

I also gathered that Soft Access Point means that the Internet is not needed or used.  The communication between my ESP32 board and say my phone is done directly.  The advantage being that internet access is not needed.  The disadvantage can be limited range.

I have been successful in using an ESP32 Dev board in Soft Access Point to communicate with my iPhone.  I have noticed that when the connection app is active, the ESP32 shows as a possible connection on my iPad.  However the app will not work with it as long as the phone is working with it.  I can see that this would be good especially in my situation.  Is this always the case that in Soft Point Access Mode that the ESP32 can only work with one other device at a given time?

Now I read about Access Points being "hotspots".  I thought "hotspots" referred to using another device for the WiFi Internet connection.  For example, I don't have a cellular plan for my iPad so in the house it can use my WiFi network there.  In an area without Internet Access the iPad can use my iPhone as a hotspot via its cellular connection.

Are Soft Access Point and Access Pont two different things?  Most things I read seem to assume that internet access is available and that one will be using it.  This is not always the case down on the farm. 


ReplyQuote
Ron
 Ron
(@zander)
Noble Member
Joined: 2 years ago
Posts: 2262
 

@tedbear A lot to unpack there Ted. A hotspot is USUALLY associated with an internet access very likely a cell phone. It's not a 3rd type, it is an access point. I don't know for sure about two clients on one access point but I would put money on only one unless the access point is specifically coded for more than one client. Access points do NOT need the internet, although the most common use is that. If @Inq is around, I am sure he can and will correct me if I got anything wrong. I am still learning and he is my goto networking guy.

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
frogandtoad
(@frogandtoad)
Noble Member
Joined: 3 years ago
Posts: 1213
 

@zander

Posted by: @zander

I don't know for sure about two clients on one access point but I would put money on only one unless the access point is specifically coded for more than one client. Access points do NOT need the internet, although the most common use is that.

In fact, a soft access point is UNABLE to access the internet or your home network for that matter... you'll need station mode for that, or both modes at once depending on your needs:

image

Cheers


ReplyQuote
Ron
 Ron
(@zander)
Noble Member
Joined: 2 years ago
Posts: 2262
 

@frogandtoad In your picture re ESP32 WiFi modes I don't see 'Soft AP'. I also don't see in that definition where the internet connects. This is why I get confused by all these terms. In fact upon reading it again, the definitions are circular. Stations connect to AP that connect to stations. Did terminology change at some point and I didn't notice? It gets super confusing when I see @Inq with his SEE PIC attached one line of code and both a SoftSSID and a RouterSSID. I am 100% sure I am missing a key point somewhere and would really like to get myself educated.

Screen Shot 2022 06 07 at 06.59.32

 

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
frogandtoad
(@frogandtoad)
Noble Member
Joined: 3 years ago
Posts: 1213
 

@zander

Posted by: @zander

@frogandtoad In your picture re ESP32 WiFi modes I don't see 'Soft AP'. I also don't see in that definition where the internet connects. This is why I get confused by all these terms. In fact upon reading it again, the definitions are circular. Stations connect to AP that connect to stations. Did terminology change at some point and I didn't notice? It gets super confusing when I see @Inq with his SEE PIC attached one line of code and both a SoftSSID and a RouterSSID. I am 100% sure I am missing a key point somewhere and would really like to get myself educated.

Screen Shot 2022 06 07 at 06.59.32

 

Hi Ron,

The operating modes are applied to the WiFi object, whereas "svr.begin(...) is related to the http web server component.

 


ReplyQuote
Ron
 Ron
(@zander)
Noble Member
Joined: 2 years ago
Posts: 2262
 

@frogandtoad I know and appreciate you are trying to help, but I am on the spectrum and learn some things easily and others not. This all sounds like static to me. Remember I was almost retired when the internet became widely available to the average person. I NEVER had any internet stuff in my professional life.

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
frogandtoad
(@frogandtoad)
Noble Member
Joined: 3 years ago
Posts: 1213
 

@zander

Posted by: @zander

@frogandtoad I know and appreciate you are trying to help, but I am on the spectrum and learn some things easily and others not. This all sounds like static to me. Remember I was almost retired when the internet became widely available to the average person. I NEVER had any internet stuff in my professional life.

I understand, it's not the most intuitive thing to comprehend.  Have a look at the following link, which provides some good detail around the use of the WiFi object modes etc:

randomnerdtutorials esp32-useful-wi-fi-functions-arduino

Cheers


Ron liked
ReplyQuote
Ron
 Ron
(@zander)
Noble Member
Joined: 2 years ago
Posts: 2262
 

@frogandtoad It's starting to sink in. I have never seen the method SoftAP used before. So is this like a network that is NOT connected to any other network by wires or wireless. The ESP32 functions as a router so to speak and my client phone app connects to the ESP32 ONLY. What are the practical uses of that?

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
frogandtoad
(@frogandtoad)
Noble Member
Joined: 3 years ago
Posts: 1213
 

@zander

Posted by: @zander

@frogandtoad It's starting to sink in. I have never seen the method SoftAP used before. So is this like a network that is NOT connected to any other network by wires or wireless. The ESP32 functions as a router so to speak and my client phone app connects to the ESP32 ONLY. What are the practical uses of that?

Glad to hear. A Soft-AP is a new self sustained network, not at all connected to your real network, that's why you can give it any SSID and PASSWORD you like.  There are certainly many uses for it... some recent irrigation discussions are a perfect example where no internet is required.  You can have many "WIFI_STA" reporting back to a "WIFI_STA_AP (station + access point in one)", which could in turn report all sensor readings back to an MQTT server / dashboard, web server page, log them, control them etc...

The stations don't need internet access, so this is a perfect scenario for such use.

Cheers.


ReplyQuote
Ron
 Ron
(@zander)
Noble Member
Joined: 2 years ago
Posts: 2262
 

@frogandtoad Ok, well I am certainly aware of networks that exist outside the internet, but somehow I never noticed the term soft-ap and never saw the softap method used. I am probably overthinking this or somehow confusing myself. Thanks for taking the trouble to point me in the right direction. I have used the RandomNerds both for education and to point newbies to, I think I need to go back and read some and pay attention a little more. Slowly but surely I learn especially with the help of understanding patient friends.

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
Page 1 / 2