*FIXED* Nano 328 - unreadable serial monitor

I’m sure someone here has had this before.

The first Ardunio I was given for Xmas was a Nano kit from Franzis I-O-T maker kit series.

It comes with 20+ projects and a booklet, which to be honest boosted my knowledge no end and was much fun.

I have progressed onto an Uno but dusted off the nano yesterday.

I plugged the nano into my PC and got the IDE window up, selected the model, flavour and port.

I then selected the serial software sketch to upload so I run a few checks like sdk and so on…

Here is the code:

Its a standard piece that reads and writes to an AT prompt.

/*
Software Serial Examples.
No change necessary.
*/
#include <SoftwareSerial.h>

SoftwareSerial esp8266(11, 12);

void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(19200);
// set the data rate for the SoftwareSerial port
esp8266.begin(19200);

//send first AT Command to see if ESP8266-Module responds
esp8266.println(“AT”);
}

void loop() // run over and over
{
if (esp8266.available())
Serial.write(esp8266.read());
if (Serial.available())
esp8266.write(Serial.read());
}

Now, the only problem I have is that the IDE serial monitor window which used to work now give unreadable characters. I have tried a number of different baud rates - all to no avail.

I’m sure it is something fairly simple as some other example programs DO work and you can get responses.

OR

Is there a better softwareserial code out there I can use to program and run various commands.

Thank you for any help and suggestions.

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.

The Serial Monitor’s baud rate setting must match the number used in Serial.begin(), 19200 in the code you posted. Did you try selecting 19200 from the baud rate menu at the bottom right corner of the Serial Monitor window?

If that doesn’t work then it may be that the serial monitor communication is working perfectly well but the garbage is coming from the ESP8266. ESP8266 is set to communicate at 115200 by default but the SoftwareSerial library doesn’t work reliably at that speed so you may need to change the ESP8266’s setting to a lower speed via the appropriate AT command.

Sorry about the </> things.

Yes in the serial monitor I have selected the same baud rate and the CR NL setting as well.

The code itself is an example that I used many times over.

I have uninstalled IDE and reinstalled it, even gone back a few releases.

I have remved and reinstalled the USB/COM driver.

Im now at a loss.

Without using the serial window - to change the baud to 115200 a simple sketch could be created ?

The serial monitor window is useless at this point regardless of the baud I set.

Again, thank you for your help.

KenHart1969:
The serial monitor window is useless at this point regardless of the baud I set.

It’s easy enough to test that statement:

/*
Software Serial Examples.
No change necessary.
 */
#include <SoftwareSerial.h>

SoftwareSerial esp8266(11, 12);

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(19200);
  Serial.println("Hey look, the Serial Monitor is working just fine!");

  // set the data rate for the SoftwareSerial port
  esp8266.begin(19200);
 
  //send first AT Command to see if ESP8266-Module responds
  esp8266.println("AT");
}

void loop() // run over and over
{
  if (esp8266.available())
    Serial.write(esp8266.read());
  if (Serial.available())
    esp8266.write(Serial.read());
}

So it sounds like the problem is that you’re getting garbage from the ESP8266. I suspect the problem is that the ESP8266 is set to the default configuration of 115200 baud and you’re communicating with it at 19200. My advice is to change the sketch to communicate with the ESP8266 at 115200:

/*
Software Serial Examples.
No change necessary.
 */
#include <SoftwareSerial.h>

SoftwareSerial esp8266(11, 12);

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(19200);

  // set the data rate for the SoftwareSerial port
  esp8266.begin(115200);
 
  //send first AT Command to see if ESP8266-Module responds
  esp8266.println("AT");
}

void loop() // run over and over
{
  if (esp8266.available())    
    Serial.write(esp8266.read());
  if (Serial.available())
    esp8266.write(Serial.read());
}

The serial communication is still set to 19200 so leave your Serial Monitor set to 19200. Now use the AT+UART_DEF to set the baud rate lower, 9600 or 19200, as documented in the ESP8266 AT command reference:

If you’re not sure of the command you could test it first with AT+UART_CUR, which will only temporarily change the configuration and will revert back to the previous settings when the ESP8266 is powered off. AT+UART_DEF writes the settings to flash so it is a persistent change.

I don’t have experience with SoftwareSerial but hopefully it will work well enough at 115200 for you to get the command through. It’s possible you might have to make a couple attempts.

Pert,

Thank you - I followed your comments and I have now got a responsive Nano again As below:


AT

OK

Firstly I tried your original suggestion and got the response : "Hey look, the Serial Monitor is working just fine!" but then any AT+ commands were unreadable. : fæ€æ€˜€æ€˜€þ˜ž˜æ€˜€ so it was almost sorted.

I then uploaded your code snippet from the thread above and it worked and it was all good. I tried a few commands AT+GMR and got readable responses.

I then used the command "AT+UART_DEF=19200,8,1,0,0" as this is the default value that Franzis iot build uses in all their examples.

Its a perfect fix and one that I'll not forget !

Many thanks for your help.

Regards

Ken.

So glad to hear. Congratulations on being back on track with your project. Enjoy!