Introduction: Arduino Esp8266 Post Data to Website

Picture of Arduino Esp8266 Post Data to Website

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. It offers a complete and self-contained Wi-Fi networking solution, allowing it to either host the application or to offload all Wi-Fi networking functions from another application processor.When ESP8266 hosts the application, and when it is the only application processor in the device, it is able to boot up directly from an external flash. It has integrated cache to improve the performance of the system in such applications, and to minimize the memory requirements.

For this project We are going to use The Esp8266-01 .

Step 1: What You Will Need ??

Picture of What You Will Need ??

To accomplish this simple yet amazing project you will need a few components that I personally got from mainly thanks to their High-Quality products and also for their Free-shipping WORLDWIDE. I mean who wouldn't like that !! So the list of the components needed is down below:

  • Arduino Uno (you can get the official one or other clones ,same for this project)

Official 8.00 $ :

  • DHT11 Temperature Humidity Sensor Module 2.68 $ :

  • 3X 220 Ohm resistors (Voltage divider, explaination in the circuit diagram below) from your local electronics-shop.
  • A few Male to Female jumper Wires 1.88 $ :

  • A website : 0.00 $

Finally this project won't cost you any higher than 20 $. Isn't That Amazing ?!!

Step 2: Circuit Diagram :

Picture of Circuit Diagram :

This project is based on a very simple Circuit that anyone can do it .

Power Consumption:

First, you need to keep in mind that the Esp8266 runs on 3.3V , connecting it to 5V could work but it is not recommanded.According to its Datasheet,the amperage needed for the Esp8266 to work correctly varies according to its state ( transmitting, receiving, deep sleep ,etc... ), and reaches its highest at around 200 mA while the Arduino's DC Current for 3.3V Pin is Only 50mA,it actually works but you won't get a perfect result.

So, there are plenty of other ways to power the module (using diodes, using Zener diode, voltage regulator). I believe that the best solution is to make an independant 5 to 3.3V power regulator circuit, you will need the following components :

  • LM1117 or LD1117 : A very common and cheap 3.3 V regulator that allows you to convert the 5V power used by the Arduino to the 3.3V needed by the Esp8266 module.
  • A 10 µF capacitor.

Then, when it comes to the TX and RX connections, you have to avoid connecting the TX of the Arduino directly to the RX of the Esp module since that could damage both of them, so two easy solutions you can use to solve this issue. The first one is to use a simple voltage divider with resistors (as in the diagram above) to drop down the 5V voltage from the TX Pin of the Arduino to 3.3 V or you can use a level shifter with a diode, they both do the job correctly and it's up to you to choose either one for your project.

Step 3: Testing the Module :

Picture of Testing the Module :

If this is the First time you use your Esp8266 module, you probably should test it first by sending AT Commands manually to it . You can do that with an FTDI USB to Serial Converter like this one or you can simply use your arduino.

If you're going to use your arduino you have to arrange your connection as in the image above :

Pin 0 Arduino (Rx pin) ---->> Rx Pin Module

Pin 1 Arduino (Tx pin) ---->> Tx Pin Module

And for the power supply use the power regulator circuit as described in the previous step of this article.

Then, you will have to upload into the arduino an empty code means ( void setup() {} void loop () {} ) and open the Serial monitor window to type the commands just remember that newer versions of the esp module use 9600 baudrate while older ones use 57600 or 115200 baud rates. The Esp8266 responds to a few commands called AT Commands, this is a list of the most basic ones to help you get going and you can find more complex ones just google it.

After checking out that your module is working correctly by responding positively to the commands sent you can finally move to the next step and start your HTTP post project.

Step 4: Create a Website First

Picture of Create a Website First

So first we need to create our own website and to do that there are plenty of free domain and hosting websites. I personally chose which sounds pretty much convenient for our simple task.

You can create a free website using their free subdomain service then just follow their instructions and you should receive an email that lists your FTP Username and FTP Password and your website will be fully functional within 24 hours. After you will actually need a software that allows you to send the files (php, HTML , images ...) from your computer to the host servers and to do that I used FileZilla you can download it from here. Before sending any file we need to make a file, so in this example we need to make a php file that we will name httppost.php using NotePad ++ ,which you can download from here, (check the image above for the code and a little explaination).After creating your php server file you are going to actually send that file to the servers that host your website and this is where FileZilla comes in,to accomplish that we first need to establish a connection between your computer and the host servers then you right-click on the file that you wish to send ,in this case esp8266.php, and then transfer.

Step 5: Sending the Data

Picture of Sending the Data

First you need to understand the basics of an HTTP.The Hypertext Transfer Protocol (HTTP) is designed to enable communications between clients and servers.

