1

I'm successfully running AT commands via the Serial Monitor. But now I'm issuing AT commands via Arduino code and facing problems getting the correct response.

Goal: After issuing AT commands programatically, knowing whether these run successfully or not.

Microcontroller: Arduino Uno

#include<string.h>
#include<SoftwareSerial.h>

#define OK "OK"
#define SERVER_PORT 1234
#define RX_PIN 2
#define TX_PIN 3

SoftwareSerial ESP(RX_PIN, TX_PIN);

void setup() {
  Serial.begin(115200);
  Serial.println("First serial");
  while(!Serial);
  ESP.begin(115200);
  Serial.println("Second serial");
  while(!ESP);
  //Enabling multiple connections
  ESP.println("AT+CIPMUX=1\r\n");
  while (!ESP.available());
  String muxResponse = ESP.readString();
  Serial.print("muxR:");
  Serial.println(muxResponse);
}

void loop() {
  if (ESP.available()) {
    String val = ESP.readString();
    Serial.println(val);
  }
}

After running the above code I get the response in the Serial Monitor like:

muxR:AT+CIPMUX=1


busy p../

OK

I'm getting special characters too.

  • You could try lowering the baud rate to see if the problem goes away: `ESP.begin(9600);` then increase in increments. I guess you are using some sort of level shifting between the Uno and the ESP8266 device. – 6v6gt Feb 26 '17 at 09:34
  • Ok. I'm just using arduino uno R2, ESP8266 and breadboard, nothing else. – Rahul Rastogi Feb 26 '17 at 10:55
  • @6v6gt I changed the baud rate of ESP8266 to 9600 by AT+CIOBAUD=9600. Baud successfully changed but getting same response. Getting this busy p.. :( – Rahul Rastogi Feb 26 '17 at 11:09
  • busy p../ error not going even after factory reset (AT+RESTORE). – Rahul Rastogi Feb 26 '17 at 11:40
  • Maybe you find something here. I's a similar case: http://arduino.stackexchange.com/questions/18575/send-at-commands-to-esp8266-from-arduino-uno-via-a-softwareserial-port – 6v6gt Feb 26 '17 at 11:44
  • I recently found out that ESP pins are probably tolerant to 6V, **BUT** I would still use a level shifter. Also there is some issue when using SoftwareSerial to communicate between an Uno and ESP where something doesn't work at high baud rates, normally 9600 does work. Personally I would put a `delay(50);` and the end of `loop()` but I have no evidence that it makes a difference :) – Code Gorilla Sep 20 '17 at 07:19
  • I believe busy is a response you should expect and it literally means the ESP is still busy doing the last command. – Code Gorilla Sep 20 '17 at 07:25
  • There is a nice library that hides the AT commands behind standard Arduino networking API: [WiFiEsp](https://github.com/bportaluri/WiFiEsp) – Juraj Sep 20 '17 at 15:44

1 Answers1

1

change

AT+CIPMUX=1\r\n

to

AT+CIPMUX=1
James
  • 11
  • 1
  • Explain that, what was the mistake and how your answer correct it. As it, it solve the problem at hand without educating the OP. –  Feb 17 '18 at 11:42