Note-arduino library: could you add Rx, Tx pin options to Notecard.begin()

I am using the note-arduino library, with an ESP32-S3 microprocessor, in my cellular IoT prototype. I use UART1 to talk to the Notecard. The ESP32-S3 supports reassigning serial ports to most any of the GPIO pins, and my PCB design takes advantage of this feature. The Arduino code would be Serial.begin (9600, 8N1, RX_PIN, TX_PIN);

The Note-arduino does not support the pin number arguments in Notecard.begin() but I’ve been able to succeed by defining them with this workaround code:

Serial1.begin(9600, SERIAL_8N1, PIN_RX_FROM_NOTECARD,PIN_TX_TO_NOTECARD);
delay(1000);
notecard.begin(Serial1, 9600);

BUT beginning with V1.6.0 of the library, the workaround stopped working! I can see in the library that a Serial.end is now being issued before Serial.begin. This must be wiping out my pin definitions, I’m stuck on V1.5.4 of the library and worried my product will stop working in the future.

So I’m entering this as a fix/enhancement request: support optional definition of alternative Serial port pins in the Notecard.begin() function.

2 Likes

Apparently, ESP32 has extended the standard Arduino begin() method (shown below), and this is the source of the problem. I believe the bug you are experiencing is a side effect of Espressif’s implementation.

The standard Arduino HardwareSerial::begin method does not allow you to declare the pins, only a baud and configuration.

AVR Core: HardwareSerial::begin

    void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
    void begin(unsigned long, uint8_t);

Typically, you would need to create a new SoftwareSerial object, and provide the pins to the constructor.

AVR Core: SoftwareSerial:SoftwareSerial

SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false);

Here is a link to the reference material for the SoftwareSerial library.


1 Like