Projecter
Published

ESP8266 To Your Website

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

BeginnerFull instructions provided14,447
ESP8266 To Your Website

Things used in this project

Story

Read more

Schematics

wifi

Code

wifi

C/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: moty22.co.uk";  //change to your website address
    
    Serial.println("AT+CIPSTART=\"TCP\",\"moty22.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);
}

Credits

Projecter

Projecter

4 projects • 12 followers

Comments