#include "Arduino.h"
#include "SoftwareSerial.h"
int rxPin = 2;
int txPin = 3;
String commands[] = {"AT\r\n", "AT\r\n", "AT+GMR\r\n", "AT+CWLAP\r\n"
, "AT+CIPSTART=\"TCP\",\"www.thingspeak.com\",80\r\n"
, "AT+CIPCLOSE\r\n"};
int command_number = 0;
SoftwareSerial soft (rxPin, txPin);
void sendCommand (String cmd, int del);
void setup ()
{
pinMode (rxPin, INPUT);
pinMode (txPin, OUTPUT);
Serial.begin (115200);
Serial.println ("Starting up...");
soft.begin (115200);
while(!Serial) {;}
while (!soft) {;}
}
void loop ()
{
sendCommand (commands[command_number++],command_number*1000);
if (command_number == 6)
command_number = 0;
delay(200);
}
void sendCommand (String cmd, int del)
{
char data;
soft.print (cmd);
delay (del);
while (!soft.available()) {;}
Serial.println (soft.available());
while (soft.available())
{
data = soft.read();
Serial.print (data);
delay(10);
}
}
And here is the response from serial monitor. If you notice the response sometimes is incomplete and sometimes it's junk. So it's really unreliable. On the other hand, when I communicate using Arduino RX/TX and some serial term app then the response is perfectly fine with same baud rate. Only difference is that I move the connection from pin 2 and 3 to RX and TX.
Starting up...
11
AZCH�H�j�H�11
AT
OK
63
AT+GMR
AT vdrsion:0.40.0.0(Aug 8 2015 14:45:58)
SDK vershon63
AT+CWLAP
+CWLAP:(4,"ATT7YXn7J6",-90,"f8:18:97:`c:2b:16",1,76)59
AT+CIPSTART="TCP","www.thiogspeak.com",80
CONNECT
OK
28
AT+CIPCLOSE
CLOSED
OK
10
AT
OK
11
AT
O�C�63
AT+GMR
AT vession:0.40.0.0(Aug 8 2015 14:45:58(
SDK version63
AT+CWL@P
+CWLAP:(3,"DHRECT-A0-HP FNVY 4520 sdries",-89,"dc:4a