Need help to upload ESP8266 data to webpage

Thread Starter

ketancool203

Joined Jan 20, 2016
1
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:

mcgyvr

Joined Oct 15, 2009
5,394
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?..
 

mcgyvr

Joined Oct 15, 2009
5,394
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:
#include <DHT.h>
#include <ESP8266WiFi.h>

const char* ssid = "SSID GOES HERE";
const char* password = "SSID PASSWORD GOES HERE";
const char* server = "SERVER GOES HERE";
#define DHTPIN 2 // what pin we're connected to
DHT dht(DHTPIN, DHT22,15);
WiFiClient client;
  
void setup() {   
  pinMode(0, OUTPUT);           
  Serial.begin(115200);
  delay(10);
  dht.begin();
 
  WiFi.begin(ssid, password);
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  
  WiFi.begin(ssid, password);
  
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
 
 
}
void loop() {
  
  float h = dht.readHumidity();
  float t = dht.readTemperature(true);
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

     Serial.print("Temperature: ");
     Serial.print(t);
     Serial.print(" degrees F Humidity: ");
     Serial.print(h);
     Serial.println("% send to Server");
  if (client.connect(server,80)) { 
  
// We now create a URI for the request
  String url = "/posttemphum.php?temp=";
  url += (String(t));
  url += ("&hum=");
  url += (String(h));
  Serial.print("Requesting URL: ");
  Serial.println(url);
 
  // This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + server + "\r\n" +
               "Connection: close\r\n\r\n");
      
  
  }
  client.stop();
  
  Serial.println("Waiting...");   
  // delay between updates
  delay(2*60*1000);  //2 minute delay
}
 

mcgyvr

Joined Oct 15, 2009
5,394
And here is the php code..
Code:
<?PHP
$con = mysql_connect("localhost","USER","PASSWORD");

  if (!$con)
  {
    die('Could not connect: ' . mysql_error());
    return 'Failure';
  }
        if(isset($_GET['temp'])) {$Temp = $_GET["temp"];}
            else {$Temp="100.00";}
        if(isset($_GET['hum'])) {$Hum = $_GET["hum"];}
            else {$Hum="100.00";}
    echo $Temp."</br>";
    echo $Hum;
/*    $ActiontoDB = $_POST["Action"]; */
    $Sensor = "001";
  
  mysql_select_db("joomla", $con);

  $query = "INSERT INTO `DATABASE NAME`.`TABLE NAME` (`Sensor`, `Temp`, `Humidity`) VALUES ('$Sensor',
        '$Temp', '$Hum');";
  mysql_query($query);


  mysql_close($con);
  return '$params(0)-$params(1)-Complete';



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