Simple Webserver Using Arduino and ESP8266




The main aim of this instructable is to show how you can create a simple web server using Arduino and Wi-Fi module which displays the sensor data in the webpage.

Enjoy this instructables........


Step 1: Things You Need


1. Arduino UNO or Mega.

2. WiFi module ESP8266- 01/12.

3. 3.3V voltage regulator. (LM390/LD117)

4. LM35 Temperature Sensor.

5. Jumper wires.

6. External 5V source (optional)..

7. Breadboard.

8. Capacitors (0.47uF, 22uF).


1 .Arduino IDE.

2. Web browser.

Step 2: Pin Configurations and Preparing ESP8266

Things to know before starting with ESP8266
The ESP8266 WiFi Module is a self contained SOC with integrated TCP/IP protocol stack that can give any microcontroller access to your WiFi network. The ESP8266 is capable of either hosting an application or offloading all Wi-Fi networking functions from another application processor. Each ESP8266 module 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.

Before you go for programming we have to prepare ESP module to work with arduino.

For ESP8266-01 the VCC pin and CH_PD pin should be short-circuit as shown in the image above.

Same way in ESP8266-12 there a certain pins which are to be short i.e CH_PD and GPIO0 with VCC, GPIO15 with GND

For ESP8266-12 without base board we have to solder it on perfboard or with connecting wires for making it breadboard compatible.

AT commands for ESP8266 is attached below..

Step 3: Circuit Connections

Voltage Regulator

The circuit for voltage regulator is shown in the above diagram. Capacitors are connected at the input and output terminal of regulator for smoothing. The capacitors used is ceramic type connected at input side and electrolytic type at the output side.

NOTE: It is not advisable to give 5v source from Arduino as ESP requires more current for its operation. Doing so can cause malfunction of Wi-Fi module. Schematics shown above is just for representation.

ESP8266 connections

VCC should be connected to the 3.3v voltage regulator and GND should be common for both Arduino and for ESP same follows for any sensors used.

ESP RxD----------------->Arduino Tx

ESP TxD------------------>Arduino Rx

If using Arduino Mega we can use Serial Port 1, i.e. Pin 18 and 19, for connecting to ESP as Serial Port 0 is used by serial monitor.

For Arduino UNO we have to assign software serial which is declared in the program. Here we are using Arduino pin 2 and 3 as Rx and Tx

Temperature Sensor

the VCC of the sensor is connected to 5v source from Arduino and GND is connected to the common ground. the Output pin is connected to Arduino's analog pin (A0).

Step 4: Arduino Sketch and Explanation.

Arduino sketch for this tutorial is attached below, Program is self-explanatory and contains comments for all operations.

If you are using Arduino Uno then follow this...


#define DEBUG true

SoftwareSerial esp8266(2,3);

REPLACE the above text in bold with the content above the void setup() ,and also Serial1 with esp8266 in program.

The above Code is to assign UNO pins 2 and 3 as RX and TX. This means that you need to connect the TX line from the esp to to Arduino's pin 2 and the RX line from the ESP to the Arduino's pin 3.

Step 5: Final Outcome.

As we are using ESP8266 in Mode 2 i.e. Access Point ,it will create a Wi-Fi hotspot with ssid AI-THINKER.

By default there is no password for the network. We can change SSID and PASSWORD by sending the AT commands from the program.

Accessing the Web page

First connect to the network by your device.

Open a web browser such as Google Chrome.

Go to the Address bar and enter the IP Address of your ESP8266 then press Enter. By default the IP address is .Now you will get the webpage as shown in the image.

This is just the basic work with ESP8266,but you can get more out of it, just be creative and Think out of the Box :)

Thank you.



  • Fandom Contest

    Fandom Contest
  • IoT Challenge

    IoT Challenge
  • Gardening Contest

    Gardening Contest

25 Discussions


Question 8 months ago

I am unable to get this project working. during compilation an error comes up :

in void setup(), "Serial1" was not declared in this scope". I am a newbie and cannot figure out what is happening. When I use the IDE Serial Terminal mode what is printed is a series of AT, error, series of AT+CWMODE=3, error, etc. I am completely lost. Can anyone suggest what I should do. Thanks.


Question 11 months ago on Step 5

Hey! Iam using arduino UNO for this but getting errors like espcomm_sync failed,espcomm_open failed, espcomm_upload_mem failed


Question 1 year ago

void Send()


webpage = "<h1>Welcome to Circuit Digest</h1><body bgcolor=f0f0f0>";






webpage ="<a href=""; // <-- arduino uno can't comiple

webpage+="\">Click Here for .....</a>"; // error before http is [ " ]

sendwebdata(webpage); // exzample works well just 1 small error



Thanks for lesson to Author it help me a lot to start with esp8266.


1 year ago

Ok, thanks for this very complete tutorial.

I try to obtain POST data from the calling request, is that possible ? How to do this ?


Question 1 year ago

hello world if i want to use this vode for iot project for home automation how to turn on tv fan light relay using switch button in iot if code is available plz share that part


Question 1 year ago on Step 5

What are the changes need to make while using UNO R3 in this project both in circuit and code ?


1 year ago

With Arduino UNO and ESP8266, how to connect camera that should continuously monitor and analyze image via code and send images to webpage via wi-fi whenever required


1 year ago

hey Joyson96,

thanks for the help, got it working! but I can't get the temperature value refreshed every, lets say 5 seconds. have you tried such thing?


1 year ago

Hi, Works perfectly, thanks!

how can I do to send the values that I got from "pin=" in the webserver to another php page, like "" the number that I got in the web server?


1 year ago

I've made it but i want to upload value to web server so can you help me


2 years ago


I am trying to use ESP8266 with Arduino UNO R3. But I can’t sent the AT command as I am getting loop of FatalException(0) as below as soon as I connect to ESP8266 module: (Can’t make out what does this mean)

Fatal exception 0(IllegalInstructionCause):
epc1=0x40201364, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000 ets
Jan 8 2013,rst cause:2,
boot mode:(3,6) load 0x40100000,
len 1856,
room 16 tail 0
chksum 0x63
load 0x3ffe8000,
len 776,
room 8 tail 0
chksum 0x02
load 0x3ffe8310,
len 552,
room 8 tail 0
chksum 0x79
csum 0x79
2nd boot version : 1.5
SPI Speed : 40MHz
SPI Mode : DIO
SPI Flash Size & Map: 8Mbit(512KB+512KB)
jump to run
user1 @ 1000

Following are my ESP8266 connection details:
1. Vcc – 3.3v external supply (GND connected to GND of 3.3v and GND of 5v of Arduino)
2. CH_PD – 3.3v
3. GPIO0 – Tried keeping 3.3v (Same Error)
disconnected (Same Error)
GND (Same Error)–(Just tried. I know this will be the programming mode)
4. Rx – Rx of Arduino UNO via voltage divider
5. Tx – Tx of Arduino
(Tried with exchanging Rx and TX)
6. RST – Disconnected (Same Error)
3.3v (Same Error)
(Used the GND pulse to reset the ESP8266)

I also tried connecting RESET of Arduino UNO to GND with no success ;( .

I checked the output with all the baud rates keeping “Both NL & CR” option selected. For baud rate 115200 I am getting the above exception. For rest it showing some garbage values.

I have uploaded bareMinimum example in the Arduino UNO to start with.

Any suggestion, pointer will be really appreciated.

Is my module damaged? Never used it with anything other than 3.3v though.


2 replies

Reply 2 years ago

try this..

Rx of ESP to Tx of Arduino

Tx of ESP to Rx of Arduino

if there is no use of ATmega328 then take it out and try.


Reply 2 years ago

Thanks for your reply.

I tried exchanging Rx and Tx but no success.

Sorry for dumb questions! What do you mean by take out ATmega328? Do i need to desolder it? I tried connecting RESET of Arduino to GND so that Arduino will act as just path. Is it same what do u mean?



2 years ago


Read Datasheet and inputting link with and without <>. Still getting either link not valid and error, or error report. What do I enter and where? tried all links in close command, but have put it in send command also. Have 8 to 10 hours trying to get this to work. Going mad!!!!!

3 replies

Reply 2 years ago

sorry, but i can't exactly get your problem. please upload your sketch. which board are you using???


Reply 2 years ago

Am using UNO. Possibly have found a problem at my end. Tried another sketch and see a report there was a problem downloading library, and it refers to joyson. Will reload, and let you know what happens.


Reply 2 years ago


Have sorted it out at last. Brilliant!!! Slowed down ESP baud to 9600, as UNO cannot keep up with ESP speed. After find ("+IPD,") I changed delay to 10000 and it worked. Tested this and works fine at delay 3000, but not at 2000.

Incidentally, in your description you state changes in #include for the UNO. I have entered #include<SoftwareSerial.h>. I assume this is correct. If so you may want to update your description. I noticed this early on, so was not the problem I had getting this running.

Could this be altered to auto-refresh? Maybe I can do something on my Tablet to do this. I will try to figure this out myself. Thanks for all the responses. Love It, Love It, Love It.



2 years ago


Sorry to bother you again.

How do I find / determine / calculate the connectionID


2 years ago

Thanks for the response. New to this. Trying to enter SSID and password for over 2 hours, but no success. What is the correct way to do it & where in the sketch does it go? Going Mad at attempting to do it.!!

1 reply

Reply 2 years ago

There are specific commands for entering these, those commands will be given in data sheet.U have to enter these under Void Setup().