I am developing a sketch that uses an Uno and an ESP8266 to send email via smtp2go. However "HELO" responds with "ERROR". What might be the source of the problem?
To explore this, I created another sketch that simply sends commands to the ESP8266, and displays the results. The wifi connection seems fine, as does the SMTP Server connect to mail.smtp2go.com. However, the next command issued "HELO 10.1.0.35" provides a response of "ERROR".
The ESP8266 is mounted on an ESP-01 board, and set @ 9600 baud. have tested with different chip sets. I have also tried using Gmail [smtp.gmail.com,465 ], but results are the same.
[I know that an ESP8266 can be used stand-alone. However the final sketch requires 13 data pins.]
Output from sketch:
"ESP8266_ATcmdtest", compiled on: Jun 8 2017 at 17:58:18
Running on: Arduino UNO: ATmega328P
__________[ Disable echo (Echo sends back received command before response) ]__________
__________[ ATE0 ]__________
Response buffer:
OK
__________[ Delete server ]__________
__________[ AT+CIPSERVER=0 ]__________
Response buffer:
no change
OK
__________[ Restart the module ]__________
__________[ AT+RST ]__________
Response buffer:
OK
0,CLOSED
WIFI DISCONNECT
bB׆QR⸮⸮⸮ȤRN⸮ɥRL⸮H⸮⸮N⸮⸮d#@⸮⸮
WIFI CONNECTED
__________[ Check Firmware type [Responds with: AT version:1.2.0.0(Jul 1 2016 20:04:45) ]__________
__________[ AT+GMR ]__________
Response buffer:
AT+GMR
AT version:1.2.0.0(Jul 1 2016 20:04:45)
SDK version:WIFI GOT IP
__________[ Lists available APs ]__________
__________[ AT+CWLAP ]__________
Response buffer:
AT+CWLAP
+CWLAP:(0,"KCTcircuit2",-47,"08:bd:43:ff:6a:0c",1,21,0)
+CWLAP:(3,"49KHC",-88,"70:f1:96:66:29:ef",1,11,0)
+CWLAP:(3,"KCTstudy",-49,"04:a1:51:bf:6b:30",5,-11,0)
+CWLAP:(3,"Linksys05761",-75,"b4:75:0
e:64:54:b1",11,21,0)
+CWLAP:(3,"Pccd_main",-91,"14:91:82:83:f8
__________[ Get local IP address, e.g., 192.168.4.1 ]__________
__________[ AT+CIFSR ]__________
Response buffer:
AT+CIFSR
+CIFSR:STAIP,"10.0.0.4"
+CIFSR:STAMAC,"5c:cf:7f:34:
__________[ Set Station mode ]__________
__________[ AT+CWMODE=1 ]__________
Response buffer:
AT+CWMODE=1
OK
__________[ Set current multiplex mode ]__________
__________[ AT+CIPMUX=1 ]__________
Response buffer:
AT+CIPMUX=1
OK
__________[ Connect to AP ]__________
__________[ AT+CWJAP="KCTstudy","[pw redacted]" ]__________
Response buffer:
AT+CWJAP="KCTstudy","[pw redacted]"
WIFI DISCONNECT
WIFI CONNECTED
__________[ Prints the SSID of Access Point ESP8266 is connected to. ]__________
__________[ AT+CWJAP? ]__________
Response buffer:
AT+CWJAP?
busy p...
WIFI GOT IP
OK
__________[ Get IP address of ESP8266 station, e.g., 10.0.0.4 ]__________
__________[ AT+CIPSTA? ]__________
Response buffer:
AT+CIPSTA?
+CIPSTA:ip:"10.0.0.4"
+CIPSTA:gateway:"10.0.0.1"
__________[ SMTPServer connect ]__________
__________[ AT+CIPSTART=0,"TCP","mail.smtp2go.com",2525 ]__________
Response buffer:
AT+CIPSTART=0,"TCP","mail.smtp2go.com",2525
0,CONNECT
OK
+IPD,0,70:220 mail.smtp2go.com ESMTP Exim 4.87 Fri, 09 Jun 2017 00:59:07 +0000
__________[ Get information about connection ]__________
Response format is:
STATUS:stat [ 2: Got IP, 3: Connected, 4: Disconnected]
+CIPSTATUS:id,type,addr,port,tetype [type: TCP, addr: IP address]
OK
__________[ AT+CIPSTATUS ]__________
Response buffer:
AT+CIPSTATUS
STATUS:3
+CIPSTATUS:0,"TCP","173.255.233.87",25
__________[ HELO ]__________
__________[ HELO 10.0.0.8 ]__________
Response buffer:
HELO 10.0.0.4
ERROR
Sketch code
#include <SoftwareSerial.h>
// _______________________________
#define sendit(x) ( { \
Serial.print(F("__________[ ")); \
Serial.print(x); \
Serial.println(F(" ]__________")); \
esp8266.write(x); \
esp8266.write("\r\n"); \
delay(300); \
Serial.println(F("Response buffer: ")); \
for (int i=0; i <= 99; i++) { \
memset(buffer, 0, sizeof(buffer)); \
delay(10); \
bcount = esp8266.readBytes(buffer, sizeof(buffer)); \
if (bcount == 0) i = 100; \
else { \
if (bcount > 1) Serial.println(buffer); \
delay(300); \
} \
} \
} )
// _______________________________
#define desc(x) ( { \
Serial.println(); \
Serial.print(F("__________[ ")); \
Serial.print(F(x)); \
Serial.println(F(" ]__________")); \
} )
// _______________________________
SoftwareSerial esp8266(11, 12); // RX, TX
char buffer[200];
String SerialReadBuffer = "";
char SerialByteIn; // Temporary variable
boolean SerialEnd = false;
int bcount;
// _______________________________
void setup()
{
Initialise();
}
// _______________________________
void loop()
{
}
// ____________________________________________________________________________________________________
void Initialise()
{
SerialReadBuffer.reserve(64);
esp8266.begin(9600);
// esp8266.begin(115200);
Serial.begin(9600);
CommandList2();
}
// ____________________________________________________________________________________________________
void CommandList2()
{
desc("Disable echo (Echo sends back received command before response)");
sendit("ATE0");
desc("Delete server");
sendit("AT+CIPSERVER=0");
desc("Restart the module");
sendit("AT+RST");
desc("Check Firmware type [Responds with: AT version:1.2.0.0(Jul 1 2016 20:04:45)");
sendit("AT+GMR");
desc("Lists available APs");
sendit("AT+CWLAP");
desc("Get local IP address, e.g., 192.168.4.1");
sendit("AT+CIFSR");
desc("Set Station mode");
sendit("AT+CWMODE=1");
desc("Set current multiplex mode");
sendit("AT+CIPMUX=1");
desc("Connect to AP");
sendit("AT+CWJAP=\"KCTstudy\",\"[pw redacted]\"");
desc("Prints the SSID of Access Point ESP8266 is connected to.");
sendit("AT+CWJAP?");
desc("Get IP address of ESP8266 station, e.g., 10.0.0.4");
sendit("AT+CIPSTA?");
desc("SMTPServer connect");
sendit("AT+CIPSTART=0,\"TCP\",\"mail.smtp2go.com\",25");
desc("Get information about connection");
Serial.println(F("Response format is: "));
Serial.println(F("STATUS:stat [ 2: Got IP, 3: Connected, 4: Disconnected]"));
Serial.println(F("+CIPSTATUS:id,type,addr,port,tetype [type: TCP, addr: IP address]"));
Serial.println(F("OK"));
sendit("AT+CIPSTATUS");
//
// Problems start here
//
desc("HELO");
sendit("HELO 10.0.0.4");
Serial.println(F("__________________"));
}