Project tutorial

ESP8266 To Your Website

Sending a few bytes of data from Arduino to your website.

  • 6,757 views
  • 4 comments
  • 6 respects

Components and supplies

About this project

Connecting to internet using ESP8266

This project can be useful for you if you have a website that you can use to keep the data. The common way is to set the ESP8266 to server mode and connect to it from the internet by entering your router IP address in a browser. My internet provider don't let me do that by changing my IP address each time I enter the IP address. In this project the ESP is set to station mode and it sends several bytes of data to my website. I can browse at the data from the internet by logging to a page in my website. The idea is taken from here: https://thingspeak.com/ The idea is to request a file and to add the data using URL parameters. The PHP file records the data on another file which I named a2.php. I added a suggestion for a PHP script http://mfprojects.co.uk/wifi.php . To see the data log to page http://mfprojects.co.uk/a2.php .

In the code enter your SSID and PASSWORD of your router. Also change the name of my website to yours. You can use my website to test your project, http://mfprojects.co.uk/a2.php but remember that if more than one person is using my website at the same time they are likely to read each others data.

The internal connections of the Arduino show the serial data coming out of the Atmega only. Monitoring the data both ways will give better view. One way to achieve that is by connecting the Tx output of the ESP to the Rx input of a serial to USB converter module and setting the Serial Monitor of the Arduino IDE to read the port of that USB.

A disadvantage of this system is that you can't access the ESP directly from a browser on the internet. This code is set to transfer the data to the website once every 60 seconds.

Changes to the code can allow for transfer of more data and also data transfer both ways.

Code

wifiC/C++
  int analog=0;
  String msg, host, d1;
 
void setup()
{
  pinMode(3,INPUT_PULLUP);
  Serial.begin(9600);
  
  Serial.println("AT+RST"); //reset wifi
  delay(2000);
  Serial.println("AT+CWMODE=1");  //station mode
  delay(1000);
   //connect to AP, ADD YOUR ROUTER SSID and PASSWORD
  Serial.println("AT+CWJAP=\"SSID\",\"PASSWORD\"");
  delay(10000);
  
}
 
void loop()
{
 
    analog = analogRead(A0);
    if(digitalRead(3)) {d1 = "OFF";} else {d1 = "ON";}

      //GET request of a website page a1.php 
    msg = "GET /a1.php?v1=" + String(highByte(analog)) + "&v2=" + String(lowByte(analog)) + "&v3=" + d1 + " HTTP/1.1";
    host = "HOST: mfprojects.co.uk";  //change to your website address
    
    Serial.println("AT+CIPSTART=\"TCP\",\"mfprojects.co.uk\",80");  //change to your website address
    delay(1000);
    Serial.println("AT+CIPSEND=" + String(msg.length() + host.length() + 6));
    delay(1000);
    
    Serial.println(msg);
    Serial.println(host);
    Serial.println("");

    delay(60000);
}

Schematics

Comments

Similar projects you might like

A Microwave Interface for the IKEA Duktig Kids Kitchen

Project showcase by Myles Eftos

  • 1,405 views
  • 8 comments
  • 9 respects

Servo Signals and Characterization

by 3 developers

  • 1,332 views
  • 4 comments
  • 14 respects

Music Adaptive RGB LED with Arduino and Processing

Project in progress by ounane mohamed elfarouk

  • 1,082 views
  • 6 comments
  • 11 respects

Cellular IoT with Blynk & Hologram

by Moheeb Zara

  • 5,230 views
  • 9 comments
  • 19 respects

Monitoring Temperature Remotely with Blynk for Dummies

Project in progress by Cmtelesann

  • 1,307 views
  • 2 comments
  • 5 respects

How to Make a Customizable Punchable Keyboard Button

Project tutorial by Amal Mathew

  • 1,566 views
  • 4 comments
  • 4 respects
Add projectSign up / Login