0

Hi I am new to arduino development i was using esp8266 using software serial library

here is the code

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

SoftwareSerial monitor(2, 3); // RX, TX

void setup()
{
  monitor.begin(9600);
  Serial.begin(9600);

  sendDebug("AT");
  delay(5000);
  Serial.println("Hello");
  if(monitor.find("OK"))
  {
   Serial.println(monitor.available());
   Serial.println((int)monitor.read());
   Serial.println((int)monitor.read());
    Serial.println(monitor.available());
   Serial.println("RECEIVED: OK");
    //connectWiFi();
  }
  else
  {
    Serial.println("RECEIVED: None");
  }
}

void loop(){

}


void sendDebug(String cmd){
  monitor.println(cmd);
  Serial.println("Command: "+cmd);
}

Output

Command: AT
Hello
2
13
10
0
RECEIVED: OK

All I know is monitor.available() return the available bytes that can be read and i can also deduce that these two bytes are O and K but the integer value doesn't corresponds to the ascii value of O and K

can anyone explain what is actually getting printed on the serial monitor what is 13 and 10 ? ??

1

It is just like https://www.arduino.cc/en/Serial/Read :

The monitor.find("OK"); already consumed the 'O' and the 'K' bytes, (see https://www.arduino.cc/en/Serial/Find ) then there were two bytes .available(), a 13=CarriageReturn and a 10=LineFeed, both returned by successive monitor.read()s, then zero more bytes in monitor.available().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.