I tested this Program:
/*
Software serial test
*/
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
char charbuffer[255];
int inCount;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// set the data rate for the SoftwareSerial port
mySerial.begin(115200);
}
void loop() // run over and over
{
byte inputChar;
int iCount;
if (mySerial.available()>0)
{
inputChar = mySerial.read();
charbuffer[inCount] = inputChar;
inCount++;
}
if (Serial.available())
switch(Serial.read())
{
case '?':
Serial.print("Send At...");
mySerial.print("AT\n\r");
break;
case '!':
Serial.print(charbuffer);
while (inCount > 0)
{
charbuffer[inCount] = 0;
inCount--;
}
break;
}
}
Result:
--> ?
<-- Send At...
--> !
<-- AªCQÔ¤*IIOR†…
Too bad..
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Hey hello, I was reading through this. You have two ints, one is called inCount, and one is not used and called iCount. I would start to give inCount an initial value of zero. Does this work better?
Are you sure? yes | no
Thank you. I just about to add the next log :)
It is not a great example of programming.. sorry.
Are you sure? yes | no
not sure the Softserial is capable of 115200 bps, taken from https://www.arduino.cc/en/Reference/SoftwareSerial :
"On Arduino or Genuino 101 the current maximum RX speed is 57600bps"
You should use the softserial for debug and the hardware serial for talking to the ESP, although that might complicate things again.
Are you sure? yes | no
Ahh nevermind again. "It is possible to have multiple software serial ports with speeds up to 115200 bps"
Are you sure? yes | no
Thank you. It was a bit strange.. i have tried to talk to the Arduino with a FTDI RL232FT and it worked but not with the ESP.. I changed the Baudrate to 9600 and now it works much better.
Are you sure? yes | no