ESP01. Get started with the Arduino or PlatformIO IDE. Which module to choose? Pinout
The ESP01 is an ESP8266 module installed on a miniature development board that has four expansion slots (GPIO). The difference between the versions lies in the quantity of flash memory on board by the board, 512Ko (ESP01) or 1Mo (ESP01S).
Initially developed to add WiFi connectivity to the Arduino, it has become a stand-alone module for making mini connected objects. Relays, various sensors (temperature, humidity, energy consumption, etc.), OLED display, etc.
ESP-01 vs ESP-01S, which one to choose?
The ESP01 is simply an ESP8266 module installed on a miniature development board (24.8 x 14.3mm). There are only 2 pins of the ESP8266EX module that are exposed on the GPIO GPIO0 and GPIO2 as well as the pins RX et TX for programming and debugging via the serial port.
The difference between the versions lies only in the amount of flash memory, 512 KB or 1 MB.
A few years ago, you could tell by the color of the board. This is no longer the case today even if some manufacturers keep this marketing difference.
The table below summarizes the main differences between the two versions.
|Flash Memory||512 Mo||1 Mo|
|Possible mention||AI Cloud Inside||S Series|
|Note||The red (Power) and blue (WiFi) LEDs are placed next to the antenna engraved on the PCB|
Given the very small price difference (a few tens of cents) between the two models, it is preferable to opt directly for an ESP-01S module.
Whatever the version, the input / output connector (GPIO) is perfectly identical. It has not changed since the first version of the ESP01 module.
Here is the pin identification for the 2 models
Put the ESP01 module in Flash Mode
Most of the ESP32 and ESP8266 development boards most of the time integrate a UART to USB converter (CH340, CP212 …). In addition to this, the ESP8266 development kit takes care of putting the module in a particular mode which allows the binary file of the program to be uploaded to the flash memory.
This is Flash Mode or Boot Load
However, to be as compact, the ESP01 module does not include a UART to USB converter.
You must put the module in Flash Mode yourself each time you want to upload a program from the Arduino IDE or any other code editor.
It’s quite simple, you need the pin GPIO2 be connected to GND when the module is powered on.
Then you can upload the program using a module or a USB to TTL (UART) cable. It is also necessary that the power supply is sufficiently powerful to avoid any failure to transfer the program.
The following diagram uses an external power supply (2 AA batteries). This is not necessary if the USB to TTL adapter delivers enough power. Problems are often encountered with serial cables.
Setup for uploading a program from the Arduino IDE or PlatformIO to an ESP-01 using a USB to TTL adapter.
It quickly becomes tedious!
The best is to buy a programmer (Programmer in English) which embeds both a power supply and a USB to TTL adapter.
This article explains everything in detail
There are few programmers who allow you to activate Flash Mode and in the end it is not very useful because you have to disconnect / reconnect the module each time to be able to use it normally.
See more offers
It is enough to solder a push button and hold the button while inserting the programmer in the USB port of the computer.
How to upload a program from the Arduino IDE?
Before you can develop a program for the ESP-01 WiFi module, you need to install the official ESP8266 SDK. Follow the detailed instructions in this tutorial
There is no dedicated configuration for ESP-01 modules.
1 Open the Tools -> Development board menu and select Generic ESP8266 Module.
2 Adapt the configuration to your board
The default configuration is fine most of the time.
Upload speed 115200 by default but recent modules very well support the maximum speed of 921600 bauds
Flash Mode DOUT
Flash Size Select 1MB or 512KB. It is possible to reserve part of the flash memory for the SPIFFS or LittleFS file system.
A series of articles to learn how to use the SPIFFS or LittleFS (its successor) file system.
3 Connect the programmer
Here the case of a modified programmer. To activate Flash Mode, keep the button pressed while plugging the programmer into the computer’s USB port.
4 Select the COM port on which the programmer is connected
5 Upload the project
6 Disable Flash Mode
After uploading an Arduino program, the ESP01 module will restart. Depending on the modification of the program, the module will remain in Flash Mode (or not). To return to standard operation, here is what to do depending on the solution chosen.
|Resistor||Jumper||Push Button||Integrated selector|
|Remove the ESP01 from the holder|
Replace the ESP01
|Remove the programmer from the USB port|
Remove the jumper
Reconnect the programmer
|There is nothing to do !||Remove the programmer from the USB port|
Return the selector to the UART position
Reconnect the programmer
7 If necessary open the serial monitor to debug the program!
How do I upload a program from PlatformIO?
There is nothing special to do on PlatformIO.
1 Create a new project.
In the board field, do a search with the keyword esp-01. Choose the 512KB or 1MB version from the list.
Here are two configuration examples that you can use directly.
|512KB version||1 MB version|
2 Modify the main parameters
CPU Frequency By default the CPU frequency is 80MHz. The board_build.f_cpu option allows to modify the CPU frequency to 160MHz.
|board_build.f_cpu = 80000000L||board_build.f_cpu = 160000000L|
Note, for battery operation, it is preferable to keep a low frequency.
Serial port speed Assign the serial port speed used in your programmonitor_speed = 115200
Start the compilation and upload of the program from the PIO menu
If the board is in Flash Mode, the program is directly uploaded
Problems uploading a program to an ESP01 from PlatformIO
If you are having trouble uploading the project, you can try to decrease the upload speed by adding the upload_speed option in the platformio.ini file. Recent modules support the default maximum bit rate very well.
For older models, it may be necessary to force the protocol and flash mode.
To master the important options of the platformio.ini file, you can continue by reading this article.
Click to rate this post!
[Total: 2 Average: 5]
More discussion »
Programming ESP8266 ESP-01 with Arduino © GPL3+
ESP8266 module is of low cost and comes pre-programmed with an AT command set firmware, meaning, you can simply hook this up to your Arduino device and get about as much WiFi-ability as a WiFi Shield offers.This module has a powerful on-board processing and storage capability that allows it to be integrated with the sensors and other application through its GPIOs .
In this tutorial we can see how to get started with the ESP-01 Wi-Fi module, configure it, and verify that there is communication established between the module and another device without using a ftdi chip.
STEP 1 : Arduino Setup
First download Arduino IDE ensure that you have the latest software version (some older versions won’t work), visit the following URL: https://www.arduino.cc/en/Main/Software.
Upload Bareminimum sketch from examples to arduino this is to make sure that there are no other programs running on arduino and using serial communication channel.
AT firmware is compatible with the Arduino IDE, so we are going to use this firmware for this tutorial . Connect ESP8266 as per the above circuit.
- VCC shall be connected to the 3.3V power supply.
- GPIO0 and GPIO2 are general purpose digital ports. GPIO0 also controls the module mode (programming or normal operation). In our case (normal operation), it shall be connected to 3.3V (high). GPIO2 is not used in this example.
- Rx: Goes to Arduino pin0 (But needs a voltage adjusting).
- CH_PD: Chip enable. Keep it on high (3.3V) for normal operation.
- RST: Reset. Keep it on high (3.3V) for normal operation. Put it on 0V to reset the chip.
- Tx: Goes to Arduino pin1.
Open the serial monitor change the boud rate to 115200 and coose NL and CR (new line and carrage return).Type AT on the serial monitor you will see an OK response .If you see garbage value on the screen, try resetting the module, or checking your baud rate. Make sure the NL and CR option is set.
ESP8266 module has threeoperational modes.
1. Access Point (AP)
In AP the Wi-Fi module acts as a Wi-Fi network, or access point (hence the name), allowing other devices to connect to it. It establishes a two way communication between the ESP8266 and the device that is connected to it via Wi-Fi.
2. Station (STA)
In STA mode, the ESP-01 can connect to an AP(access point) such as the Wi-Fi network from your house. This allows any device connected to that network to communicate with the module.
In this mode ESP-01 act as both an AP as well as in STA mode.
You can refer the following site for more ESP8266 AT command set click here.
STEP 2: Installing ESP8266 Platform
First arduino environment has to be setup to make it compactable with the ESP module. It is required to have Arduino version 1.6.4 or higher in order to be able to install the ESP’s platform packages.
1.Open the preferences window from the Arduino IDE. Go to File > Preferences
2. Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field and click the “OK” button
3. Open boards manager. Go to Tools > Board > Boards Manager…
4. Scroll down, select the ESP8266 board menu and install “ESP8266 platform”
5.Choose your ESP8266 board from Tools > Board > Generic ESP8266 Module.
STEP 3. Controlling Input and Output
In Arduino IDE go to examples and take blink change the pin no to 2 from 13 since there is only two gpio pins for ESP8266 (GPIO0 and GPIO2).
NOTE: Make sure that GPIO 0 is grounded while uploading the code.
Connect the ESP as per the image and upload the sketch and watch the magic.
Comments and Questions welcome! Thanks for reading.
- Season 9 hoarders
- Naruto with rinnegan
- How to open samsung s10e
- C# junior developer salary
- Vw thing speedometer
IoT Using ESP8266-01 and Arduino © GPL3+
Today, we will build a device that connects to the internet and allow the user to control his/her home remotely over wifi. we will use the Arduino board(any model will do the job well) with the ESP8266-01 wifi module to make this device. Let’s get started!
What’s a smart home?
Smart home technology uses devices such as linking sensors, features and other appliances connected to the internet of things (IoT) that can be remotely monitored, controlled or accessed and provide services that respond to the needs of the users.Wikipedia
We will build a simple web page that will work as a control panel for the user allows him to control any home appliance connected to our system. To build the web page we will use:
The Embedded Hardware
the web page sends some orders to the ESP8266-01 which is working as a web server connected to the Arduino board. And according to the incoming data, the Arduino board will take some actions like turning on the bulb, turning off the TV and in this part, we will use:
Getting Started with the ESP8266-01
As we stated before, we need our Arduino board to get connected to the Internet but the Arduino Nano the version which we are using today doesn’t have that feature. So, we will use the ESP8266-01 wifi module to add the wifi feature to our tiny Arduino board.
there are a lot of ESP wifi modules models out there, which one should I choose?! Well, almost all the ESP family wifi modules out there will do the job well but each one has its own features and specifications. I encourage you to look at each one specifications and features to choose the most suitable one for your needs.
According to my needs, I found the ESP8266-01 is the most suitable one and that’s for many reasons. It’s very famous in the makers community. As a result, it got a very solid online community that you can find an answer to almost any question or problem you face with this awesome small module. Also, its price is very cheap(around 1.5$).
Also, it’s very easy to use with the Arduino board since its a Serial wifi module it can communicate with the Arduino board over the serial communication. It has a built-in Microcontroller which means that you can use it as a standalone microcontroller and wifi module in one combo which is super cool. It has built-in two GPIOs. Only with 1.5$, you will get all of these features which is super cool, actually. Let’s get a closer look at this module.
- VCC: connect to +3.3V power source. don’t connect it with a 5V source it will get damaged.
- GND: -ve pin, connect it to the ground of your circuit.
- CH_PD: chip enables pin – Active HIGH. connect it to a logic value HIGH to allow the module to boot up.
- RST: Chip Reset pin – Active LOW, when it pulled LOW it Resets the module.
- GPIO0, GPIO2: General purpose input/output pins.
- Tx: connect to the Rx of the microcontroller(Arduino) to establish serial communication.
- Rx: connect to the Tx of the microcontroller(Arduino) to establish serial communication.
As we stated before the ESP8266-01 module communicates with the Arduino board over the Serial communication, which means that we need to connect it with the Arduino’s Serial pins 0, 1(Tx, Rx). But the problem here is that these pins will be busy because we will use the Arduino Serial monitor alongside the ESP8266-01 for debugging purposes. So, we need to find another two Serial communication pins to use them with the ESP8266-01.
Fortunately, Arduino made this easy. There’s a library called “SoftwareSerial” which developed to allow serial communication on other digital pins of the Arduino, using software to replicate the functionality. For example, by using this library I can set the pins 2, 3(SoftwareSerial) as Rx and Tx alongside the pins 0, 1(Hardware Serial).
“SoftwareSerial” library works great as long as the transmission speed is less than 19, 200 baud. But, there’s a small problem here! the ESP8266-01 wifi module comes from the factory programmed to communicate at speed 115, 200 baud which is somehow hard at the “SoftwareSerial” library to communicate at. So, we need to reprogram our wifi module to set the communication speed to 9600 baud which works pretty good with the “SoftwareSerial” library. To do that we will use some “AT Commands”.
Changing the ESP8266-01 communication speed
First step: Upload an empty program to the Arduino board
At this step, we are uploading an empty code to the Arduino board. Just to be sure that there’s nothing is Executing in the background by the Arduino board.
Second Step: Wiring the ESP8266-01 with the Arduino board
To Reconfigure the ESP8266-01 and change the communication speed(baud rate) we use the AT-commands. Simply, AT commands are some instructions used to control modems, mobile phones, Bluetooth modules, wifi modules, GSM Modules.
with these commands we can get basic information about our mobile phone or GSM Modules like the name of the manufacturer, model number, IMEI and so on.“AT” is an abbreviation for “ATtention” and it’s called AT-commands because every command starts with “AT”. the “AT” prefix is not a part from the commands itself it just tells the module the start of the commands.
Some Important AT Commands
Command number “4” depends on your ESP8266-01 firmware version, if this command doesn’t work with you Try this one
Step 1: Open the Serial Monitor
Step 2: Set the Communication speed to 115, 200 baud
As we stated before, the ESP comes from the manufacturer programmed to communicate at speed 115, 200 baud. So we need to set the Arduino communication speed to 115, 200 too for the first time only then we will change that later. Also, you should select “Both NL & CR”.
Step 3: Send “AT” and wait for the response to be sure that the ESP module is hearing you.
Step 4: Now, change the ESP8266-01 communication speed
My ESP8266-01 module loaded firmware is 1.6. and this command works well for me. If it doesn’t work with you, try this . If it responds with “OK” now your ESP module communication baud rate changed from 115, 200 baud to 9600 baud. CONGRATS!
Let’s change the Serial monitor communication speed back to 9600 and send “AT” again to see if the ESP module can hear us at the new Speed(9600) or not.
LOOK! it’s working. the ESP8266-01 now can communicate with the Arduino board at 9600 baud rate instead of 115, 200 baud rate.
Now, let’s try to connect with the Wifi network
Once you press enter, the ESP8266-01 will search for this network and connect with it. If the process succeeds it will return this
At this point, we successfully changed the ESP8266-01 communication speed from 115, 200 baud to 9600 baud. Now, we need to build the control panel(Web Page) which the user will use to control his home appliances. So, let’s build it!
What’s the Internet?
Actually, the internet is a wire buried under the ground it can be fiber optics, copper, or even a satellite but the internet is simply a wire.Any two computers connected to that wire can communicate. If the computer is connected directly to that wire it’s called a server and if it not connected directly to that wire it’s called a client.
Server: is a special computer that runs a specific Operating system like Apache, this special computer saves some web pages, files, databases on its disk drive. any server connected to the internet has a unique IP Address like 126.96.36.199, the IP address is just like a phone number helps people to find each other easily. Since that IP Address is not very easy for humans to remember. So, we just gave it a name google.com(Domain name).
Client: it’s a computer like what you and I are using every day, it’s connected indirectly to the internet through an internet service provider(ISP) and it also has a unique IP address.
Simply, it starts with a request sent from a web browser(Client) like google chrome, firefox and ends with the response received from the webserver.
You entered the website URL makesomestuff.org in a browser from a computer(client), then this browser sends a request to the webserver hosts the website, the webserver then returns a response contains HTML page or any other document format to the browser to display it.
Exactly, that’s what we need to do today in our project. We need to send a request from the web browser(Client) to the ESP8266-01(Webserver) which both of them are connected to the same local network. This request contains some data which tells the Arduino what to do turn on or off a light bulb. So, let’s build the web page!
Building The Web Page
HTML: Stands for “HyperText markup language” we use it to build any web page main structure. Like adding some buttons, images, paragraphs, headers, tables, and many more elements. it consists of a series of elements which tell the browser how to display the web page content. these elements represent by something called tags.
CSS: It stands for cascading style sheet. After building the web page main structure, you need to make this structure looks nice here comes CSS to make some styling. it’s a language that describes the style of an HTML element. it consists of some selectors and deceleration blocks.
Build The Web Page Structure
To easily understand the upcoming explanation, I recommend Reading this cool HTML intro.
As we see our control panel is very simple, it contains two headers each one has a different size, one image, and two buttons one for turning on an LED and the second one for turning it off.
- <!DOCTYPE html>: declaration defines that this document is an HMTL5 document.
- <html>: the root element of an HTML page.
- <head>: element contains meta information about the page.
- <title>: element specifies the title of the document. this title appears on the web page browser tab.
- <body>: element contains the visible web page content.
- <h1>: element defines a large element.
- <h4>: element defines a smaller header. when the header value decreases the font decreases.
- <img>: element adds an image to the web page. the image that you want to display should be in the same project folder.
- <br>: advance the cursor to a new line.
- <button>: element adds a button to the page content.
Each button is our web page has very important two attributes the , and the attributes. we will talk about why we assigned these two values to the buttons in the Jquery code explanation.
Styling The Web Page
To easily understand the upcoming explanation, I recommend Reading this cool CSS intro.
Now, the web page looks nicer (NOT TOO MUCH xD) we gave it a cool green background color, we make the page content centered aligned, and we change the headers font color and font family which made the web page more alive. We used CSS to do all of this styling stuff.
We added some few lines of code to make our web page looks nicer. We added inside the body tag to make all the web page content in the center of the page and to set the background color to seagreen also to set the font color to seashell.
Also, we added inside the two button tags to set a margin of 10 pixels around the four sides of each button.
Sending a Request To The Webserver
To easily understand the upcoming explanation, I recommend Reading this cool Jquery intro.
Now, after building our web page structure and styling it we need to add some functionality to the two buttons which we added earlier in the web page. we need when the user clicks the “LAMP ON” button his/her browser sends a request contains some unique data to the server(ESP8266-01) this unique data tells the Arduino to turn on the lamp. The same thing with the second button “LAMP OFF” when the user clicks it, the browser will send a request contains some unique data to the server(ESP8266-01) this unique data tells the Arduino to turn off the lamp. Let’s take a look at the code.
First Things First, we need to import the Jquery library in our code. So, we added this line in the head tag.
All the magic happens in this interesting part.
When the user clicks on any button associated with the class “button”, trigger the following function.
Get the value of the clicked button attribute “id” and store it inside the “p” variable.
Put the variable “p” value in a dictionary (key-value) it’s key is “pin” and the value is “p” variable value.
Then, send a GET request to the webserver which it’s IP address is “172.20.10.11”. this GET request contains the value of the attribute id pressed button.
In case the user pressed the “LAMP ON” button this id value will be 111, so the GET request header will contain some data like this pin=111. look at the next figure!
At the opposite side, if the user pressed “LAMP OFF” button the request will contain this data pin=110.
I know you asking now why the heck did he choose 111 and 110 specifically? Ok, Lemme answer you fam. Actually, the number 111 and 110 divides into two parts.
- Part one: is the first two numbers which are in both cases will be “11”, it refers to the Arduino pin number which the load I need to control is connected on.
- Part two: is the third number which changes between 1 and 0 depending on the clicked button. And it refers to the pin state(ON or OFF).
In the Arduino code, we will receive this data and separate these two parts from each other and save each part in a different variable, part one in variable and the second part in variable , then we will write this simple line of code to control the connected load
Connecting The Load
Now, we need to connect the load with the Arduino board to control it. Before connecting any high voltage device like the air conditioner or even the TV, we need to test our circuit and the code with some low voltage stuff like LEDs only to make sure that everything is working well. Here’s the wiring diagram
The wiring is pretty simple, we are connecting the LED positive leg to the Arduino digital pin 11, and the negative leg to the GND through a 1k ohm resistor.
the code is pretty straightforward, we implemented two different functions and
The function job is regulating how the AT commands will get sent to the ESP8266-01 module.
the function job is to provide the function the AT commands that we need to send to the ESP8266-01.
in the function we read the income HTTP request header and search for the “+IPD, ” which means that the request has successfully arrived, then we read the pin value which it will be “111” if the user clicked the “LAMP ON” button and “110” if the user clicked “LAMP OFF” button.
Don’t forget to put your wifi SSID and Password in the Arduino code line no. 103
For more code explanation please read the comments in the code, it’s well documented
How It Works
After uploading the code to the Arduino board, open the Serial monitor and read the responses that the ESP module is sending.
at the beginning of the program, if you see something like the previous figure with “OK” at the end of the page, it means that the ESP8266-01 module is successfully connected to your wifi (Access point) and got an IP and MAC address. Now, you can open your fancy web page and try to control some stuff 😉
But, if you see something like the previous figure with a “FAIL” or “ERROR” at the end of the page, it means that your ESP module cant connect to your wifi (Access point) for some reasons, try to check if entered the right SSID and password for your network.
Adding a High Voltage Load
After we tested our code and got sure that everything is working like a charm, we need to replace this boring LED with a High voltage load like an air conditioner, TV or a light bulb. But to control all of these high voltage appliances we have to deal with relays.
What’s and why relays? Ok, the relay is a mechanical switch, which is toggled on or off by energizing a coil. it’s mainly used to control a high powered circuit using a low power signal (5V or 0V). So we can control a high powered device like an air conditioner or an AC lamp turning it on or off only by a 5V or 0V signal. Which is amazing!
The Two-channel relay module has two control pins(IN1, IN2) these pins should get connected to two Arduino digital pins to control the state of the two coils, closes or opens the load circuit.
At the opposite side of the relay module, the COM(common) should get connected to one end of the load. the other end of the load is either connected to the NC(Normally Close) or NO(Normally open), if connected to the NO the load remains Disconnected before trigger and vice versa.
As you see, we are using a two-channel relay module that gives us the ability to control two different AC loads. We are connecting the first relay at digital output pin11(Arduino) and the second relay to digital output pin 12(Arduino)
We will make a small modification to our web page, we will add another two buttons(ON and OFF) to control the second connected load.
How It Works
Just like the last trial, You upload the Arduino code to the board (if not uploaded yet) and open the serial monitor and make sure that your ESP module is connected successfully to your access point and got an IP and MAC address.
Then open your fancy web page and start controlling your stuff 😉
Make it more professional!
What about transferring our breadboard circuit to a professional printed circuit board (PCB) to make our project more rigid and solid, I designed the project circuit using Autodesk Eagle software. all the PCB files are open-source you can access it from this link: https://www.pcbway.com/project/shareproject/IoT_Using_Arduino_and_ESP8266_01.html
Because we love open source 😉
You can order your own PCB From PCBWay company these guys have a very good reputation in this field and they ship to more than 170 countries around the world with reasonable prices. all you have to do is to open the project PCB files link and press “Add to cart”. That’s it!
if your ESP Module is successfully connected to your access point but there is no action happens when you click the web page buttons
- make sure that you are sending the request from your web browser from port 80(HTTP). example:
- make sure that your PC or Laptop and the ESP module is connected to the same Access point.
- In Jquery code, make sure that you wrote the right ESP module IP address.
- Make sure that you are connecting the load at Arduino digital pins 11 and 12.
- Don’t forget to save the Web page code file after any change or modification, and reload the web page in the web browser after any code modification to take effect.
We are done! in today’s tutorial, we learned how to build a simple web page using HTML, CSS, and jquery. Also, we learned how to control an AC load wirelessly from a web-based control panel, and how to use the awesome ESP8266-01 Wifi module with the Arduino board.
you wanna see more Tutorials and open source projects you can also visit my blog www.makesomestuff.org
Lastly, if you have any questions drop it in the comments section below, I will be more than happy to hear from you 😉
Button was pressed!
Introduction: Using ESP-01 and Arduino UNO
In our previous tutorial, we learned how to set up the ESP8266 ESP-01 and establish communication with other devices.
In this tutorial we are going to show how to use the ESP-01 module to give the Arduino UNO access to a Wi-Fi network and interact with inputs and outputs.
Step 1: Materials
The materials that you will need for this tutorial are:
Add the LED and button to the wiring setup from the previous tutorial as shown in the images above.
Note that TX and RX from the ESP-01 are now connected to pins 7 and 6 correspondingly.
Step 2: Coding
Now that we have the setup complete, we are going to control the LED via Wi-Fi to turn it ON or OFF.
We are also going to check to make sure that when the button is pressed that a message is received about its change of state.
The following code shows how to do this:
Step 3: Code Explanation
In this part of the code, we include the SoftwareSerial library to allow pins 6 and 7 to receive serial communication from the ESP-01.
We also assign the name “LED” to pin 5 and “button” to pin 11, and make the initial value of the button zero.
Step 4: Code Explanation - Continued
In the setup, we make the LED an output and the button an input.
We then begin serial communication and define the baud rate for both channels of communication.
Next, we call the function “SendCommand” several times to configure the ESP-01.
With this function you avoid having to open the serial monitor and sending commands manually like we did in the previous tutorial.
First we reset the module and wait for a couple of milliseconds to let it finish.
Then we make it operate in STA mode and ask for the IP address.
Finally, we enable multiple connections and start the server at port 80.
Step 5: Code Explanation - Continued
In the loop, we read the state of the button and assign it to the variable “button_state.”
Then we check if the button is pressed.
If the case is true, we type the command “AT+CIPSEND=0,23” to send 23 bit of data through channel 0 to our device connected to the ESP-01. Then we type the message that we want to send. In this case the message is “Button was pressed!” Note that we can use html formatting to edit the text and make it a header.
Next, we create a string variable that will hold the data coming from the ESP module. Once all data has been read we check if the received data contains either a string equal to “LED=ON” or “LED=OFF” along the lines.
If the first case is true, the LED is turned on. If the second case is true, the LED is turned off.
Step 6: Code Explanation - Continued
The “SendCommand” function takes two arguments: the AT command that we want to send to the ESP-01 and the acknowledge string.
The first argument is used to send a command to the ESP-01 through the serial channel.
The second argument is used to verify that the command was successfully accepted by the ESP module.
Step 7: Code Explanation - Continued
The last function is used to compare the acknowledge string to the response given by the ESP-01 once a command has been sent.
First we initialize the variable “current_char” to zero. This variable will serve as an index to compare each character between the acknowledge string and the ESP response. Then we store the length of the acknowledge string in the variable “keyword_length” and create a deadline that equals to the time since the Arduino board began running plus 5000ms.
Next we create a while loop that runs until the deadline is met. Inside the while loop we check if there is data to be read in the serial channel connected to the ESP. If the case is true, then we compare the acknowledge string to the data being read from the serial channel.
If both are equal, then the function returns a true to tell the program that the ESP-01 has responded accordingly to the command sent. If the deadline is met, then the function returns a false, meaning that something went wrong and the ESP was not able to respond to the command sent.
Step 8: Results
Once we upload the code, we can open the serial monitor. We will get the information shown in the image above.
This means that the configuration of the ESP was successful, and it is ready to be used as a server.
Step 9: Results - Continued
Now we can open a web browser and type either of the following lines shown above in the screen shot images of the browser windows.
The first line is used to turn the LED on, and the second line is used to turn the LED off. The images above show the lines written into the browser as well as the corresponding action that occurs on the breadboard.
Step 10: Results - Continued
If we press the button, we get the following message in our web browser’s window.
Step 11: Results - Continued
If we use the Android App “Mobile Telnet” we can get the same results.
First we need to open the App and connect to the ESP module as it was done in the previous tutorial.
Once we are connected we can type a message to turn the LED on, as shown in the image above.
Step 12: Results - Continued
Similarly, we can send the following message to turn the LED off.
Shown above in the screenshot image.
Step 13: Results - Continued
If we press the button we get the same message as before on our phone.
Now you can manipulate inputs and outputs via Wi-Fi using the Arduino UNO and the ESP-01 module in the ESP8266 series.
If you have any questions about this tutorial, do not hesitate to post a comment, shoot us an email, or post it in our forum.
Check out Jaycon Systems online store for the parts you need to start creating!
If you haven't already - read through the other great tutorials we have on our website as well as our Instructables profile!
Let us know what you think, and thanks for reading!
3 People Made This Project!
Did you make this project? Share it with us!
3D Printed Student Design Challenge
Pumpkins & Gourds Speed Challenge
Arduino esp with
How to Program ESP8266 (ESP-01) Module with Arduino UNO
In a previous story we saw how to flash firmware on ESP8266 ESP-01 module. Now we are going to see how to program ESP-01 module using an Arduino UNO with few very simple steps.
Download and install Blynk libraries to your Arduino IDE its very important before programming (Search on YouTube you can find easily).
Connections for programming
(Find the code in attachments)
GND -------------------------- GND
GPIO-2 -------------------------- Not connected (open)
GPIO-0 -------------------------- GND
RXD -------------------------- RX
TXD -------------------------- TX
CHPD ------------------------ 3.3V
RST -------------------------- Not connected (open) *(Read Below Instruction)
VCC -------------------------- 3.3V
Very Important Instruction:
Now before hitting upload, take GPIO-0 to ground.
And RST to ground afterwards, remove RST after half a second (the blue LED flashes for some millisecond).
Hit upload, the blue flashes once and then blinks till it gets uploaded.
Now you are all done.
After programming, remove the serial Arduino cable and plug it again and take out GPIO-0 from GND and just interchange the connection of RX and TX that is RX connect to TX and TX connect to RX.
Connections after programming
GND -------------------------- GND
GPIO-2 -------------------------- Not connected (open)
GPIO-0 -------------------------- Not connected (open)
RXD -------------------------- TX
TXD -------------------------- RX
CHPD ------------------------ 3.3V
RST -------------------------- Not connected (open)
VCC -------------------------- 3.3V
That's it, you are done!!!
Open serial monitor of Arduino IDE where you see the ESP is connected and ready.
Arduino core for ESP8266 WiFi chip
This project brings support for the ESP8266 chip to the Arduino environment. It lets you write sketches, using familiar Arduino functions and libraries, and run them directly on ESP8266, with no external microcontroller required.
ESP8266 Arduino core comes with libraries to communicate over WiFi using TCP and UDP, set up HTTP, mDNS, SSDP, and DNS servers, do OTA updates, use a file system in flash memory, and work with SD cards, servos, SPI and I2C peripherals.
Installing with Boards Manager
Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. We have packages available for Windows, Mac OS, and Linux (32 and 64 bit).
- Install the current upstream Arduino IDE at the 1.8.9 level or later. The current version is on the Arduino website.
- Start Arduino and open the Preferences window.
- Enter into the File>Preferences>Additional Boards Manager URLs field of the Arduino IDE. You can add multiple URLs, separating them with commas.
- Open Boards Manager from Tools > Board menu and install esp8266 platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation).
Boards manager link:
Using git version
Also known as latest git or master branch.
PlatformIO is an open source ecosystem for IoT development with a cross-platform build system, a library manager, and full support for Espressif (ESP8266) development. It works on the following popular host operating systems: macOS, Windows, Linux 32/64, and Linux ARM (like Raspberry Pi, BeagleBone, CubieBoard).
- What is PlatformIO?
- PlatformIO IDE
- PlatformIO Core (command line tool)
- Advanced usage - custom settings, uploading to SPIFFS, Over-the-Air (OTA), staging version
- Integration with Cloud and Standalone IDEs - Cloud9, Codeanywhere, Eclipse Che (Codenvy), Atom, CLion, Eclipse, Emacs, NetBeans, Qt Creator, Sublime Text, VIM, Visual Studio, and VSCode
- Project Examples
Building with make
makeEspArduino is a generic makefile for any ESP8266 Arduino project. Using make instead of the Arduino IDE makes it easier to do automated and production builds.
Documentation for latest development version: https://arduino-esp8266.readthedocs.io/en/latest/
Issues and support
ESP8266 Community Forum is a well-established community for questions and answers about Arduino for ESP8266. Stackoverflow is also an alternative. If you need help, have a "How do I..." type question, have a problem with a 3rd party library not hosted in this repo, or just want to discuss how to approach a problem, please ask there.
If you find the forum useful, please consider supporting it with a donation.
If you encounter an issue which you think is a bug in the ESP8266 Arduino Core or the associated libraries, or if you want to propose an enhancement, you are welcome to submit it here on Github: https://github.com/esp8266/Arduino/issues.
Please provide as much context as possible, as well as the information requested in the issue template:
- ESP8266 Arduino core version which you are using (you can check it in Boards Manager)
- your sketch code; please wrap it into a code block, see Github markdown manual
- when encountering an issue that happens at run time, attach the serial output. Wrap it into a code block, just like the code.
- for issues that happen at compile time, enable verbose compiler output in the IDE preferences, and attach that output (also inside a code block)
- ESP8266 development board model
- IDE settings (board choice, flash size)
For minor fixes of code and documentation, please go ahead and submit a pull request. A gentle introduction to the process can be found here.
Check out the list of issues that are easy to fix — easy issues pending. Working on them is a great way to move the project forward.
Larger changes (rewriting parts of existing code from scratch, adding new functions to the core, adding new libraries) should generally be discussed by opening an issue first. PRs with such changes require testing and approval.
Feature branches with lots of small commits (especially titled "oops", "fix typo", "forgot to add file", etc.) should be squashed before opening a pull request. At the same time, please refrain from putting multiple unrelated changes into a single pull request.
License and credits
Arduino IDE is developed and maintained by the Arduino team. The IDE is licensed under GPL.
ESP8266 core includes an xtensa gcc toolchain, which is also under GPL.
Esptool.py was initially created by Fredrik Ahlberg (@themadinventor, @kongo), and is currently maintained by Angus Gratton (@projectgus) under GPL 2.0 license.
Espressif's NONOS SDK included in this build is under Espressif MIT License.
ESP8266 core files are licensed under LGPL.
SPI Flash File System (SPIFFS) written by Peter Andersson is used in this project. It is distributed under the MIT license.
umm_malloc memory management library written by Ralph Hempel is used in this project. It is distributed under the MIT license.
SoftwareSerial library and examples written by Peter Lerup. Distributed under LGPL 2.1.
BearSSL library written by Thomas Pornin, built from https://github.com/earlephilhower/bearssl-esp8266, is used in this project. It is distributed under the MIT License.
LittleFS library written by ARM Limited and released under the BSD 3-clause license.
uzlib library written and (c) 2014-2018 Paul Sokolovsky, licensed under the ZLib license (https://www.zlib.net/zlib_license.html). uzlib is based on: tinf library by Joergen Ibsen (Deflate decompression); Deflate Static Huffman tree routines by Simon Tatham; LZ77 compressor by Paul Sokolovsky; with library integrated and maintained by Paul Sokolovsky.
Other useful links
Lwip link layer repo
Serial Monitor Arduino IDE plugin Original discussion here, quick download there.
FTP Client/Server Library
You will also like:
- Parker pen & pencil set
- Cutie mark crusaders
- Crystal stock price
- Trunk party ideas
- Celemony support
- Ariana grande wikipedia español
- Season 9 hoarders
- Apartment building exterior design ideas
- Walmart auto care
- Mk5 tdi jetta
- Wenger knives
This post shows a quick guide to program ESP8266 WiFi module with Arduino UNO board and how to use Arduino IDE software in order to write codes for this module.
The ESP8266 board contain the microcontroller ESP8266EX (32-bit microcontroller) from Espressif Systems, this low cost Wi-Fi module is a very good choice for hobbyists to build IoT projects. IoT: Internet of Things.
The ESP8266 module comes with AT firmware which allows us to control it with AT commands through serial interface (RX and TX pins).
The most popular ESP8266 module is the ESP-01, it has only 8 pins as shown in the picture below (with pinout):
As show above, the ESP-01 board has 8 pins which are:
TX: UART data transmit pin which is also GPIO1 pin
GND: ground pin (0 V)
CH_PD: chip power down pin, used to turn off the ESP8266EX chip, when high the chip is enabled and when low the chip is off, also named as CH_PU (chip power up) and CHIP_EN (chip enable)
GPIO2: general purpose input/output pin 2
RESET: external reset pin (active low), when low the chip is in reset mode
GPIO0: general purpose input/output pin 0
VCC: power supply pin. ESP8266EX chip Operating voltage: 2.5V ~ 3.6V
RX: UART data receive pin which is also GPIO3 pin
ESP8266 Programming with Arduino IDE:
It’s easy to start ESP8266 programming, all what we’ve to do is adding it to the Arduino IDE software.
First, open Arduino IDE and go to File —> Preferences
Add the link below to Additional Boards Manager URLs and click on OK:
Now go to Tools —> Board —> Boards Manager …
In the search box write esp8266 and click on Install and the installation of the board should start (the installation may take some time depending on the connection speed):
After the installation select the ESP-01 board by going to: Tools —> Board: —> Generic ESP8266 Module
Now every thing is finished and we can start our ESP8266 programming.
Program the ESP8266 (ESP-01) module with Arduino UNO board:
As known the Arduino UNO board contains Microchip ATmega16U2 microcontroller which is used as USB-to-serial converter. This chip (ATmega16U2) can be used to program (flash) the ESP-01 Wi-iF module, circuit connections are shown below:
In the circuit there are 2 resistor one of 1k ohm and the other one of 2.2k ohm. The two resistors are used to step down the 5V which comes to arduino into about 3.43V which goes to the ESP-01 board (connected to RX pin of the ESP-01) because the ESP8266EX chip works with 3.3V only and applying a 5V directly may damage it.
On the other hand, the TX pin of the ESP-01 is connected directly to the Arduino board without any voltage level converter because here the ESP-01 sends data (at 3.3V) to the Arduino board using this pin.
The ESP-01 is supplied with 3.3V which comes from the Arduino board.
There is other ways to build a programmer for the ESP-01 module for example by using FT232RL USB to serial converter from FTDI Chip which is shown below:
With this module we can choose between 5V and 3.3V (using a jumper) and here we’ve to select 3.3V.
LED Blink with ESP8266 (ESP-01):
This is a simple example which we should start with, it’s the LED blinking example. In this example I’m going to connect one LED to ESP-01 board GPIO2 pin, and make this LED blinks. Circuit diagram is shown below:
The LED is connected to pin GPIO2 of the ESP-01 module through a 330 ohm resistor.
The ESP-01 module needs a 3.3V supply. We can get the 3.3V for example from Arduino UNO board, or using AMS1117 3V3 voltage regulator which steps down 5V into 3.3V, or directly from 3.3V source.
Arduino code for ESP8266 module:
// LED Blink example for ESP8266 (ESP-01) module
#define LED 2 // LED is connected to GPIO2
pinMode(LED,OUTPUT); // Configure LED pin as output
digitalWrite(LED,HIGH); // Turn the LED on
delay(500); // wait 1/2 second
digitalWrite(LED,LOW); // turn the LED off
delay(500); // wait 1/2 second