Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By hunterwc
#60597 Hi :)
Is there someone who can help me and show me how i can receive data for database to esp, because i need this date in arduino sketch. I can send data to database, and this is my code in php:
Code: Select all<?php

$wartosc1 = $_GET['temperatura'];
$wartosc = $_GET['wilgotnosc'];

$connect = mysqli_connect("localhost","root","szynszyle","food") or die("blad polaczenia z baza danych");
 
if($wartosc!='')
{

$dodaj=mysqli_query($connect,"INSERT INTO device_values (device_id,temp_level,humidity_level) VALUES ('100','$wartosc1','$wartosc')");
echo "<h1>THE DATA HAS BEEN SEND!!</h1>";

mysqli_close($connect);
}
 
?>


and from arduino ide:

Code: Select all  String url = "http://localhost/food/conec.php?temperatura="+String(t)+"&wilgotnosc="+String(h);


  Serial.print("Wysylam dane na serwer: ");
  Serial.println(url);

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + String(adresSerwera) + "\r\n" +
               "Connection: close\r\n" +
               "Content-Length: 0\r\n" +
               "\r\n");


And this works fine, but how to receive date?I will be very grateful for help. :)
User avatar
By martinayotte
#60601 If you wish to track the insert date/time in your database, no need to add that in the ESP <-> PHP server transaction, simply use MySQL "NOW()" to insert current DATETIME into a table field.
User avatar
By hunterwc
#60604 Actually i need values like maxiumum and minimum temperature, humidity and food form database. This data are in database and i need to receive them on esp, and use in arduino ide skech. :)