01 Getting Started with ESP32 | IoT Development | Arduino IDE setup | ESP32 pinout | GPIO Led Blink
Well, look at the esp32 specifications and some of the common development boards that are currently available in the market. Youll learn how to configure your Arduino IDE so that it allows you to communicate and upload programs to your esp32. Take note that we are no longer using the Arduino Uno board for this course, and we are only going to be using the Arduino IDE and its programming language, since this is very familiar to us from our previous course embedded systems with Arduino Uno. If you havent watched it yet, please check the link in the description below, of course, well investigate the esp32 pin out and its basic functionalities. And ultimately, you should be able to test and conduct a very simple experiment on your own esp32 development board. To perform basic input and output operations hi, my name is Joe Edgar and welcome to iot development training course with esp32, so lets get started. The esp32 is created and developed by expressive systems, a shanghai based Chinese company and one of the world leaders in microcontroller development. If you look at their website, there are various esp32 modules that you can see, based on the esp32w room, esp32 Rover mini Pico du and solo series. Unlike the atmega 308p found in your Arduino Uno board, the esp32 is more powerful. The esp32 chip is available in both dual core and single core variations, and for this course we will be using the ESP W room 32 module.
It runs on a 10 silica extensor lx6 32 bit microprocessor with an operating frequency of up to 240 megahertz. It has 512 kilobytes of ram, it has integrated 2.4 gigahertz, Wi, Fi, Bluetooth and Bluetooth low energy, which makes this microchip great for iot project. This is unlike most of the commonly used Arduino boards, which require the use of an add on Shield just to have Bluetooth and Wi Fi capabilities. The ESP W room 32 is packed with multiple functionalities. It supports up to 18 12 bit analog the digital converters or ADC, and two 8 bit digital to analog converters or DAC. It has 10 capacitive touch sensor inputs. It has a built in hall effect sensor. It can also be an IR remote controller with up to eight individual channels. It can supply pulse width, modulation or pwm for driving Motors, as well as pwm for LEDs up to 16 independent channels. Moreover, it has 4 serial peripheral interface or SPI bus channels. Two inter integrated circuits or i2c bus connections, two inter integrated circuit, sound or i2s bus connections. This is a bus that can carry digital audio. It has an ultra low power, analog preamp. It has three uarts for serial communication. It can also act as an SD card host controller and it has multiple real time, clocks or rtcs. Although the esp32 module comes in a 48 pin package, not all pins are exposed in all esp32 development boards that are available on the market, as some of the pins cannot be used directly or are not recommended for use.
Here are some of the examples of the many varieties of the commonly used esp32 boards, the do it dev kit V1, the esp32s node MCU. The ESP is 32 thing from SparkFun the esp32 feather board from Adafruit the wemos lowland 32 and a lot more for this course. Most of my demonstrations will be done using the 38 pin esp32s node MCU development board, which is very popular, but you can definitely use any of the esp32 boards out there. You just have to be careful with your boards pin out as it varies depending on what youre using here is an example of a typical pin out for the 38 pin esp32s node MCU development port. As you can see, most spin outs on the ESP W room. 32 has multiple functions and some of the functions conflict with each other and cannot be used simultaneously. So now lets start experimenting with your esp32s node MCU development board using the Arduino IDE lets start with the basics, for this experiment well test some of the gpio pins of your esp32, so youll need an esp32 development board, an LED. A current limiting resistor mine is 220 ohms, but you can use any value, ideally from 150 to 470. Ohms youll also need a tactile switch. Of course, your breadboard a couple of connecting wires and a micro USB data cable, make sure that you use a good quality data cable and not just any charging cable, because it wont work so well Begin by placing your esp32 development board onto your breadboard.
Make sure that each pin is properly aligned before pushing it firmly to the board. In some cases you might need to bend some of the pins to get them in place, just be careful not to damage the pins of your esp32 board. First Ill connect the ground of this node MCU board to the negative bus strip of the spreadboard and then Ill connect. The gpiop number 2 of the esp3221 side of the current limiting resistor. The other side of the resistor is connected to the anode of the LED, while the cathode of the LED is connected to the ground of the esp32 and then Ill connect. The gpio0 of the esp32 to one side of your push, button switch and the other side is connected to the ground notice that I didnt Implement any pull up or pull down resistors to our circuit connection. Well, do this programmatically later, let me reposition this output LED so that you can have a better view of its connection, just make sure to connect the upper negative bus strip to the lower negative bus trip of your breadboard, or you can also use the ground of The other side of your board, now all we must do – is to plug in this node MCU board, via this micro, USB connector in your computer, open the device manager, and once you hear the connected sound, you should be able to see a newly detected device under Ports, mine is detected as silicon Labs cp210x USB to uart bridge com7.
Youll also notice that the power LED on your node MCU board is now turned on now to use the Arduino IDE for esp32 boards. First, we need to add the esp32 board to the Arduino IDE by default. The Arduino IDE only sees Arduino boards. So, to do this, we need to install the esp32 package for Arduino from GitHub, so lets Google, it esp32 Arduino, GitHub and click on this esp32 Arduino boards manager link now copy this stable release link which basically is a link to a Json file and then go Back to your Arduino IDE click on file preferences and in the additional boards manager URL paste here. The link that you copied from GitHub note that if there are existing entries to this URL text box, you can simply put a comma to it before pasting. The additional URL and then click ok, now go to tools, board manager and from here you can see all the installed boards that your Arduino IDE currently has search for esp32 and when you see one from the expressive systems, just click install and depending on your internet Connection, it could take some time Ill fast forward. This and after the installation is finished, just click close now, click again on the tools board, so you can verify that the esp32 Arduino boards already exist so in here youll see a lot of supported boards. Now, if youre, using a similar board to what Im, using, which is a generic esp32s, nodemcu, simply choose this esp32 Dev module and youre good to go also make sure that you have selected the correct com port number, especially if you have multiple devices attached to your Computer mine is com7 also note that there are plenty of examples per programming esp32 that are now installed in your Arduino IDE, so you can explore it as you wish and perform your own experiment, but for our first experiment lets just try.
Writing a simple blinking program to the Circuit connection that we have so Ill declare a lead, variable and assign a value of 2.. This is our gpio pin number two in the setup function Ill set. The mode of this gpio p number two as output lets, also use our serial Monitor and set its bond rate to 115 200. now inside the loop function, Ill call, the digital write function to send a logic. High signal to gpio pin number two lets also have the message: welcome to iot development and then delay for one second and Ill duplicate this code and change this to a low signal to have a blinking lead effect and then Ill change this to print Ln. So it goes to the next line and the message is esp32. Well, this is not new to you, and this is exactly similar on how we write programs to our Arduino boards now lets click the upload button and it is asking us to save our sketch. Okay, lets give it a name: esp32, program01, LED blink and hit save, and the compilation should begin right away, although you will notice that the compilation time for your esp32 board is slightly slower than compiling your Arduino Uno board. Now there is one major difference for this upload to succeed when the compilation is done and uploading begins, you should see this message connecting and for this node MCU board. You must press this boot Button that appears on the right side of your board.
Just hold it for a couple of seconds: until you see the writing at the flash memory with the corresponding percentages, then you can let go if you dont do this correctly. An upload error message will appear so after its done uploading, you should be able to verify your running program to your esp32 board and congratulations. You have successfully uploaded your first program in esp32 via the Arduino IDE. You will also notice a blinking blue, LED next to the red Power lead. This built in LED is connected to the gpio pin of your esp32 kinda, similar to the built in LED in your Arduino Uno, connected to gpio 13.. Also, on the other side of your board is another button which serves as a reset button, pressing it resets the program execution. Okay, now lets modify our program to include this push button so Ill declare another variable and assign a value of 0, because this button is connected to the gpio number 0 of the esp32 in the setup function. Lets set the pin mode of this button to input pull up. This is to activate the boards internal pull up resistor, since we didnt specify any in our circuit connection inside the loop function, Ill create a condition that if the button is pushed meaning, it is connected to the ground Ill cut this one first and create a separate Function called lead, link and paste our blinking codes here and then Ill call it when this condition is satisfied, meaning when we push the switch the lid links.
Otherwise, we turn the lid off. Okay now lets click this upload button and same as before. When you see this connecting message, just press this boot Button and hold it until you see this right into the flash memory, then you can let go so since our button is not being pushed right now, it is still pulled High by the boards internal resistor. Making this, if condition, to be evaluated as false, thus turning the lead off, and once I press this button, it satisfies the condition and the let blink function is called now theres. One more thing lets check the serial monitor to verify If the message is being printed. Click On Tools serial monitor just make sure that the baud rate in your serial monitor is set to the same value that you have specified when you set up your board so Ill choose. One hundred fifteen thousand two hundred now lets try pressing this button. One more time and, as you can see clearly, the message appears in sync, with the turning on and off of the LED okay same as before, Im going to give you your programming challenge activity. This is for you to practice your previous programming skills in writing. Codes for Arduino, but now you will be practicing for esp32, so I want you to modify this demo circuit that we had and choose different gpio pins for your push button switch and your LED also, instead of just one LED, you will be working with two LEDs.
This is how your program should behave clicking this button for the first time causes the two LEDs to Blink, with the corresponding message displayed in your serial monitor in sync to the blinking on and off now clicking the push button for the second time changes the LED Sequence to alternating light, also pay attention to the message displayed in the serial monitor alternating on off off on and when the button is clicked for the third time everything stops, the LEDs are off and there is no additional message displayed on the serial monitor now, when The push button is clicked again. It repeats the entire process as if it is clicked for the first time. If I click again, the mode is now alternating and clicking it one more time everything stops so thats it for your challenge and as a hint try to recall how to use the milis function in our previous course in Arduino Uno youll need it here, especially in Our succeeding lessons up next youll learn how to work with the esp32s analog input and output signals well, experiment on Photo existors, potentiometer and pulse with modulation signals for controlling Servo Motors and LEDs. Again.