FAIL: ESP8266 ESP-1 TCP Connections via Arduino UNO

Hi,

I’m trying to use dweet.io trough an ESP8266 ESP-1 module connected to an Arduino Uno board.

The problem is that I’m able to make a connection trough AT+CIPSTART when using AT commands directly on the ESP8266, but i’m unable to do the same throughout an Arduino sketch via SoftwareSerial!

I used my own web server to see why it fails, and the direct AT commands that worked are these:

AT+CIPSTART=0,"TCP","homepages.myownsite.com",80
AT+CIPSEND=0,70
GET /docs/TestDocument.pdf HTTP/1.1
Host: homepages.myownsite.com

AT+CIPCLOSE=0

However, this sketch with the same AT commands fails:

#include <SoftwareSerial.h>
#include <stdlib.h>

// RX ESP -> TX Arduino
// TX ESP -> RX Arduino
SoftwareSerial ESPSerial(10, 11); // RX, TX

// this runs once
void setup() {                

  // enable debug serial
  Serial.begin(9600); 
  // enable software serial
  ESPSerial.begin(115200);

  delay(2000);
  Serial.println("AT+CIPMUX=1");
  ESPSerial.println("AT+CIPMUX=1");

}


// the loop 
void loop() {

  delay(2000);
  Serial.println("AT+CIPSTART=0,\"TCP\",\"homepages.myownsite.com\",80");
  ESPSerial.println("AT+CIPSTART=0,\"TCP\",\"homepages.myownsite.com\",80");

  delay(2000);
      
  Serial.println("AT+CIPSEND=0,70");
  ESPSerial.println("AT+CIPSEND=0,70");

  delay(2000);
  
  Serial.print("GET /docs/TestDocument.pdf HTTP/1.1\r\nHost: homepages.myownsite.com\r\n\r\n");
  ESPSerial.print("GET /docs/TestDocument.pdf HTTP/1.1\r\nHost: homepages.myownsite.com\r\n\r\n");

  delay(6000);
  //Close connection
  Serial.println("AT+CIPCLOSE=0");
  ESPSerial.println("AT+CIPCLOSE=0");
 
}

To monitor the response of my Web server I used the command sudo tail -f /var/log/apache2/access.log. I noticed that with the direct AT commands I always get a response, even when it was a 400 response. However, with the sketch there isn’t any response, and yes I also tried with a bigger sketch where all the connections are established, including AT+CWJAP, and everything works just fine until the GET command, it looks like the SoftwareSerial is unable to post HTML commands like GET!

It would be helpful to see the Serial ESP8266 response to the sketch commands, but I don’t know how to do it, I’m only able to monitor the Arduino Serial (9600) when commanding the board trough a sketch!

Any suggestions?

Thanks

Try using slower baud rates for SoftwareSerial, starting with 9600.

You need to change the baud rate of ESP8266 too, sending the AT command:

AT+UART=9600,8,1,0,0

as in the Instruction Set

giova014:
Try using slower baud rates for SoftwareSerial, starting with 9600.

Thank you, but I figured out what was wrong with my code... The issue was the ESPSerial ports! The right ones are these:

// RX ESP -> TX Arduino
// TX ESP -> RX Arduino
SoftwareSerial ESPSerial(2, 3); // RX, TX

:stuck_out_tongue_closed_eyes:

Thank you any way. I started with the SoftwareSerialExample code from the Arduino API Examples and never check the ESPSerial ports...

BTW, I thought every went well from the beginning because I never lost the wireless connection to my router AP. Now I realize that it simple never change it because the Arduino never post any command to the ESP8266!