Introduction to ESP32 - Getting Started

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today in the workshop we're working with the ESP 32 we'll see how to set up our programming environment and then we'll explore the many features of this amazing microcontroller we've got ESP today so welcome to the workshop [Music] well hello and welcome to the workshop and today we are going to be working with the microcontroller that is not an Arduino which is very different from what we usually do here in the workshop we cover a lot of things here in this workshop using Arduino --hz we've also used raspberry PI's and the occasional other device like the Nvidia Jetson Nano but we have really stuck with the Arduino when it comes to microcontroller as well we're moving on here in the workshop now it doesn't mean we're not going to be covering arduino anymore but we are also going to be covering other devices and i asked a number of you on my forum as to which devices you would like to see me cover and i got some great answers but one of the consistent answers was the ESP 32 now the ESP 32 i'm sure you have heard about it it is a small microcontroller that is priced about the same as a good quality arduino uno clone but this thing has so many more features over the uno it runs ten times faster than the arduino uno it is a 32-bit device as opposed to an 8-bit device that the uno is it has a multitude of very versatile IO ports including ports like digital to analog ports and touch switches it is really a very versatile device so let's go and begin our journey with the ESP 32 by taking a look at it and then I'll show you how we can start working with this amazing little micro controller the ESP WR oom 32 is a dual-core 32-bit microcontrollers module that is part of the ESP 32 series each CPU core can be individually controlled it can support clock frequencies of up to 240 megahertz the ESP wor oom 32 has multiple power modes the device has integrated Wi-Fi Bluetooth and Bluetooth Low Energy the ESP WR oom 32 has multiple digital and analog i/o pins the ESP WR oom 32 is one of the ESP 32 series of microcontrollers this module is manufactured by expressive systems in Shanghai this device is a successor to the popular esp8266 it was released in September of 2016 the ESP wor oom 32 is used on many ESP 32 development boards this device has up to 18 12 bit analog to digital converters there are also two 8-bit digital to analog converters it has 10 capacitive touch sensor inputs for spi bus channels it has 2 I to see bus connections it also has 2 i2s bus connections if you're not familiar with i2s this is a bus that can carry audio the device also contains 3u arts for serial communications the ESP wor oom 32 can act as an SD card host controller as well as a host controller for other external devices like e MMC it can be an IR remote controller with up to eight individual channels it can supply pulse width modulation for driving motors as well as PWM for LEDs and there are up to sixteen independent channels it has an integrated Hall effect sensor an ultra-low power analog preamp and it has multiple real-time clocks with all this functionality most pins on the ESP WR oom 32 have multiple functions please note that some of these functions conflict so they can't all be used simultaneously one example is that some of the analog to digital converters cannot be used while the Wi-Fi feature is being used now not all development boards that use this module expose all of the pins and some of these pins are not recommended for use some of the digital i/o pins are input only and cannot provide outputs now here's an illustration of the pinout of a typical ESP 32 module that uses the ESP WR oom 32 as you can see many of these pins have multiple functions the module that I'll be using in our experiments today is the node MCU ESP 32s board which is a very popular module available on Amazon eBay and a number of other sources for these experiments you can also use other ESP 32 boards such as the ESP 30 to do it boards the sparkfun ESP 30 to thing or a series of ESP 32 boards from Adafruit whatever board you use make certain that you observe the pinups as they will be different than the board that I'm using so now let's get to work with the ESP 32 now here are just a few of the many varieties of ESP 32 boards and modules that you can experiment now this first one over here is the one that I'm going to be using for my experiments today this is the node MCU 32s version of the ESP 32 and it's a pretty popular board so if you can get your hands on one of these I would suggest that I picked this one up over at Amazon now it's got on it a micro USB connector so that you can connect it up to your computer and use either the Arduino IDE or another IDE to program it to push buttons which I will explain the usage of later and of course the ESP 32 modules over here the pin outs for it are marked on the corners over here now one thing about pin outs is that these boards are all ESP 32 boards but they don't necessarily have the same pin ups so it's very important when you're using the ESP 32 to make certain that you obey the correct pin outs for your module now this module over here is really nice it's a similar module to this although Totti has two less pins it has as you can see the micro USB connector and the two push buttons it also has an OLED display over here and this is integrated onto the module so for IOT apps this is probably a cool thing to have on the bottom over here you can see a small connector and this is a connector for a lipo battery for a three point seven volt battery so you can make battery-powered projects with this one another thing I liked about this is that it didn't have the pins soldered on to it but it did come with not only the pins but this little sticker that you can put on the side of the pins to give you the pin outs and that's really a handy thing have now over here we have the ESP 32 cam now this thing is so cool that I'm going to be making several videos just on this unit alone this is a very inexpensive unit it's about nine or ten US dollars for this and as you can see it's got an integrated camera underneath the camera over here this isn't the ESP 32 module which you'll seen soon is underneath this is a micro SD card slot so you can store data from the camera on a micro SD card and on the bottom the ESP 32 itself note that over here it's got a connection for a small antenna also note that it has far fewer GPIO pins because several of these are already being used by the camera and the micro SD card another thing to notice about this board is it does not have a micro USB connector or any kind of a communications connector you need to use an FTDI adapter in order to program this and then finally this one over here is a sparkfun ESP 32 thing as with all sparkfun products it's a very high quality product it's got a micro USB connector and a Jack over here that can be used for a three point seven volt lipo battery it uses a different ESP 32 module the SP 32 on this one is this it's not in the big metal case but like most Sparkfun products it's excellently documented and there are some great tutorials available for this board as well and so there you go just a few of the many ESP 32 boards that you could be using in your projects now to begin working with the ESP 32 we are going to be using the Arduino IDE now the Arduino IDE is not the only way to program any SP 32 in fact it's probably not even the best way to do it but it is a comfortable environment for most of us because we are familiar with the Arduino IDE and this makes it a good way to get started with this new microcontroller now in order to use an e SP 32 with the Arduino IDE we are going to need to add the e SP 32 board to the IDE you the board's manager so let me show you how to do that and then we'll go ahead and we'll run a test sketch everyone's favorite sketch just to make certain that the ESP thirty-two is indeed communicating with our Arduino IDE now in order to use the ESP thirty-two with the Arduino IDE we'll need to install the arduino ide boards manager for the ESP 32 so we'll begin by going to the github page that expressive has for the arduino ESP 32 and you'll find a link to that page in the article it accompanies this video now what we are looking for is a link to a JSON file if you're not familiar with Kasaan it's a format of text file that is understood by all computers and in this case contains all the parameters for the board's manager this first one over here is what we want the stable release link so copy this link over here now go into your arduino ide and in the arduino ide go into file and then go into preferences now i've already done this but what you need to do is you need to paste that into this field additional board managers URL now you'll probably find this field empty in your arduino so you can just simply paste it in and click ok but if you find there is an entry there already place a comma after that entry and paste the link to the new json file after that and then click OK once you've done that you've installed the link to the boards manager but you still need to install the boards so go into tools and then go into board and go to boards manager when you're in the boards manager type in ESP 32 and you will find ESP 32 by expressive now I've already installed mine but if you haven't done it yet you'll have an install button over here and when you click that it will install after that you may close this now to verify that everything works go back into your boards again and go and take a look at the list of boards and you should start seeing like I do down over here a number of ESP 32 boards there are quite a few of them over here and we can now use these with our Arduino IDE now for our experiments today you're going to need an ESP 32 module now you don't need to use the same ESP 32 module that I'm using because we'll be doing our connections based upon GPIO pin numbers and not actual module pin numbers so just observe the same GPIO connections and you will be fine you'll also need an LED and the dropping resistor for that led I use 220 ohms but any value from 150 to 470 ohms will work fine you'll need a momentary contact push-button switch and you will also need a touch switch now I'm just using a piece of wire for my touch switch but you can use a piece of printed circuit board or another metallic device that you can attack to wire to we'll begin by connecting the GPIO pin number two to one side of the dropping resistor the other side of the resistor will be connected to the anode of the led well then connect the ground from the ESP 32 to the cathode of that LED will connect GPIO pin number 0 to one side of the momentary contact push-button switch will connect the ground to the other side of the switch and finally we will connect our touch switch the GPIO pin number 4 and this completes the wiring for today's experiments now here is an ESP 32 version of the common blink sketch and I'm sure we all know how the blink sketch works it's pretty well digital right to an LED pin to go high you delay it and then digital right to go low now what I've added here is also a serial print so we can go up to the serial monitor saying hello and the LED goes higher on and world when it goes off and there's a half second delay in between so there's not that much there to it now a couple of things different the led pin is pin number two because we've attached at the GPIO pin number two and you'll notice I set the serial monitor up to a relatively high baud rate you'll find for most ESP 32 sketches you want to keep it at a high baud rate because this device works much faster than the Arduino does now a couple of things about uploading a sketch for the ESP 32 it's not quite the same as an Arduino now you'll notice on my ESP 32 which I have over here there are two push buttons and they're on either side of the micro USB connector on my device this push button over here is labeled IO 0 and this other one is labeled e n but in actual fact the e n button serves very accurately as a reset button and the isle 0 button comes into play when you are uploading programs and so what I'm going to do is I'm going to go through and upload this to my ESP 32 now I'll hit the upload button as before and it compiles a sketch and the sketch is right now compiling you're going to find with the arduino ide the ESP 32 sketches take longer to compile now it says connecting and what you need to do is you need to hold this button down and watch the screen now there it goes it actually connected it won't connect until you do that now on some models of the SP 32 you actually need to hold the button down throughout the whole compiling process but on this one you don't and now as you'll notice now our blink sketch is indeed running and we are flashing the light on and off and so we have completed the hello world aspect now we can bring up our serial monitor as well just to see the print that we have here and it's a bunch of gobbledygook which is quite common because it's out of sync what we'll need to do is hit this other switch to reset it and there you'll see the hello world world in sequence with the blinking LED and since I've picked pin 2 you'll notice there's a built-in LED as well this little blue one on my ESP 32 now one other thing I want to note is that if you try to do this compile and get an error message at the end of compiling you're probably going to get a message about something called serial dot py which is a Python program and that would mean that this has not been installed on to your computer now this seems to be touch-and-go I have another bun - machine that's virtually a dental this one in the other room and it compiled just fine without any problem but this machine I'm using here did not and if you run into that there is a sequence of instructions you can execute at the command line to install all of the Python programs that are required for the board manager for the ESP 32 and you will find a link in the article accompanying this video to those instructions for both Linux and Windows and for the Mac so if you run into that problem there is indeed a way to solve it but otherwise here we have our hello world example our blink example running on the ESP 32 and now we can move on to bigger and better things incidentally this is one of the few sketches that you'll see today that I actually wrote myself and I use the term rope loosely because of sistah blink sketch the other ones are going to be using are all examples that have been included with the ESP 32 now one of the key features of the ESP 32 that makes it ideal for IOT applications is its built-in Wi-Fi capability and what we're going to cover next is how we can use the Wi-Fi capability of the ESP 32 now in order to execute the next couple of experiments you're going to need to know something about your own Wi-Fi network specifically as SSID which is the name of the Wi-Fi network and your passcode so armed with that information let's go and see how we can get our ESP 32 communicating on Wi-Fi let's take a quick look at the Wi-Fi capabilities of the ESP 32 the ESP 32 supports Wi-Fi protocols 802 11 B G and n it operates at 2.4 gigahertz and supports data rates of up to a hundred and 50 megabits per second it has adjustable transmit power up to 20 point 5 DBM the ESP 32 supports antenna diversity the GPIO can be used to control an external RF switch allowing the selection of the best antenna for the situation in the arduino ide we use the Wi-Fi library to expose the Wi-Fi capabilities of the ESP 32 this library supports the ESP 32 as both a station or as a soft access point now in station rst a mode the ESP 32 is another client of your router similar to your computer tablet or phone in soft access point mode the ESP 32 is the center of the network providing connections for external devices like a tablet phone computer or an ESP 32 in sta mode by the way this is called a soft access point because the ESP 32 itself has no direct connection to the Internet in STA mode the ESP 32 gets its IP address from the routers DHCP or dynamic host control protocol in s AP mode the ESP 32 assigns the IP addresses the clients when used in soft access point mode you can have a maximum of five external clients both modes allow the ESP 32 to act as a web server which is a very common configuration so let's start working with the ESP 32 and Wi-Fi now to start using Wi-Fi with the ESP 32 we're going to use the Wi-Fi scan example and you can find that quite easily just go into examples and go down to the section for your node 32s and go and look for Wi-Fi which is down near the bottom and you will find Wi-Fi scan among all of these different programs here it is over here now I've got it open up right now and as the name would apply this just scans to see what Wi-Fi networks are available to the ESP 32 now we start off the program by using the Wi-Fi library which is pretty well used for all Wi-Fi programs with the ASP 32 and then in the set up we set it up as a Wi-Fi station remember the ESP 32 can either be a station or an access point we want to be a station we also disconnect from the Wi-Fi just in case we happen to be connected to something now because we don't want to be connected to a network when we're scanning for all the networks now the scanning itself is quite simple we do a Wi-Fi scan networks and that returns a number which are the number of networks and then we simply go and iterate through all of those networks and print them all out print out the parameters of them the SSID RSSI is the signal strength and the encryption type as to whether it is open or encrypted and we put that up on the serial monitor we wait 5 seconds and then do the whole scan again so it's a very simple program now I've already uploaded it to my ESP 32 so let me open up my serial monitor and I will reset my ESP 32 because you need to get gobbly when you get that now you will notice that I'm finding 4 different networks in this first scan now I've found 5 the two networks of interest to me are WJ net 24 which is the one I have downstairs here in the basement along side the workshop and WJ net 24 X which is upon my second floor it's another Wi-Fi access point to have in the house because I don't get a very good signal in the upper floors the rest of these networks these video Tron and virgin ones are just networks that my neighbors have and as you can see from the signal strength they're at a much lower signal strength and so this is a very simple program and you should have no problem getting it to work however one thing you need to know about the ESP 32 and Wi-Fi is that it initially can take quite a bit of current to get started you may get an indication of a brownout and if you do try replacing the cable that you're using the micro USB cable with a shorter one or with one that has heavier gauge wire you can also power your ESP 32 from an external five volt or 3.3 volt power supply if you're having problems getting it to work with your cable but otherwise this proves that the ESP 32 Wi-Fi is functioning in my environment now this Wi-Fi example configures the ESP 32 as an access point in other words it is providing a Wi-Fi signal for external devices such as tablets phones computers or even another ESP thirty-two and in this particular example what we're going to do is have a very very simple web page that will find that the address 192.168.1.1 and on that page we'll have two links one to turn on the LED and one to turn off the LED and as you recall we have an LED already connected the GPIO pin number 2 which is also the built-in LED now a couple of parameters here you might want to modify when doing this first of all the SSID of our new network is going to be your AP and you can change that to anything that you like the same deal with the password right now your password with a capital P is the password and you can change that as well now if you want to eliminate the need for a password on this line over here where we set up the soft access point simply provide just the SSID and eliminate the password same deal for the IP address by default it'll be 192.168.0.1 but you can change it by inserting another IP address in over here in the loop we set up a fairly simple web page and the web page just has a couple of links to turn on and off our LED and of course you could style this and make it into a fancier looking webpage but for the purposes of our demonstration it will work now if I go over to my tablet and go into Wi-Fi you will notice I'm already connected to your AP and I've provided that the password etc and so let's go into our web browser and let me just refresh that and you'll see we have two links over here click here to turn on the LED and click here to turn it off and so I've clicked and I've turned on the LED and I click to turn it off and it's very simple but this is an excellent example of how you can remotely control devices using the ESP 32 as a Wi-Fi access point now the final Wi-Fi sketch that we're going to be looking at today is the simple Wi-Fi server sketch and this sketch does pretty well the exact same thing as the previous sketch does it creates a web page and allows you to turn on and off an LED now the difference with this one is that in this case the Wi-Fi is connected in station mode or sta mode so it does not provide an access point instead it uses your router so in order to configure your sketch you're going to need to know your router name and the password for it the other thing about this sketch is it was set up the work on pin number 5 and so you'll need to modify a couple of things to make it work on pin 2 or simply just move the wire over to GPIO number 5 now over here you're going to need to put the SSID that's the name of your Wi-Fi network and over here you'll need to put your password now the thing about modifying this to use pin number two instead of pin number five is they did something a little bit odd in this sketch instead of using a constant or variable to represent the pin they've actually hard-coded it so you need to change it in three places so here in the pin mode statement you'll need to change that to a two and also down near the bottom over here there are two places you'll need to do it here both on these Digital Rights which turns the LED on or off otherwise the actual loop is very similar to the previous sketch this builds a very simple web page that looks identical to the one in the other sketch and connecting to the Wi-Fi in station mode is also very easy it's just this statement over here Wi-Fi begin and you pass it the SSID at the password that you need for your network now I've already configured this but what you need to do with this sketch is when you start it off at first is you need to go into your serial monitor and in your serial monitor you will see the IP address that has been assigned to it this is going to pick up an IP address from your networks DHCP server so it'll be different on your net than it is on mine you'll need to make note of that and then you can go over to a web browser somewhere on your network even on the same machine you're working on and go to that particular address and at that address you'll get basically the same webpage we had before to turn the LED on or turn it off and so when you click over here you will turn the LED on and clicking over here will turn it off and so it functions identically to the previous sketch but in this particular case the Wi-Fi is a client on your network now one of the advantages that the ESP 32 has over its predecessor the esp8266 is that the ESP 32 is capable of bluetooth including ble or Bluetooth Low Energy so let's go and take a look to see what it is we need to do to work with bluetooth on the ESP 32 let's take a quick look at the Bluetooth features of the ESP 32 the ESP 32 has both classic Bluetooth and BL II or Bluetooth Low Energy the ESP 32 can act as a Bluetooth client or as a server you'd use classic Bluetooth for continuous data streaming ble can be used for short bursts of data there are Arduino libraries for Bluetooth and ble that are installed by default when you install the ESP 32 board manager some uses for classic Bluetooth are wireless headsets file transfers between devices wireless keyboards and mice and wireless audio devices such as speakers you would use bluetooth low energy or ble for devices like medical monitors fitness bands Internet of Things sensors and also devices like eye beacon which do targeted promotions so now let's work with Bluetooth on the ESP 32 now to demonstrate the use of the classic Bluetooth we are going to look at the serial to serial bt sketch and this is a sketch that basically ties the serial monitor on your Arduino IDE to the Bluetooth serial so basically anything that is received via bluetooth is going to be displayed on the serial monitor and anything that you type in and enter on the serial monitor will be transmitted via the serial Bluetooth now it's a fairly simple sketch most of the work is done by the Bluetooth serial library and we create an object called serial BTW which represents the Bluetooth and as you can see from the sketch it's basically this time the serial monitor - the serial bluetooth now there is one parameter that you may wish to modify serial BT dot begin where you start the Bluetooth has the name of the Bluetooth device and you can change this to any name that you want and this is the name that you'll identify the device when you're connecting via bluetooth so I'm going to start the program right now and I'm going to open up my serial monitor and I'm going to reset my device and it says the device is started and I can now pair it with my Bluetooth now in order to use this I've installed the serial terminal on to my Android device and I have a link in the article that accompanies this video so you can install the same serial terminal there's also a link in there to a similar device for iOS so if you happen to have an iPhone or an iPad you can also use it as well and I'm going to open this up right now and in the terminal I'm going to go and look for devices and here is ESP 30 to test I'm going to connect to it and I have connected to it so now I'm going to type something and a very misspelled hello which we can now see up on my serial monitor and if I type something in the serial monitor you will see that that has appeared on my terminal so I can communicate back and forth between the two of them so it's a very simple example but it's an effective method of seeing how serial Bluetooth works with the ESP 32 now of course the Wi-Fi and the Bluetooth capabilities of the ESP 32 are the things that most people talk about but as you saw at the beginning of the video the ESP 32 has a myriad of other features it has all sorts of i/o ports both digital and analog it has touch switch inputs it even has a Hall effect sensor built into it so what I wanted to do right now is this go through some more of the example sketches using some of these additional features of the ESP 32 now remember you can take these example sketches and use them as part of your own code when you're designing for the ESP 32 and so let's go and take a look at a variety of different ESP 32 features now the first of the extra examples we're going to be working with today is one called simple time and I'll show you where I find this as well as all of the other examples I'm going to be using so we go into file into examples and scroll down to our ESP 32 section and you will find another menu called ESP 32 which brings up this submenu and you'll notice a number of things analog out camera tip ID etcetera etc this is where all the extra examples are and the first one I'm using is called simple time and it is under the time section so let's take a look at that now simple time is a sketch that is very powerful you will recall that the ESP 32 has a built in real time clock and this sets the real time clock by going out to the Internet querying a network time protocol server getting the exact time in GMT converting it to your local time and then displaying it so that's quite powerful and as you can see there's not a great deal of code required to accomplish that now you're going to need to modify a few constants to get this to work the first one SSID so this is the SSID or the name of your Wi-Fi network so you'll recall that I had a number of networks and the 1wj at 24 was the one I had downstairs so that's what I would enter over here make sure to observe the correct case the same deal for your network password and you will enter the passcode or password that you use to get onto your Wi-Fi network and that of course is unique to your own network the next constant you will want to modify that you probably will need to modify anyway is this one that says gmt offset now this is how many minutes are actually how many seconds you are offset from GMT time now in my case I need to modify this I'm in Eastern Time and if you're in Eastern Time the value is negative 18,000 this value can be positive or negative depending on whether your time is plus or minus PMT and I will give you a link in the article in the drone bot workshop website that accompanies this video that you can use to calculate the offset for your area so in my case I change this to negative 18,000 because I'm in Eastern Time now the daylight offset is for areas like the one that I live in that observe daylight savings time and this generally will be set at 3600 there are 3600 seconds in an hour and on daylight savings time our time is offset by an hour if you do not observe daylight savings times if it's residents of Arizona or Hawaii or Saskatchewan you would set this down to zero and so after you modify all of that we'll take a quick look at this sketch over here now the sketch really the heart of it is a function that is built-in called config time and you pass the parameters that we just passed to it including the NTP server the daylight offset and the DMT offset and it basically configures the clock print local time is a function they've defined over here which gets the local time and then prints it using a format that is defined over here the Wi-Fi connection is just over here where we connect to the Wi-Fi and basically that is really it we disconnect from the Wi-Fi afterward and then in the loop we go and every second we go and call the print local time function so this should caused time to come up once a second on our serial monitor so I've already loaded this onto my ESP 32 and the version I loaded had my adjustments for my SSD my password and my offset of negative 18000 so let's go and take a look at my serial monitor right now and see what we've got now as usual we've got a bunch of gobbledygook I'll hit the reset key and there we are and is printing the time and if you look up in the corner of my computer you'll notice that the time does indeed match the time on my computer so it has gone to the network got a network time protocol erver and is now just repeating this every once per second and so there you go a very simple way of setting the clock on the ESP 32 one of the many features of the ESP 32 is it has an integrated Hall effect sensor this is a sensor that can detect the presence of a magnetic field now if you're not familiar with Hall effect sensors I did do a video an article specifically on these devices and you can check it out to learn more about them now as you can see from the hall sensor sketch this is very very simple sketch it literally has only one statement in here which is Hall read and that reads the value of the Hall effect sensor which we then print out to the serial monitor now the value of the sensor is going to be relatively high when there is no magnetic field and it'll go very low in fact below zero when a magnetic field is picked up so let's go and open the serial monitor and let's reset our device and as you can see we're getting a series of numbers now I'm going to come in with a magnet and as you can see those numbers get very very low they actually go below zero at this point and removing the magnet brings them back up and you can use this in your sketch to determine the presence of a magnetic field near your ESP 32 now this is an example called LED software fade and as its name implies it fades the brightness of an LED now with the arduino ide in the ESP 32 you cannot use the analog write function the analog write function for the arduino drives pulse width modulation and that can be used to change the brightness of an LED or indeed the speed of a motor instead there is a separate function for driving an LED with pulse width modulation and it's called the LED see write function and that's what this sketch uses now what it does is it sets up a timer and a base frequency for the pulse width modulation and then it created an LED C analog write function which is essentially the equivalent of the analog write function in the Arduino and this is used in the loop to vary the brightness of the LED it goes dims and fades and dims a disc goes through a loop and goes through a number of different values and so I've already loaded that up to my sketch and so let's take a look at it right now and as you can see the LED is fading now I'm going to dim the lights over here so it's a little easier to see the LEDs so there it goes down and up and as you can see it's on a fading pulse thing and so if you're trying to control the brightness of an LED you can use this sketch as an example for your circuit the repeat timer example is an example of using the built-in hardware timer on the ESP 32 it's a timer that increments every second and it can be stopped by using the push button that we wired to GPIO pin number zero now this example scheduie gain is a very good sketch to use within one of your own sketches if you need to do a timing function so I've got the timer running right now and we'll open up our serial monitor and I'm just going to reset our ESP 32 and here you can see timer 2 3 4 5 it's giving the time and will continue to increment until I hit the button and then after that that will stop the timer and I can reset it again to demo that again and we're starting again if I hit the push button it stops the timer so again this would be an excellent sketch to incorporate into one of your own designs if you do indeed need a timer function that you control externally now ten of the GPIO pins on the ESP 32 are also designated as touch switch inputs and your designated as touch zero touch one all the way up to touch nine and they're very simple to use now as you recall from our schematic we simply attach the wire to a plate or some sort of device we can use as a touch pin and on my circuit board it might be a little hard to see but I've got just a piece of wire looped up over here and this effectively is my touch slick and it's connected to GPIO pin number four which is also touch pin number zero now as you can see from this sketch it's very easy to use the touch switch you simply do a touch read and tell it what pin you're going to and it will bring you back a value and analog value and you can use that value to determine whether the switch has been touched or not now you'll notice the value will go down whenever the slipped is touched so I've loaded this already to my ESP 32 I'm going to open my serial monitor and we'll reset it and we're getting values of around 57 over here now let me go and touch the switch and you'll notice now it drops 21 18 17 if I remove my finger it's back up to the 57 and so we can use these values to determine whether one of the touch switches has been touched and create a very simple interface or keyboard for our project with the ESP 32 now as I mentioned just a few moments ago there are so many aspects to the ESP 32 that I couldn't possibly cover them all in one video so I guess I'm going to need to make several more ESP 32 videos and I am looking forward to doing that it's a device that we're going to use in many projects including IOT projects of course and they also want to make use of that really cool ESP 32 Campbell and so to find out about these videos the best way is to be subscribed to the channel and if you haven't done that already you could do that right now by hitting the subscribe button below this video or clicking on the robot that you see in the bottom corner of the video and he'll do the subscribing for you now when you do subscribe please hit the bell notification and that way you will be aware every time I release a new video on the ESP 32 or in a multitude of other subjects that I'm sure you'll enjoy now if you want to know more about the ESP 32 you'll find an article that accompanies this video on the drone bot workshop comm website and there's a link below the video to that article where you can grab the code that I used and also learn a bit more about this amazing processor now as they said at the beginning of the video this was its topic that was suggested to me by the folks on the drone bot workshop forum and that's the place to go if you want to suggest new topics or participate in polls that I occasionally give in order to find out what topics interest you the most so that I can make videos and articles that you will enjoy and so please if you haven't signed up to the forum go ahead and do so and join the crowd over there and finally there's one more thing to sign up for and that's the newsletter it's my way of keeping in touch with you and letting you know what's happening here in the workshop and so once you've done all that signing up there are plenty more videos in the channel you can go and watch them right now and until we meet the next time please take care of yourselves and I do hope to see you again soon here in the drone bot workshop good bye for now [Music] you
Info
Channel: DroneBot Workshop
Views: 663,075
Rating: 4.9501653 out of 5
Keywords: esp32 tutorial, ESP32, esp32 introduction, esp32 arduino
Id: xPlN_Tk3VLQ
Channel Id: undefined
Length: 47min 56sec (2876 seconds)
Published: Thu Apr 02 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.