A beginner’s guide to ESP32 | Hardware & coding basics + Wi-Fi server demo

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey guys welcome back today we'll take a look at the esp32 microcontroller and we'll see how we can program it using the arduino ide we'll see exactly what this microcontroller is capable of and we'll run some example sketches to demonstrate its capabilities i'm currently working on part 3 of the wi-fi rgb led controller series and i initially wanted to talk about these topics in that video but while i was editing i noticed that the video was getting way too long and i decided to split it so we'll talk about the basics of esp32 hardware and programming in this video and we'll talk about the more advanced code for the rgb led controller in an upcoming video so let's begin first up what is an esp32 esp32 is a series of microcontrollers created and developed by a shanghai-based company called expressive systems esp32s are famously known for being a low-cost microcontroller with an integrated wi-fi and bluetooth radio for wireless and internet of things applications over the last couple of years esp32s have gained a lot of popularity in the maker community this is mainly because they're one of the cheapest ways to implement wi-fi bluetooth and ble and diy electronics projects the esp32 first launched back in late 2016 and since then the number of esp32 users has steadily increased over the years support for esp32 firmware development keeps getting better as more hobbyists and hardware designers adopt expressive chips in their projects writing firmware for esp32s has never been easier thanks to arduino ide support which makes it easy for us makers and hobbyists to integrate robust web functionality into our projects so if you're looking to add wi-fi or bluetooth to your next project or if you need extra processing power then maybe consider purchasing an esp32 now let's see what this microcontroller is capable of by taking a look at what's under the hood the esp32 has 32 bit 10 silica extensive microprocessors clocked at 160 or 240 megahertz with 512 kilobytes of sram it has 802.11 bg and wi-fi and bluetooth 4.2 with bluetooth low energy support as well it's also got a lot of peripherals too there's a 12-bit analog to digital converter two 8-bit digital analog converters lots of pwm channels 10 capacitive touch sensing gpios and we can also find a lot of serial interfaces too four spi two i squared c two i squared s and three uart buses there's also some nifty built-in wi-fi security and encryption features too so compared to your standard run-of-the-mill atmega328p which if you didn't already know is the microcontroller used on the classic arduino uno the esp32 is an absolute unit alright so the esp32 is looking pretty good so far but how can we actually get one well just like with arduino expressive provides open source schematics and pcb layouts for esp32 modules so basically anyone can access their reference documentation and hardware design guidelines to manufacture their own board and that's why you see so many different esp32 based development boards out there here's a couple of popular ones there's the huzzah 32 feather from adafruit industries the esp32 thing from sparkfun electronics the lowland d32 from wemos and the node mcu 32s from ai thinker there's also a ton of dev boards out there with really cool extra components like oled screens cellular data modules built-in lithium-ion battery chargers lora radios and even cameras the one i'll be using is this generic looking dev board here and i have absolutely no idea who manufactured this board but it works just fine you can purchase pretty much any esp32 dev board out there and you'll probably get similar performance to any other board on the market so we got our hands on an esp32 board but how do you actually write code for it expressif also provides an official development framework for the esp32 called idf but there's a lot of other platforms out there with different programming languages some are based on lua others use javascript there's a couple that use python and a few use c or c-sharp i encourage you to take a look at all of these platforms especially if you're using an esp32 for commercial or industrial use but the easiest way to get up and running within esp32 for prototyping is the good old arduino ide expressive has also provided an open source arduino core on github which can be installed using the arduino ide's board manager to install it first visit xpressops arduino esp32 github repo i'll leave a link in the description scroll down until you find this installation instructions section and click on instructions for board manager to get the stable release copy the first url shown and open the arduino ide on your computer go to file preferences and paste the link in the additional board manager urls section if you've already added other links here just add the comma and paste the new url once that's done click ok now go to tools board manager boards manager in the search field type esp32 and esp32 by expressive will appear click the install button and the arduino ide will install the new package i've already got mine installed so there's no clickable install button here once that's done close the board manager now go back to tools board and let's take a look at the list of boards listed in the esp32 arduino menu now you'll notice there's quite a lot of boards here but if you don't see your specific board listed in this menu just click esp32 dev module and that should work fine once you've got your board selected let's test to see if we can upload a program go to file examples basics blink this will open up the classic arduino blink sketch hook up an led with a current limiting resistor to any gpio on your esp32 and ground in the ide change led built-in to the gpio number of your led and click upload compiling this sketch might take a while but once it's done as soon as connecting appears on the ide's console press the boot button on your esp32 and the sketch will start uploading once it's done press the reset button and the led should light up nice now let's test the esp32's wifi capabilities go to files examples scroll down to the esp32 dev board menu wi-fi simple wi-fi server with this sketch you'll be able to control an led over the internet the esp32 will connect to your home wi-fi network and run the local web server that can be accessed through a web browser on your computer or phone as long as it's connected to the same network as the esp32 let's try it out before we upload make sure to change your wi-fi network credentials here change ssid to the name of your wireless network and password to well your wifi password hook up an led with a current limiting resistor to gpio 5 and ground now upload the sketch once the upload is done open the serial monitor and reset the board as soon as the esp32 connects to your wifi it will print out its ip address on the serial monitor copy this ip address and paste it on your web browser and you'll be greeted with a simple web page try clicking the buttons and holy smokes so look the led is turning on and off awesome here's what's happening your web browser acts as an http client and every time you instruct your browser to visit a website with a url your browser will send out an http get request to the server that has that specific address the server which in our case is the esp32 will acknowledge the request and send a response in our case the response just contains html code for displaying this simple web page also don't worry about understanding what each line of code in this example does at least not for now the code that's running on the esp32 wi-fi rgb led controller seriously guys i i really need a better name for this thing is adapted from this example sketch and in part three of you know what we'll do a full walkthrough of the esp32 server code and hopefully you'll understand exactly what the microcontroller is doing as i've demonstrated in past videos it's totally possible to communicate with the esp32 over wi-fi with an android app on your phone instead of a web browser we didn't set up an elaborate response scheme from the server but if you want you could instruct the esp32 to send an xml file or a json file as a response too with that the server would be able to send structured data to a client which is definitely useful for a lot of applications if you have no idea what http is or how web requests and responses work take a look at part one of my esp32 rgb led controller video series i also strongly recommend you take a look at episodes one and two of all the internet of things it's a video series made by adafruit in digikey and hosted by none other than ladyaida herself throughout the series ladyaid explains lots of different concepts in the world of the internet of things it's a really good show to watch if you've just begun exploring what iot is and what iot is capable of well that's all i've got for this video in the next video we'll take a look at how to set up the esp32 as a web client and we'll see how we can request data to a rest api like open weather map we'll also go over the basics of json parsing too see you later guys and keep on coding thanks for watching don't forget to like if your suggestions in the comment section below subscribe for more content that's all i've got for now see y'all later
Info
Channel: Lucca's Lab
Views: 131,466
Rating: undefined out of 5
Keywords: esp32, arduino, projects, wi-fi, 101, esp32 basics
Id: UuxBfKA3U5M
Channel Id: undefined
Length: 9min 9sec (549 seconds)
Published: Sat Aug 01 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.