logo elektroda
logo elektroda
X
logo elektroda

How do I configure the ESP8266 to send data to a free server?

endju999 1947 9
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 17277038
    endju999
    Level 4  
    Hello, I would like to set up a website, hosted on some free server, to which I upload measurements from time to time.
    The problem is that I don't know how to go about it. I have no idea how to make the server communicate with the esp. Could someone please describe the whole procedure in a nutshell so that I understand the outline and know which languages and which programs to use. Thanks in advance.
  • ADVERTISEMENT
  • Helpful post
    #2 17277234
    stiscorpion
    Level 10  
    My layman's version is:
    On the server make a PHP file with reading data from the url GET read.php
    And on the esp write a script that every e.g. 5 min will run this file http://bubu . Host. Pl/czytam.php?a1=12.30&a2=Celsjusza&a3=12pm

    And if it works for you, switch to the POST method in PHP because it's worth it.

    cya
  • ADVERTISEMENT
  • #3 17290259
    endju999
    Level 4  
    Thanks a lot for the suggestions. I have taken to learning php. I downloaded the XAMPP package, created my database there.
    I would like to add data to the database in the browser field by typing http://localhost/test1/czytaj.php?temp=100. This is not functioning as I would like. I get the following errors:
    Notice: Undefined index: temperature in C:\xampp\htdocs\test.php on line 3


    Thanks in advance for any hints.

    Code: PHP
    Log in, to see the code
    .
  • ADVERTISEMENT
  • #4 17290841
    krzbor
    Level 27  
    In the question you wrote "temp=100", and on line 3 $_GET['temperature'] - decide whether your parameter is "temp" or "temperature"
  • #5 17290878
    endju999
    Level 4  
    Thanks for your feedback, I have corrected it. Now I'm struggling with the error :
    Warning: mysqli_query(): Empty query in C:xampphtdocs.php on line 13

    I have no idea how to solve this.
  • Helpful post
    #6 17291026
    krzbor
    Level 27  
    Type "php mysql" into google and look at examples. After all, what's in the code doesn't make sense - the $add variable encapsulates the result of mysqli_query, and then becomes a parameter to mysqli_query itself. At the end of php you have the script closing twice (the ?> characters). If your code contains only php, then don't use a closure. It's easy to get whitespace characters behind it, which often causes additional problems.
  • ADVERTISEMENT
  • #7 17291615
    endju999
    Level 4  
    My programme is a modification of one of the examples just given. I have corrected everything works correctly. I am still wondering if it is possible to send data from esp to my localhost, apache server if everything is done through "one router".
  • #8 17291744
    krzbor
    Level 27  
    endju999 wrote:
    I'm still wondering if it's possible on my localhost, Apache server to send the data from esp
    Write what this is about because it's simply incomprehensible.
  • #9 17292151
    endju999
    Level 4  
    I am using the XAMPP package on my computer, which consists of an Apache server and a mysql database. I am wondering if I can with the help of get/post using esp8266 provide data to the mysql database, located locally on my computer.
  • #10 17292407
    krzbor
    Level 27  
    Using ESP and a GET or POST request, you can call your PHP script to write something to the database. See if you have port 80 on your computer unblocked on the firewall for incoming connections.

Topic summary

The discussion addresses configuring an ESP8266 module to send measurement data to a free web server. The recommended approach involves creating a PHP script on the server (e.g., read.php) that accepts data via HTTP GET or POST requests. The ESP8266 runs a script that periodically calls this PHP endpoint with sensor data as URL parameters. Transitioning from GET to POST is advised for better practice. For local testing, the XAMPP package (Apache server and MySQL database) can be used to host PHP scripts and manage databases. Common issues include mismatched parameter names in the URL and PHP script, and incorrect use of mysqli_query functions. It is possible to send data from the ESP8266 to a local server behind the same router, provided the server's port (usually 80) is accessible and not blocked by a firewall. The PHP script should correctly handle incoming parameters and insert data into the MySQL database. Proper PHP syntax and avoiding redundant mysqli_query calls are essential for functionality.
Summary generated by the language model.
ADVERTISEMENT