Need help to upload ESP8266 data to webpage

Discussion in 'The Projects Forum' started by ketancool203, Jan 20, 2016.

  1. ketancool203

    Thread Starter New Member

    Jan 20, 2016
    1
    0
    Hello Guys ,
    Needed help Regarding my IOT based project .
    I have connected a ESP8266 with a MPU6050 sensor and have sending its data to the thingspeak API . But now wanted that i could receive data on my on webpage . please guide me how to do that.
    I am here with high hopes that some will help me, because my projects deadline is near.
    Anyone provide paid services can also contact on below given Email.
    (xxxxxxxxxx@gmail.com)
    Regards
    ketan bhardwaj

    MOD note: Please do not show your e-mail address in posts. Removed e-mail address.
     
    Last edited by a moderator: Jan 20, 2016
  2. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,769
    969
    Do you run your own server?
    Work with Mysql?
    Need logging/graphing?
    php skills?

    There are plenty of examples (google).. did you try any of them?.. If so what problems/issues did you encounter?..
     
  3. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,769
    969
    I'm doing something like this where the data is sent to a php page which grabs the datapoints and shoves them into a mysql database..
    Code (Text):
    1.  
    2. #include <DHT.h>
    3. #include <ESP8266WiFi.h>
    4.  
    5. const char* ssid = "SSID GOES HERE";
    6. const char* password = "SSID PASSWORD GOES HERE";
    7. const char* server = "SERVER GOES HERE";
    8. #define DHTPIN 2 // what pin we're connected to
    9. DHT dht(DHTPIN, DHT22,15);
    10. WiFiClient client;
    11.  
    12. void setup() {  
    13.   pinMode(0, OUTPUT);          
    14.   Serial.begin(115200);
    15.   delay(10);
    16.   dht.begin();
    17.  
    18.   WiFi.begin(ssid, password);
    19.   Serial.println();
    20.   Serial.println();
    21.   Serial.print("Connecting to ");
    22.   Serial.println(ssid);
    23.  
    24.   WiFi.begin(ssid, password);
    25.  
    26.   while (WiFi.status() != WL_CONNECTED) {
    27.     delay(500);
    28.     Serial.print(".");
    29.   }
    30.   Serial.println("");
    31.   Serial.println("WiFi connected");
    32.  
    33.  
    34. }
    35. void loop() {
    36.  
    37.   float h = dht.readHumidity();
    38.   float t = dht.readTemperature(true);
    39.   if (isnan(h) || isnan(t)) {
    40.     Serial.println("Failed to read from DHT sensor!");
    41.     return;
    42.   }
    43.  
    44.      Serial.print("Temperature: ");
    45.      Serial.print(t);
    46.      Serial.print(" degrees F Humidity: ");
    47.      Serial.print(h);
    48.      Serial.println("% send to Server");
    49.   if (client.connect(server,80)) {
    50.  
    51. // We now create a URI for the request
    52.   String url = "/posttemphum.php?temp=";
    53.   url += (String(t));
    54.   url += ("&hum=");
    55.   url += (String(h));
    56.   Serial.print("Requesting URL: ");
    57.   Serial.println(url);
    58.  
    59.   // This will send the request to the server
    60.   client.print(String("GET ") + url + " HTTP/1.1\r\n" +
    61.                "Host: " + server + "\r\n" +
    62.                "Connection: close\r\n\r\n");
    63.      
    64.  
    65.   }
    66.   client.stop();
    67.  
    68.   Serial.println("Waiting...");  
    69.   // delay between updates
    70.   delay(2*60*1000);  //2 minute delay
    71. }
    72.  
     
  4. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,769
    969
    And here is the php code..
    Code (Text):
    1. <?PHP
    2. $con = mysql_connect("localhost","USER","PASSWORD");
    3.  
    4.   if (!$con)
    5.   {
    6.     die('Could not connect: ' . mysql_error());
    7.     return 'Failure';
    8.   }
    9.         if(isset($_GET['temp'])) {$Temp = $_GET["temp"];}
    10.             else {$Temp="100.00";}
    11.         if(isset($_GET['hum'])) {$Hum = $_GET["hum"];}
    12.             else {$Hum="100.00";}
    13.     echo $Temp."</br>";
    14.     echo $Hum;
    15. /*    $ActiontoDB = $_POST["Action"]; */
    16.     $Sensor = "001";
    17.  
    18.   mysql_select_db("joomla", $con);
    19.  
    20.   $query = "INSERT INTO `DATABASE NAME`.`TABLE NAME` (`Sensor`, `Temp`, `Humidity`) VALUES ('$Sensor',
    21.         '$Temp', '$Hum');";
    22.   mysql_query($query);
    23.  
    24.  
    25.   mysql_close($con);
    26.   return '$params(0)-$params(1)-Complete';
    27.  
    28.  
    29.  
    30. ?>
    I just made it too easy for you :)
    Note I used the arduino IDE to program the ESP8266..
    If you need to use AT commands then google will help you..
     
    Last edited: Jan 20, 2016
Loading...