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 ??

To accomplish this simple yet amazing project you will need a few components that I personally got from Gearbest.com 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 $ : http://www.gearbest.com/development-boards/pp_4772...

  • 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 :

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 :

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 http://www.gearbest.com/other-accessories/pp_22726... 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

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 https://www.000webhost.com/ 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

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

Host: serverconnect.site88.net

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"; // www.example.com

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

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 : Khalilmerchaoui@gmail.com :D :D :D

<p>Hi :) I have problem with function httppost () in this line:<br>if(esp.find(&quot;SEND OK&quot;)). ESP don't find this command....</p>
<p>Thanks ! :D</p><p>Works perfectly, i managed to send my data to a serverweb host with a raspberry.</p><p>My futur step will be to fill a sql database.</p>
<p>Nice :) I have problem with function httppost(). I Send AT+CIPSTART, and ESP don't find &quot;OK&quot;. Could you show this part of code ?</p>
<p>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.</p>
<p>I can't connect to my wifi. Serial monitor always display &quot;Cannot connect to wifi&quot; although ssid and pasword is correct.</p>
<p>did you solved it?... because I have the same problem!</p>
<p>You must use also this command before AT+CWJAP<br></p><p>AT+CWMODE=1<br>AT+CIPMODE=0<br>AT+CIPMUX=1</p>
I wa ssearching for the same thing. Thank you! My blessings . Do you live in India?
<p>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.</p>
<p>hw can we contact you sir ?</p>
<p>I am always hare</p><p>http://embeddedooo.blogspot.in/2017/02/esp8266-wifi-module.html</p>
<p>Mr. Ranbeer did u made controlling devices from website through local network or cloud network???</p>
<p>No,</p><p>The html file send by my microcontroller and you can access with IP address from anyware.</p>
that's cool. do the uc has enough memory to hold so much css
<p>The html file size is 6kb and my controller have 32kb.</p>
I think it's on a local network
<p>you use modbus tcp protocol?</p>
<p>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.</p>
hey buddy. Nice layout of the webpage. could you please send me the source code?
<p>Send a massage on ra001na@gmail.com</p>
I've contacted you on your email. But u didn't seem to see it. could you please send it to shinesanthosh2000@gmail.com
<p>can you help me out , please ?!</p>
How can I help you?
<p>can u explain how to connec between my computer and the host servers ? + in the code he asked about the &quot;yourServer&quot; , is that my website domain ?</p>
yes. If you use an external hosting give domain or else I address
<p>String sendCmd = &quot;AT+CIPSEND=&quot;;//determine the number of caracters to be sent. how can i determine how many character send?</p>
<p>String cipSend = &quot;AT+CIPSEND=&quot;;</p><p>cipSend += connectionId;</p><p>cipSend += &quot;,&quot;;</p><p>cipSend += webpage.length(); // &lt;&lt;&lt;&lt;&lt;&lt;&lt; webpage is a string</p><p>cipSend += &quot;\r\n&quot;;</p>
<p>i still new in arduino..webpage.length(); mean url? i am sory.. i didnt understand?</p>
<p><a href="https://forum.arduino.cc/index.php?topic=367383.0" rel="nofollow">https://forum.arduino.cc/index.php?topic=367383.0</a></p><p>May be help you.</p>
<p>Can you plz look at this</p><p><a href="https://www.instructables.com/community/security-system-not-responding-after-combinin-ultr/" rel="nofollow">https://www.instructables.com/community/security-s...</a></p><p>small help thanks</p>
<p>Hey,</p><p>I'm stuck in step 4. I did the phpserver part on notepad++ but did not understand this-&gt; &quot;you right-click on the file that you wish to send ,in this case esp8266.php, and then transfer.&quot;</p><p>Also Http post request where should i type that??</p><p>Please help me with this, Thankyou!!</p>
<p>hi guys , still waiting for the edited code for one wire ds18b20, please :(</p>
<p>hi guys , i am using a OneWire ds18b20 waterproof</p><p>what should I change in this code?</p><p>Tried the same code but didn't work !</p><p>thank you</p>
<p>hi, does it really work with the domain name of target server? i think you should use IP adress of webserver ? </p>
<p>it keeps resetting the esp moduel !! :( please help me , </p><p>also, can you explain more about ( your server) in the code ?</p>
have you edited anything other than the variables
<p>NO !</p>
<p>Also, In the code what do you mean by your servier ?</p>
<p>I tried to test ESP8266 but the serial monitor is no responding , I did tried to change the baud rate but still !</p><p>For that i skipped the testing part , then when uploading the program to the Arduino, the serial command is empty , no mistakes but sill the reading of the temperature not uploaded to the website </p>
<p><b>Parse error</b>: syntax error, unexpected 'file_put_contents' (T_STRING) in <b>C:\xampp\htdocs\esppost.php</b> on line <b>8</b></p>
<p>Double check your syntax. There may be problem with double quotes &quot; or semicolon ; or dots . before line 8. </p><p>If you really want a help post here your code, then i will tell you.</p>
Parse error: syntax error, unexpected '$name' (T_VARIABLE) in C:\xampp\htdocs\esppost.php on line 8<br> <br>could anyone help me<br>
<p>What is your ESP8266 firmware version?</p>
<p>hi, i try to send data with esp to a lamp server on my raspi, i using php like this ex:<br></p><p><a href="https://geekytheory.com/internet-de-las-cosas-parte-2-subir-los-datos-a-una-base-de-datos/" rel="nofollow">https://geekytheory.com/internet-de-las-cosas-part...</a></p><p>but i want to do it thru wifi... any suggestion??</p>
<p>how to send image to website using sd card in same program</p>
<p>It is all clear but the part where you speak about HTTP and the website. I am a noob about websites and need a more specific manual about <b>000webhost.com. How do i build the php file exactly, first you talk about the php file and the next step is about:<br></b>POST /esppost.php HTTP/1.0</p><p>Host: serverconnect.site88.net</p><p>Accept: */*</p><p>Content-Length: &quot;name1=value1&amp;name2=value2&quot;.Length</p><p>Content-Type: application/x-www-form-urlencoded</p><p>name1=value1&amp;name2=value2</p><p>what do i do with that?</p>
<p>You need to create a new notepad file and write exactly what is written in the image above then save it as a php file under the name &quot;esppost&quot; then you can check a tutorial on youtube on how to use Filezilla to send files to the server that is hosting your website.And you should be good to go</p>
<p>please provide html for same .... thanxx</p>
<p>what about the html is it auto created or do we need to create one and feel up something into it?</p>
<p>How do i exactly have to replace the ssid an the password? I've tryed many things but none of them work</p>

About This Instructable




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