HTTP works as a request-response protocol between a client and server. A web browser may be the client, and an application on a computer that hosts a web site may be the server. Example: A client (browser) submits an HTTP request to the server; then the server returns a response to the client. The response contains status information about the request and may also contain the requested content. On our example the esp8266 is the client and the server that is hosting our website is the server.

So performing an HTTP Post request has to be under a certain form:

POST /esppost.php HTTP/1.0


Accept: */*

Content-Length: "name1=value1&name2=value2".Length

Content-Type: application/x-www-form-urlencoded


You can find more explaination and informations in the Arduino sketch below.After uploading the Sketch , wait for a few seconds then refresh you webpage.

#include "SoftwareSerial.h"
String ssid ="yourSSID";

String password="yourPassword";

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

String data;

String server = "yourServer"; //

String uri = "yourURI";// our example is /esppost.php

int DHpin = 8;//sensor pin

byte dat [5];

String temp ,hum;

void setup() {

pinMode (DHpin, OUTPUT);






//reset the esp8266 module

void reset() {



if(esp.find("OK") ) Serial.println("Module Reset");


//connect to your wifi network

void connectWifi() {

String cmd = "AT+CWJAP=\"" +ssid+"\",\"" + password + "\"";



if(esp.find("OK")) {



else {


Serial.println("Cannot connect to wifi"); }


byte read_data () {

byte data;

for (int i = 0; i < 8; i ++) {

if (digitalRead (DHpin) == LOW) {

while (digitalRead (DHpin) == LOW); // wait for 50us

delayMicroseconds (30); // determine the duration of the high level to determine the data is '0 'or '1'

if (digitalRead (DHpin) == HIGH)

data |= (1 << (7-i)); // high front and low in the post

while (digitalRead (DHpin) == HIGH);

// data '1 ', wait for the next one receiver


} return data; }

void start_test () {

digitalWrite (DHpin, LOW); // bus down, send start signal

delay (30); // delay greater than 18ms, so DHT11 start signal can be detected

digitalWrite (DHpin, HIGH);

delayMicroseconds (40); // Wait for DHT11 response

pinMode (DHpin, INPUT);

while (digitalRead (DHpin) == HIGH);

delayMicroseconds (80);

// DHT11 response, pulled the bus 80us

if (digitalRead (DHpin) == LOW);

delayMicroseconds (80);

// DHT11 80us after the bus pulled to start sending data

for (int i = 0; i < 4; i ++)

// receive temperature and humidity data, the parity bit is not considered

dat[i] = read_data ();

pinMode (DHpin, OUTPUT);

digitalWrite (DHpin, HIGH);

// send data once after releasing the bus, wait for the host to open the next Start signal


void loop () {

start_test ();

// convert the bit data to string form

hum = String(dat[0]);

temp= String(dat[2]);

data = "temperature=" + temp + "&humidity=" + hum;// data sent must be under this form //name1=value1&name2=value2.




void httppost () {

esp.println("AT+CIPSTART=\"TCP\",\"" + server + "\",80");//start a TCP connection.

if( esp.find("OK")) {

Serial.println("TCP connection ready");

} delay(1000);

String postRequest =

"POST " + uri + " HTTP/1.0\r\n" +

"Host: " + server + "\r\n" +

"Accept: *" + "/" + "*\r\n" +

"Content-Length: " + data.length() + "\r\n" +

"Content-Type: application/x-www-form-urlencoded\r\n" +

"\r\n" + data;

String sendCmd = "AT+CIPSEND=";//determine the number of caracters to be sent.


esp.println(postRequest.length() );


if(esp.find(">")) { Serial.println("Sending.."); esp.print(postRequest);

if( esp.find("SEND OK")) { Serial.println("Packet sent");

while (esp.available()) {

String tmpResp = esp.readString();



// close the connection




If everything went well you should see a result similar to the image above if not unplug then replug your Arduino and wait for a few seconds.

Step 6: You Can Go Even Further

Picture of You Can Go Even Further

This isn't the end of this project ,there are plenty of other stuff you can do like for example I made an Android App that will display the data instead of displaying it on a website which is a little bit boring. So to do so the app send an HTTP Get request to the website, retrieve its HTML code as string then get both the Temperature and Humidity.You can find more explaination about HTTP POST and GET from an Android App in this Instructables article that I made a while ago .You can download the App's source code down below.

The ESP8266 is just a very awesome device !! . you can perform a lot of other stuff with it like (Home automation system , Mesh network, IP cameras streaming,etc...)

Thanks for reading my article, if you have any questions about anything just leave them in the comment section below or email me at : :D :D :D


ngocminh.pham (author)2017-10-22

thanks alot

Mo_Spec (author)2017-09-16

Just wanted to say thanks for the tutorial, i had been looking for an easy to follow example of using ESP8266. And this was perfect as it went beyond just using the serial monitor but the basic of a web page. Mine worked perfectly, i haven't yet tried making the adroid app, which is next on my list.


SyedFaisal (author)Mo_Spec2017-10-19

Hi Mo_Spec did you do this project? please share your shematics and code if possible, my data is not sending, TCP conn. is ready but further it does not work

VrT2 (author)2017-10-04

Great tutorial. Can you please specify which wire connect to which wire?

the Image isn't that clear :( Thank you !!

RishabhL (author)2017-08-08

Can you help me?

My esp unable to connect to my hotspot. It shows Module Reset only on serial monitor. Then not connecting to network.

sspence (author)2017-06-21

Why did you use an Arduino? Why not the esp8266 native programmed with the Arduino IDE?

El CrackT (author)2017-04-27

Hi :) I have problem with function httppost () in this line:
if(esp.find("SEND OK")). ESP don't find this command....

JorluiQ (author)El CrackT2017-05-12

Hi, did you solve it?, I have the same problem, my esp8266 doesn't recognize the commands I send it .

El CrackT (author)JorluiQ2017-05-13

Hi :) Yes I solved this problem. I will answer you later because now I don't enough time.

JorluiQ (author)El CrackT2017-05-13

So, did you manage to post data in your website?, because I'm having serious problems at it. I created my html page and uploaded it to 000webhost, then I uploaded the esppost.php. but when i want to open it, I just see errors like these:

Notice: Undefined index: temperature in /storage/h11/541/1648541/public_html/esp.php on line 2

Notice: Undefined index: humidity in /storage/h11/541/1648541/public_html/esp.php on line 3

Notice: Undefined variable: dist in /storage/h11/541/1648541/public_html/esp.php on line 4

what do you think I am doing wrong?

(sorry for the bad english)


El CrackT (author)JorluiQ2017-05-14

Your english is good, I understood all :) Problem is to send GET/POST by AT commands from Arduino to website using Arduino IDE, because I read somewhere that Arduino IDE have problem with coding \r\n. I searched information on the internet how can I solve this problem but I didin't find. You can use program Realterm( if you want use AT commands. If you want write program you can use other code. See on this tutorial: I used this code to program my ESP module, and Serial.write() function on my Arduino NANO to send data to my ESP, and Serial.readString() on my ESP to receive incoming data and this work perfect.

mariaaDum12 (author)El CrackT2017-06-02


So I understood you were able to make this work. Can you give me the source code. Tanks a lot!

Lafeve (author)2017-05-07

hi. I can't transmit data to my server. Can you help me?

Cannot connect to wifi
TCP connection ready
Packet sent

+IPD,087:HTTP/1.0 400 Bad repuest
Cache,Control: no,cache
:nt<uo vuK

TCP connection ready
TCP connection ready
TCP connection ready
TCP connection ready
TCP connection ready
TCP connection ready
TCP connection ready
TCP connection ready
Packet sent

+IPD,187:HTTP/1.0 400 Bad request
Cache-Contsol: no-cachd


TCP connection ready
TCP connection ready

TCP connection ready


PedroC16 (author)Lafeve2017-05-27

Did you fix the "+IPD,424:HTTP/1.1 400 Bad Request" ?


mik3l (author)Lafeve2017-05-12

I have the same trouble :(

Someone can help?

PedroC16 (author)2017-05-27

Thanks for the tutorial, it looks great but, I have a problem on the server/web side...

The esp8266 is working fine however I am just getting the HTTP ERROR 500 on the webpage...

Could somebody please post what files do I have to have to put webserver??

I have: esppost.php and index.html... :(

I got this from the serial window:

+IPD,424:HTTP/1.1 400 Bad Request

Date: Sat, 27 May 2017 21:31:23 GMT

Content-Type: text/html

Content-Length: 166

Connection: close

Server: awex

X-Xss-Protection: 1; mode=block

X-Content-Type-Options: nosniff

X-Request-ID: 2a264c11797bc074ddc91b2f83b2964b


<head><title>400 Bad Request</title></head>

<body bgcolor="white">

<center><h1>400 Bad Request</h1></center>





AhmedD43 (author)2017-05-17


thank you for the post

but i want to show content of page without sending anythink

and after light led

how can i do it ?can you help me please?

JorluiQ (author)2017-05-12

hi, I have a problem, my esp8266 doesn't recognize the commands I send it, for example in the part of "connectWifi()" my program stays in an infinite cycle. I previously proved the module uploading an empty code and it was working correctly, but when I use the library <SoftwareSerial.h> and try to send commands like this "esp.println("AT+RST")" the module doesn't respond.

(sorry for the bad english)

Thanks in advance.

aybdz (author)2017-05-06

hi its a great one ,but i need your hlep i need to recive data from the webpage can you hlep plz ?

Lafeve (author)aybdz2017-05-08

Hi. You can do like this :

1) Create a table in your data base. Name it "aduinotest" (for example). add 2 columns named : "data" and "date"

2) Create a php file in your FTP. Name it "esppost.php" (for example). Insert the code below in this file :


$data = $_POST['data'];
$time = date("Y-m-d H:i:s");


mysql_query("INSERT INTO arduinotest VALUES ('$data', '$time')");


sorry for my poor English

aybdz (author)Lafeve2017-05-08

hi thanks , but i allready did that but i want to send from the data base to arduino and for your english i have a bad english too ^^ and really thanks :)

oum_le_dauphin (author)2016-05-26

Thanks ! :D

Works perfectly, i managed to send my data to a serverweb host with a raspberry.

My futur step will be to fill a sql database.

El CrackT (author)oum_le_dauphin2017-04-25

Nice :) I have problem with function httppost(). I Send AT+CIPSTART, and ESP don't find "OK". Could you show this part of code ?

El CrackT (author)El CrackT2017-04-25

I solved problem ! AT+CIPSTART command need four arguments: id, type, address, port. In this sketch author used only three arguments so this doesn't work.

thuan.vuvan.718 (author)2016-09-20

I can't connect to my wifi. Serial monitor always display "Cannot connect to wifi" although ssid and pasword is correct.

EhabS11 (author)thuan.vuvan.7182017-01-25

did you solved it?... because I have the same problem!

El CrackT (author)EhabS112017-04-25

You must use also this command before AT+CWJAP


Shine_Santhosh (author)2016-10-16

I wa ssearching for the same thing. Thank you! My blessings . Do you live in India?

RanbeerS1 (author)Shine_Santhosh2016-10-24

I have done many projects with this module and controlled with PIC18F controller, very fast response with home network. If you are planning with it, contact me.

AbhishekB70 (author)RanbeerS12016-11-11

hw can we contact you sir ?

RanbeerS1 (author)AbhishekB702017-04-08

I am always hare

AnilK116 (author)RanbeerS12016-10-31

Mr. Ranbeer did u made controlling devices from website through local network or cloud network???

RanbeerS1 (author)AnilK1162016-11-01


The html file send by my microcontroller and you can access with IP address from anyware.

Shine_Santhosh (author)RanbeerS12016-11-02

that's cool. do the uc has enough memory to hold so much css

RanbeerS1 (author)Shine_Santhosh2016-11-02

The html file size is 6kb and my controller have 32kb.

Shine_Santhosh (author)AnilK1162016-10-31

I think it's on a local network

MirceaN (author)RanbeerS12016-10-29

you use modbus tcp protocol?

RanbeerS1 (author)MirceaN2016-11-01

I am not using modbus TCP/IP, it is just a html coding. But using modbus RTU slave protocol for connect to other devices such as HMI.

Shine_Santhosh (author)RanbeerS12016-10-27

hey buddy. Nice layout of the webpage. could you please send me the source code?

RanbeerS1 (author)Shine_Santhosh2016-10-27

Send a massage on

Shine_Santhosh (author)RanbeerS12016-10-31

I've contacted you on your email. But u didn't seem to see it. could you please send it to

TariqA37 (author)Shine_Santhosh2016-10-22

can you help me out , please ?!

Shine_Santhosh (author)TariqA372016-10-23

How can I help you?

TariqA37 (author)Shine_Santhosh2016-10-29

can u explain how to connec between my computer and the host servers ? + in the code he asked about the "yourServer" , is that my website domain ?

Shine_Santhosh (author)TariqA372016-10-31

yes. If you use an external hosting give domain or else I address

Muhammad AriffM (author)2017-03-26

String sendCmd = "AT+CIPSEND=";//determine the number of caracters to be sent. how can i determine how many character send?

rmariz63 (author)Muhammad AriffM2017-03-28

String cipSend = "AT+CIPSEND=";

cipSend += connectionId;

cipSend += ",";

cipSend += webpage.length(); // <<<<<<< webpage is a string

cipSend += "\r\n";

Muhammad AriffM (author)rmariz632017-03-30

i still new in arduino..webpage.length(); mean url? i am sory.. i didnt understand?

hemanth kumar reddy (author)2017-03-14

Can you plz look at this

small help thanks

About This Instructable




More by Khalilm:Arduino Esp8266 Post Data to WebsiteArduino + Android POV Display
Add instructable to: