Post topics, source code that relate to the Arduino Platform

User avatar
By Labspace
#34422 Modified the code as shown below
Code: Select all#include <SoftwareSerial.h>

SoftwareSerial serial(2,3);
void setup()
{
 Serial.begin(115200);
 serial.begin(115200);

 serial.println("AT\r\n");
 if(serial.available() >0)
 {
    Serial.println(serial.read());
 }
 else
 {
    Serial.println("Nothing in serial buffer.");
 }
}

void loop()
{

}


It returns "Nothing in serial buffer." . The ESP still responds to AT commands from Serial montior.
User avatar
By Venkatesh
#34433 "if" is not "loop", you are still reading a single char.

1) First check the AT firmware version and its baud rate
2) Check connection and set correct pins in SoftwareSerial (2 -> RX and 3->TX of esp8266)
3) Use this in setup() after sending command
4) Isn't Serial and serial confusing. For soft serial, use like espSerial.

Code: Select allString response = "";
while (softSerial.available())
{
   char c = softSerial.read();
   response += c;
}

Serial.println(response);