0

I'm using an Arduino Uno to send HTTP requests to my local webserver. To communicate to the ESP8266 I created a SoftwareSerial which is set to a baud rate of 9600.

Whenever I send a HTTP request, the request looks like the following:

    192.168.2.132 - - [22/Dec/2017:12:22:57 +0100] "TP/1.1" 400 173 "-" "-"
    192.168.2.132 - - [22/Dec/2017:12:23:38 +0100] "z\x02BQQA\xBD1.1" 400 173 "-" "-"
    192.168.2.132 - - [22/Dec/2017:12:23:56 +0100] "z\x02BQQA\xBD1.1" 400 173 "-" "-"
    192.168.2.132 - - [22/Dec/2017:12:24:14 +0100] "z\x02BQQA\xBD1.1" 400 173 "-" "-"
    192.168.2.132 - - [22/Dec/2017:12:24:34 +0100] "\xE9\x09BQQA\xBD1.1" 400 173 "-" "-"
    192.168.2.132 - - [22/Dec/2017:12:25:06 +0100] "z\x02BQQA\xBD1.1" 400 173 "-" "-"
    192.168.2.132 - - [22/Dec/2017:12:27:01 +0100] "\x02BQQA\xBD1.1" 400 173 "-" "-"
    192.168.2.132 - - [22/Dec/2017:12:28:11 +0100] "\x02BQQA\xBD1.1" 400 173 "-" "-"

The code to create GET request to send over TCP:

  char *hello = "GET / HTTP/1.1\r\nHost: 192.168.2.106\r\nConnection: close\r\n\r\n";

  if (wifi.send((const uint8_t*)hello, strlen(hello))) {
    Serial.print("Wifi send succesfull\r\n");
  } else {
    Serial.print("Wifi not send succesfully\r\n");
  }

The actual send method:

bool ESP8266::sATCIPSENDSingle(const uint8_t *buffer, uint32_t len)
{
    rx_empty();
    m_puart->print("AT+CIPSEND=");
    m_puart->println(len - 4);

    if (recvFind(">", 5000)) {
        Serial.println("found >");
        rx_empty();

        for (uint32_t i = 0; i <= len; i++) {
            m_puart->write(buffer[i]);
        }

        return recvFind("SEND OK", 30000);
    }
    return false;
}

This line:

m_puart->println(len - 4);

Was in the library actually just m_puart->println(len);

I had to shorten the length of the buffer for esp8266 to wait to, otherwise it wouldn't send the TCP command. The counting part of bytes looks fine to me. Not sure what's causing this behaviour.

The part above is just some extra unusual behaviour but isn't the main priority. So any ideas what's causing the odd HTTP requests?

  • did you set the 9600 baud rate in the AT firmware? – Juraj Dec 22 '17 at 12:35
  • Yes i did, it's also saved in the flash. – Jamie Dec 22 '17 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.