0
votes

I am using Arduino Uno and GSM sim800l for a project and looks like something is wrong and I don't know what it is. Here is my code:

#include <AltSoftSerial.h>

AltSoftSerial altSerial;

void setup() {
  Serial.begin(19200);
  Serial.println("AltSoftSerial Test Begin");
  altSerial.begin(19200);
  altSerial.println("Hello World");
}

void loop() {
  char c;

  altSerial.print("altSerial is working.");
  if (Serial.available()) {
    c = Serial.read();
    altSerial.print(c);
  }
  if (altSerial.available()) {
    c = altSerial.read();
    Serial.print(c);
  }
}

Its output was like this:

AltSoftSerial Test Begin (linebreak)
 Hello World  (linebreak)
ltSerial is ok⸮⸮M⸮ɥ⸮⸮⸮is okalt //insert long random garbage here

I tried changing the baud rate of the code and serial monitor to keep it matched but it is not working, I tried to lower it as low as 300 and tried up to 19200 as well.
Any ideas would help. I also tried Tools-> Fix encoding and reload but it still didn't solve the problem. It is my first time using this type of hardware so please bear with me. My goal is to use it to send SMS messages but right now I'm trying a smaller task with it to try and understand it better.

Btw, the Arduino IDE I am using is 1.8.7

1
did you set the baud rate in Serial Monitor to 19200 baud?Juraj
yeah, when I change the baud rate in the source code I change the baud rate in arduino serial monitor as well. I make sure that they always match.Need2learn
how do you get both outputs to one Serial Monitor?Juraj

1 Answers

0
votes

I realize this post is old, but so am I, and even if I haven't had every possible com port issue in the last 40 years, I can safely say I've had dozens of them. For me, it is a trouble shooting tree, and for what it's worth, here it is..

First, you didn't say what your system is, and you should always start there. I am going to assume Windows 10, but the basic ideas are the same if the way to achieve them are different.

  1. Plug in your arduino. You already said your serial monitor is set to 19200, but be sure you are sure, because that is very often the problem.
  2. if you are sure of #1, open Control Panel > Device manager > Ports
  3. If you don't see "Ports" in the list, then your computer isn't seeing the arduino. This could be anything from a bad arduino to a bad cable to a bad usb port on your PC. Try switching all those out one at a time to see if you can get anything talking to the com port at speed. Since you were getting something in the serial monitor, this won't be your particular problem.
  4. Click on "Ports" to expand it, and verify you see the Arduino listed. Right click on the Arduino, disable, and enable it again. See if that fixes the baud rate problem.
  5. Look at Arduino properties
  6. Does it say your device is working properly? If no, look at events and you will see an error description. Fix whatever it says is wrong. If yes, continue
  7. Port settings will likely be 9200, 8, None, 1, None. Even if your baud rate in the serial monitor window is 19200, you will still probably see 9200 in the Device Manager, don't worry about it. It feels wrong, but it is normal. Microsoft seems to like keeping 9600 here, even if the last thing I did with this port was different. The data bits, and other settings listed above are a different matter.
  8. next, click on Advanced
  9. is your Arduino-assigned port number showing up? Does it say 'In Use' beside it? If it does, this is your problem. I know. Strange, huh? Trust me, if it says 'In Use', that means that something internal to Microsoft is using the port, but it isn't your Arduino. Power shell can help you resolve what has it, but that's another story, but the best bet now is reinstall your driver.
  10. Click the Driver tab, and verify your Driver Provider is Arduino LLC. I've never seen it not that, but if it isn't, I would try to find out why.
  11. Go ahead and Update the driver and reboot your computer, even if you aren't prompted to reboot, do it anyway.
  12. Didn't fix it? In the Driver tab, Disable the device, and re-enable it. That might fix the problem, too.
  13. Didn't fix it? Don't uninstall the driver just yet.
  14. click details. do you see Arduino?
  15. Look at the Events tab. If you see an error, then fix it.
  16. Still not working? Uninstall your serial driver, and reinstall it.
  17. Still no 19200? If you have garbage, the timing on your rx is not synchronized with the Arduino tx. You now need a logic analyzer, and that is more than can be covered here.