Home ARDUINO How to Program ESp8266 Esp01 with Arduino UNO

How to Program ESp8266 Esp01 with Arduino UNO


ESP8266 ESP-01 is a Wi-Fi module that allows microcontrollers access to a Wi-Fi network and we can program it with different sensors. This module Esp01 is a self-contained SOC (System On a Chip) which mean we did want another microcontroller we can control it with different sensors that don’t essentially need a microcontroller to manipulate inputs and outputs as you would normally do with an Arduino UNO or with other Similar, for example, because the ESP-01 acts as a small computer which has Wi-Fi and processor with small ram.

And it is depending upon the version of the ESP8266, it is possible to have up to 9 GPIOs (General Purpose Input Output) which is contained in the node MCU Micro Controllers. Thus, we can give a microcontroller internet access like the Wi-Fi shield does to the Arduino UNO or other Micro Controller which act like a controller, or we can simply program the ESP8266 to not only have access to a Wi-Fi network that means we can just program the esp01 for itself. For Example, we can blink the LED or Communicate the sensors between one Arduino to the web, but to act as a microcontroller as well. This makes the ESP8266 very adaptable, and it can save some money and space for your projects.

In this article, we are going to learn how to set up the ESP-01 Wi-Fi module, configure it, and verify that there is communication established between the module, sensor, and another device.

Step 1

 Collect the Hardware

These are the components that you will need:

Step 2

Setup the Hardware

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 3

Upload Coding


#include <SoftwareSerial.h>

#define TIMEOUT 5000 // mS

#define LED 5

SoftwareSerial mySerial(7, 6); // RX, TX

const int button = 11;

int button_state = 0;


void setup()






SendCommand(“AT+RST”, “Ready”);



SendCommand(“AT+CIFSR”, “OK”);





void loop(){

button_state = digitalRead(button);


if(button_state == HIGH){



Button was pressed!






String IncomingString=””;

boolean StringReady = false;


while (mySerial.available()){


StringReady= true;



if (StringReady){

Serial.println(“Received String: ” + IncomingString);


if (IncomingString.indexOf(“LED=ON”) != -1) {




if (IncomingString.indexOf(“LED=OFF”) != -1) {






boolean SendCommand(String cmd, String ack){

mySerial.println(cmd); // Send “AT+” command to module

if (!echoFind(ack)) // timed out waiting for ack string

return true; // ack blank or ack found



boolean echoFind(String keyword){

byte current_char = 0;

byte keyword_length = keyword.length();

long deadline = millis() + TIMEOUT;

while(millis() < deadline){

if (mySerial.available()){

char ch = mySerial.read();


if (ch == keyword[current_char])

if (++current_char == keyword_length){


return true;




return false; // Timed out


Step 4

Result of Serial Monitor

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. If you do not know how to open Serial Monitor then follow this short key

Now we can open a web browser and type either of the following lines shown above in the screenshot 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.

If we press the button, we get the following message in our web browser’s window.



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 question, then please do let me know.

You may also like to read these articles

Build Your Own Vehicle Tracking System using Arduino (Start with Sim808 )

How to Make Radar Detector with Arduino and Ultra Sonic Sensor

Hope my article “How to Program ESp8266 Esp01 with Arduino UNO ” helps you to Program ESp8266 Esp01 with Arduino UNO. if you have any query, feel free to comment.


Please enter your comment!
Please enter your name here