logo elektroda
logo elektroda
X
logo elektroda

ESP8266 Data Transfer to XAMPP Server Database Using WiFiESP.h Library

Rafal73t 1149 8
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18513162
    Rafal73t
    Level 6  
    Hi, I can't seem to get past the problem of transferring data from the Arduino UNO to the Database of the local XAMPP server (a seemingly trite topic but one I can't manage for the hell of it). I want to use the WiFiESP.h library. The following code connects my chip to the WiFi network (the screen displays the network status) and then nothing .... it disconnects me. My goal is to add a single digit to a specific database table using a PHP script. The script certainly works correctly, because from the browser level I can add any digit (e.g. 14) by typing: http://localhost/PMS5003/PMS5003.php?T=14 from the Arduino program level I cannot. In order not to use two serial ports for displaying messages I use a TFT display. The ESP8266 runs on the Serial Port of the Arduino at 115200.
    A warm request for your help!

    Code: C / C++
    Log in, to see the code
    .
    Do you have a problem with Arduino? Ask question. Visit our forum Arduino.
  • ADVERTISEMENT
  • #2 18513344
    khoam
    Level 42  
    Rafal73t wrote:
    From within the arduino program, I can't.

    How is the WiFi client on the Uno supposed to know what the IP address is for 'localhost' on your computer?
  • ADVERTISEMENT
  • #3 18513358
    Rafal73t
    Level 6  
    khoam wrote:
    How is the Uno's WiFi client supposed to know what the IP address is for the 'localhost' on your computer?
    .
    Well yes ... good question. That is, I need to specify the IP of my computer on which I have XAMPP installed ? So for example char server[] = "192.168.0.20" ? If so where to specify localhost ? Do you add to the GET command ????
  • ADVERTISEMENT
  • #4 18513371
    khoam
    Level 42  
    Rafal73t wrote:
    So for example char server[] = "192.168.0.20"?
    .
    Not really. You need to use another version of connect(IPAddress ip, uint16_t port), where ip is the IP address of the computer you want to connect to. The variable is created like this (example):
    Code: C / C++
    Log in, to see the code
    .
  • ADVERTISEMENT
  • #5 18513373
    suser222
    Level 24  
    Localhost as the name suggests on a local machine. If you want to connect from another computer/device then you must replace localhost with the IP address of the computer on which the server is running.
  • #6 18531593
    Rafal73t
    Level 6  
    Dear all, I haven't managed with any libraries despite the hints. I don't have an Ethernet overlay for the Arduino but a bare ESP8266 -01 module. Anyway, I got through the AT commands and so far I have all the command responses correct including sending data - but the problem is one BASE DOES NOT UPDATE .
    Code: C / C++
    Log in, to see the code
    .

    file PHP is probably also OK because I can add records in the database from the browser , e.g.: serverXXX.nazwa.pl/PMS5003.php?T=20

    Code: PHP
    Log in, to see the code
    .
  • #7 18531653
    khoam
    Level 42  
    Rafal73t wrote:
    so far I have all the command responses correct including sending data
    .
    Where in this code above are you sending data from the ESP to the server?
  • #8 18532157
    Rafal73t
    Level 6  
    We've succeeded :) <br> We've succeeded.

    In the end, the problem was in the space between the GET command and the HTTP/1.1 expression. The changes I made were the full address(including http://), removing unnecessary spaces from the command and replacing HTTP/1.1 with HTTP/1.0. The AT+CIPSEND command must have a value 2 longer than the actual length of the GET expression....
    The final upload looks like this:
    Code: C / C++
    Log in, to see the code
    .
    Many thanks Khoam for your help
  • #9 18533027
    khoam
    Level 42  
    Rafal73t wrote:
    The AT+CIPSEND command must have a value 2 greater than the actual length of the GET statement...
    .
    The Serial.println() command adds line termination characters at the end.

Topic summary

The discussion revolves around the challenge of transferring data from an Arduino UNO to a local XAMPP server database using the WiFiESP.h library. The user initially faced issues with connectivity and data transmission, specifically when trying to send a GET request to a PHP script on the server. Responses highlighted the need to replace 'localhost' with the actual IP address of the server and to ensure proper formatting of the GET command. The user eventually resolved the issue by correcting the spacing in the GET command and adjusting the HTTP version from 1.1 to 1.0, as well as ensuring the AT+CIPSEND command length was accurate. The final successful command included the full URL and proper formatting, allowing data to be sent correctly.
Summary generated by the language model.
ADVERTISEMENT