Post topics, source code that relate to the Arduino Platform

User avatar
By Aurora Borealis
#55256 I can't et any communication between my Arduino Uno and an ESP01.
Everything is wired up correctly (including a seperate 3.3v supply for the esp).

For testing, I've written this code:
Code: Select all#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX
long int boud_rate_array[] = {1200,2400,4800,9600,19200,38400,57600,115200,230400};


void setup() {
  Serial.begin(9600);
  while (!Serial);
  Serial.println("Start test");
}
void loop() {
    for (int i = 0; i<9;i++){
     
      Serial.println("baud rate: ");
      Serial.println(boud_rate_array[i]);
      Serial.println("send AT command");
      mySerial.begin(boud_rate_array[i]);
      mySerial.println("AT");
      delay(2000);
      while (mySerial.available()){
     String inData = mySerial.readStringUntil('\n');
     Serial.println("Got reponse from ESP8266: " + inData);
  }
      delay(5000);
     
     
    }
  }


And this is the result of it:
Code: Select allStart test
baud rate:
1200
send AT command
Got reponse from ESP8266: ÿÿÿÿ
baud rate:
2400
send AT command
Got reponse from ESP8266: ÿÿÿÿ
baud rate:
4800
send AT command
Got reponse from ESP8266: ÿÿÿÿ
baud rate:
9600
send AT command
Got reponse from ESP8266: ÿüÿþ
baud rate:
19200
send AT command
Got reponse from ESP8266: –þñ
baud rate:
38400
send AT command
Got reponse from ESP8266: I›þ
baud rate:
57600
send AT command
Got reponse from ESP8266: )Ò$þ
baud rate:
115200
send AT command
Got reponse from ESP8266: ¡µÔE¶5‚
baud rate:
230400
send AT command
baud rate:
1200
send AT command
Got reponse from ESP8266: ÿÿÿÿ
baud rate:
2400
send AT command


As you can see, only gibberish.
What am I doing wrong? I hope someone can help me

When connecting to ports 0 & 1, it works fine (so, there should be an issue with the serialsoftware connection but I cant find what it is).

Thx,
Peter
User avatar
By chalupien
#55367 Interesting method to find the baud rate. depending on the uC speed (8mhz,16mhz,etc) the Software serial has limitations. I know at 8Mhz 115200 will not function. Otherwise, try to send AT+CIOBAUD=9600 to change it to a known 9600. But you will need to send it using the baud rate of the ESP module (usually 115200).