logo elektroda
logo elektroda
X
logo elektroda

[ESP8266-01] ESP8266-01 AT Commands: Sending Data to Local Server via GET Request

piterek-23 1014 9
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 19058967
    piterek-23
    Level 33  
    Hey,
    I need a little help because I'll be honest, I have no idea what I'm doing wrong....
    I want to send data to my local data server using AT commands - while data to the ThingSpeak server "flies" correctly and without any problem, nothing reaches my server :( .

    I do everything in the terminal where I have the ESP-01 connected to my computer using a USB-TTL converter

    When I send data to ThingSpeak I "paste in sequence:
    AT+CIPSTART="TCP","184.106.153.149",80
    AT+CIPSEND=47
    GET /update?api_key=ABCNQOZDP55FYABC&field1=1
    Code: Text
    Log in, to see the code
    .
    and the data goes to the server, so everything is as it should be and without error.
    Now I want to send the data to my server I "paste" it in sequence:
    AT+CIPSTART="TCP","192.168.1.2",80
    AT+CIPSEND=71
    GET /receiver.php?key=1234&id=1&type=temp&value=22&device=ip&name=ABC
    Code: Text
    Log in, to see the code
    .
    and so everything "hangs" until 180 seconds pass (default connection time) or I use AT+CIPCLOSE
    This way the data does not reach my server, but what is interesting is when I paste the command into the browser window:
    Code: Text
    Log in, to see the code
    .
    It all works as expected, everything is correctly executed, the data appears on my server.

    Thank you in advance for your help ;) .
  • ADVERTISEMENT
  • #2 19059323
    khoam
    Level 42  
    piterek-23 wrote:
    and so everything "hangs" until 180 seconds have passed (default connection time) or I use AT+CIPCLOSE
    .
    And if, before AT+CIPCLOSE, you use the command AT+CIPBUFSTATUS (several times during that 180 seconds), what shows up on the terminal?
  • ADVERTISEMENT
  • #3 19059337
    piterek-23
    Level 33  
    I receive: 1,0,0,2920,8
    What does this mean? ;)
  • #4 19059358
    khoam
    Level 42  
    According to the documentation, as below :) Execute this AT+CIPBUFSTATUS a few times and see if anything changes.

    [ESP8266-01] ESP8266-01 AT Commands: Sending Data to Local Server via GET Request
  • #5 19059382
    piterek-23
    Level 33  
    khoam wrote:
    Run this AT+CIPBUFSTATUS a few times and see if anything changes.
    .
    I run this command repeatedly (as you told me to do before) and each time I get the same thing, nothing changes.

    So informative:
    Code: Text
    Log in, to see the code
    .
  • ADVERTISEMENT
  • #6 19059479
    khoam
    Level 42  
    In my opinion, ESP doesn't receive confirmation (or doesn't understand it) of the transmission of the whole data packet from your server as is the case with ThingSpeak:
    Code: Bash
    Log in, to see the code
    ESP waits and does not get it.
  • ADVERTISEMENT
  • #7 19059494
    piterek-23
    Level 33  
    Or is there some other way to transfer data?
    The strange thing is that via the browser everything works as expected, but via ESP it doesn't want to work for me :( .

    <ciach>
    Now I still did something like this, that in the program "Hercules", in the tab "TCP Client" I connected to the server and after pasting my GET command I get:
    Code: Text
    Log in, to see the code
    .
    So I guess the server doesn't understand what I'm sending it and closes the connection - that would agree why ESP hangs up, the server closes the connection, and ESP waits for a response, which it doesn't get
  • #8 19059569
    khoam
    Level 42  
    Is the termination of line
    piterek-23 wrote:
    GET /receiver.php?key=1234&id=1&type=temp&value=22&device=ip&name=ABC
    being sent after ?

    piterek-23 wrote:
    That is, the server probably doesn't understand what I'm sending it and closes the connection - that would account for why ESP hangs up, the server closes the connection, and ESP waits for a reply, which it doesn't get
    .
    It looks like this.

    Added after 13 [minutes]:

    piterek-23 wrote:
    GET /receiver.php?key=1234&id=1&type=temp&value=22&device=ip&name=ABC
    .
    Or maybe:
    Code: PHP
    Log in, to see the code
    and you need to increase the buffer size for AT+CIPSEND accordingly.
  • #9 19059682
    kaczakat
    Level 34  
    I used to play around with AT commands to send something from a GSM modem to thinkspeak and the problem broke down into what, what the modem understood as a command, a special character, and what as text, a lot of fiddling with adding " and ".
    Example code to send something from ESP (no AT commands, just code uploaded to ESP) to a network drive with PHP and MySQL:
    Code: C / C++
    Log in, to see the code
    .
    Via AT I did analogy, but all special characters had to be rewritten to be characters rather than commands.
    E.g. :
    Code: C / C++
    Log in, to see the code
    .
    As you can see it's easier to just use the ESP8266 as a uC and skip the Arduino UNO (or if you need the UNO IO then you can send the data via the UART to the ESP), or strong glasses and fun....
    Helpful post? Buy me a coffee.
  • #10 19060140
    piterek-23
    Level 33  
    kaczakat wrote:
    As you can see it's easier to just use the ESP8266 as a uC and skip the Arduino UNO
    .
    I know neither Arduino nor C, I write my programs in Bascom - I use the ESP8266 as a gateway to the world ;) .
    I thought I'd first tinker with the ESP itself to know the whys and hows of these AT commands, but something isn't working for me as you can see. I have now uploaded something like this to the ATmega328P:
    Code: VB.net
    Log in, to see the code
    .
    i... and everything goes ;) .

Topic summary

The discussion revolves around the challenges faced when sending data from an ESP8266-01 module to a local server using AT commands. The user successfully sends data to the ThingSpeak server but encounters issues with their local server, receiving a "400 Bad Request" error. Responses suggest checking the line termination in the GET request and ensuring the correct format, including HTTP/1.1 headers. The importance of confirming data packet transmission and potential buffer size adjustments for AT+CIPSEND are also highlighted. The user shares attempts to troubleshoot the issue, including using a TCP client and modifying the GET request format, ultimately achieving success with a different approach.
Summary generated by the language model.
ADVERTISEMENT