Arduino Forum

Using Arduino => Networking, Protocols, and Devices => Topic started by: mamw on Sep 11, 2020, 04:33 pm

Title: Serial monitor shows squares
Post by: mamw on Sep 11, 2020, 04:33 pm
hi,

I have an arduino nano that connected to sim800l. the problem is that when i try to print data coming from gsm the serial monitor shows squares but when I write to serial monitor it show what i am typing.

my baud rate both are 9600 and in the serial monitor is the same. The code was working good but now it is not.


here is the code  I am using


Code: [Select]

#include <SoftwareSerial.h>

//Create software serial object to communicate with SIM800L
SoftwareSerial mySerial(2, 3); //SIM800L Tx & Rx is connected to Arduino #3 & #2

void setup()
{
  //Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
  Serial.begin(9600);
 
  //Begin serial communication with Arduino and SIM800L
  mySerial.begin(9600);

  Serial.println("Initializing...");
  delay(1000);

  mySerial.println("AT"); //Once the handshake test is successful, it will back to OK
  updateSerial();
  mySerial.println("AT+CSQ"); //Signal quality test, value range is 0-31 , 31 is the best
  updateSerial();
  mySerial.println("AT+CCID"); //Read SIM information to confirm whether the SIM is plugged
  updateSerial();
  mySerial.println("AT+CREG?"); //Check whether it has registered in the network
  updateSerial();
}

void loop()
{
 updateSerial();
}

void updateSerial()
{
  delay(500);
  while (Serial.available())
  {
    mySerial.write(Serial.readString());//Forward what Serial received to Software Serial Port
  }
  while(mySerial.available())
  {
    Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
  }
}


I just copy it from https://lastminuteengineers.com/


(https://forum.arduino.cc/index.php?action=dlattach;topic=704645.0;attach=381392;image)
 (https://forum.arduino.cc/index.php?action=dlattach;topic=704645.0;attach=381392;image)
Title: Re: Serial monitor shows squares
Post by: ieee488 on Sep 12, 2020, 04:28 am
take a look at http://www.martyncurrey.com/hc-05-with-firmware-2-0-20100601/#AT-Command-Mode (http://www.martyncurrey.com/hc-05-with-firmware-2-0-20100601/#AT-Command-Mode) which is similar to what you are doing except for the different baud rate

.
Title: Re: Serial monitor shows squares
Post by: GolamMostafa on Sep 12, 2020, 01:59 pm
Try the following line:
Code: [Select]
Serial.print(mySerial.read());//Forward what Software Serial received to Serial Port

Or

Code: [Select]
Serial.write((char)mySerial.read());//Forward what Software Serial received to Serial Port
Title: Re: Serial monitor shows squares
Post by: mamw on Sep 16, 2020, 10:08 pm
thanks for your reply,

the first line shows 255255255255255255255...

the second shows squares
Title: Re: Serial monitor shows squares
Post by: cattledog on Sep 17, 2020, 01:35 am
Quote
The code was working good but now it is not.
What changed?