Reading serial data from arduino
Posted: Wed Apr 27, 2016 10:55 am
Hi,
I'm trying to work with a small ESP8266 board and I have issues to communicate with it.
I first did a very basic test : I wired the board to the Rx and Tx pins of an arduino uno and sent commands manually from the serial monitor interface in the Arduino IDE. It worked very well, and I was able to send commands like AT, AT+CWLAP
The next step I took, was to send commands and read responses directly from the arduino. Unfortunately it does not work as expected. I tried various approaches with the Serial interface or the SoftwareSerial library. I always get some response with a kind of random characters.
The most basic code I tried was this one :
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2,3); // RX | TX
void setup()
{
Serial.begin(115200);
ESPserial.begin(115200);
}
void loop()
{
if ( ESPserial.available() ) { Serial.write( ESPserial.read() ); }
if ( Serial.available() ) { ESPserial.write( Serial.read() ); }
}
Using this sketch to relay my manual commands from the Serial monitor, I only get some weird stuff in response.
I also tried to vary the baud rate, with no success.
I also tried to use Serial to communicate and used a LCD display to monitor, but I had no success.
Any idea / hint ?
Gilles:
I'm trying to work with a small ESP8266 board and I have issues to communicate with it.
I first did a very basic test : I wired the board to the Rx and Tx pins of an arduino uno and sent commands manually from the serial monitor interface in the Arduino IDE. It worked very well, and I was able to send commands like AT, AT+CWLAP
The next step I took, was to send commands and read responses directly from the arduino. Unfortunately it does not work as expected. I tried various approaches with the Serial interface or the SoftwareSerial library. I always get some response with a kind of random characters.
The most basic code I tried was this one :
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2,3); // RX | TX
void setup()
{
Serial.begin(115200);
ESPserial.begin(115200);
}
void loop()
{
if ( ESPserial.available() ) { Serial.write( ESPserial.read() ); }
if ( Serial.available() ) { ESPserial.write( Serial.read() ); }
}
Using this sketch to relay my manual commands from the Serial monitor, I only get some weird stuff in response.
I also tried to vary the baud rate, with no success.
I also tried to use Serial to communicate and used a LCD display to monitor, but I had no success.
Any idea / hint ?
Gilles: