Hardware serial not working but software serial is

I am using this GSM module with an arduino nano for a project of mine.

https://www.ebay.com/itm/174803191349?_trkparms=amclksrc%3DITM%26aid%3D1110006%26algo%3DHOMESPLICE.SIM%26ao%3D1%26asc%3D20201210111314%26meid%3D3e3485ef522444a598a709f4e4b1c778%26pid%3D101195%26rk%3D2%26rkt%3D12%26sd%3D174101712444%26itm%3D174803191349%26pmt%3D1%26noa%3D0%26pg%3D4429486%26algv%3DSimplAMLv11WebTrimmedV3MskuWithLambda85KnnRecallV1V2V4ItemNrtInQueryAndCassiniVisualRankerAndBertRecallWithVMEV3CPCAuto&_trksid=p4429486.c101195.m1851&amdata=cksum%3A1748031913493e3485ef522444a598a709f4e4b1c778|enc%3AAQAIAAABUObhgc4Nk8%252BdtAwOww4FKLaj%252FQ5qqgDlQCuqZA43WcPFUWDERCUugbbOk7XQv0JXlBfqCg2xKF3WcPghxGMFw2oSlXvfExEaMYr7I7LmrHcP6czY1wIMt0ORyKiCWt95xldincyyBx3g%252BNDW%252B%252FhWUgTaBhK6xAm%252BJIbCOMehu%252BdwvYsJamvFr20Za2JDgHXAqXHuDJ651MCeVFYJSh4kCu%252BZNILqw%252B5Mz%252BkQ5Rg4rnr%252BXLY5mHz3Vb3qZt36Ju7ldUUSv56a6LV4smCR8tyEj1vMKhmP5cWe1YodYJXNnqh49vnk59%252Fp6r5c8%252B5hvy0y5kfur1VkzUzkYKvXj6VKsTTgnN9TzV0nOvDndaJLgc%252FBfUkQ%252FgEA%252FKDk2cXf5HkgxClUF2zEjTP4hwfcxo4Ky6I%252BytupclVdk1BxxpqfV7db4y3RAhNz2nM79EVw%252BqVD7Q%253D%253D|ampid%3APL_CLK|clp%3A4429486

I am using a usb-ttl converter and a simple for passing data through for debugging.

#include <SoftwareSerial.h>

#define softRX 2 
#define softTX 7
#define pwr_en 9

SoftwareSerial softSerial(softRX, softTX);

void setup() {
  // put your setup code here, to run once:
  pinMode(pwr_en,OUTPUT);
  digitalWrite(pwr_en,HIGH);
  delay(3000);
  digitalWrite(pwr_en,LOW);
  delay(3000);
  Serial.begin(9600);
  softSerial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available()){
    delay(10);
    softSerial.write(Serial.read());
  }
  if(softSerial.available()){
    delay(10);
    Serial.write(softSerial.read());
  }
  
}

When I have the GSM module connected to the software serial pins I can send and receive commands as expected.

When I have the GSM module connected to the hardware serial pins (0 and 1) I do not receive commands as expected. I do see the receive led light up briefly after enabling the power on the GSM module, as it sends some data on startup, but nothing is passed back through the usb-ttl converter. This happens regardless of any delay between power up and beginning the serial communication.

I have also tried at every baud rate supported by the GSM module. I tried this after setting the baud rate using the usb-ttl converter and then trying this hardware serial setup again. The module is supposed to have an auto baud rate function but I've read that this can be unreliable.

Is there anything else I should be doing to get this communication working through the hardware serial pins? The sim7000 chip operates at 1.8V so there must be a level converter on the GSM board. Maybe this could be an issue? I don't have an oscilloscope or anything to test this with though however.

The fact that this works with software serial and not hardware serial is just confusing to me.

If I can't get this working I see a few options for my project.

  1. Get another GSM module. I'd prefer to use what I already have, and I have no idea that this would actually fix the problem with the hardware serial communication.
  2. Use software serial and then use the hardware serial pins for other outputs. This just seems dumb to me, but if it works...

Nano only has one hardware serial port. It's already in use for uploading your code and serial monitor. You can't use it for 2 things at the same time.

If you must use hardware serial, use an Arduino board with more than one hardware serial port, like Pro Micro, Mega and many others (but not Uno or Pro Mini, they too only have one).

I upload my code first, then use it for this. I'm not trying anything simultaneously. Alternatively code can be uploaded via ICSP, not using serial at all.

The USB to Serial converter on the Nano has its pins connected to Nano pins D0 and D1.

So there is a conflict, two output pins connected together, the TX output from the Nano USB to Serial converter and the connection you make to the GSM module.

I thought that too at first, that's why I used a usb-ttl converter connected directly to the D0/D1 pins for testing the software serial case. There's no interference there.

The TX/RX lines on the nano have resistors to effectively bypass the onboard usb chip when using the D0/D1 pins directly. Arduino Nano resistors on Rx/Tx - #2 by LarryD

Admittedly, I don't fully understand how this override/bypass of the onboard usb chip works, but I've used the D0/D1 pins directly for serial communication with other devices in the past just fine.

To completly 'overide\bypass' the FT232RL chip you would need to remove it.

And yes I know about the series resistors in RX and TX.

Oh, I thought you were running that code you posted.

And why don't you connect the SIM7000 via SoftwareSerial and avoid complications?

And yes I know about the series resistors in RX and TX.

Can you point me to a good explanation of why those work? Maybe then I could understand why it works with the usb-ttl converter and with my other projects using this method, but not with this module.

I plan to use all but one of the other pins for other functions in my project. I could still change which pins are being used for communication and the other functions but then I would have dedicated hardware serial pins as regular IO and regular IO as software serial pins, which doesn't seem efficient. But I still might do that if I can't figure this issue out.

The Nano board has that limitation with the use of the port (just like UNO).
Either way, you shouldn't have any problems as long as you don't have the USB cable plugged into the port.
I have a GPS connected that I have to disconnect when I need to upload code to the Nano.

Regarding efficiency, I don't see that it's more efficient to add a "virtual" USB port when you already have a real one just to use the UART hardware for something else, but these are points of view...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.