Converting from Software Serial to Hardware Serial

I don't know if I am just having a brain fart, but I currently have my project running on SoftwareSerial and would like to put it on hardware serial. Is it just as simple as changing SoftwareSerial to HardwareSerial?

Here is the code for my project:

#include "Adafruit_FONA.h"

#define FONA_RX 2
#define FONA_TX 3
#define FONA_RST 4

#include <SoftwareSerial.h>
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;

Adafruit_FONA fona = Adafruit_FONA(FONA_RST);

char gps_string[ 140 ];

void setup() {
  fonaSerial->begin(115200);
  fona.begin(*fonaSerial);
//fona.enableGPS(true);
//fona.getGPS(0, gps_string, 140);
}

void loop() {
    fona.sendSMS("7247147099", "Testing STEM Board ATMega328PB Chip...");
    delay(5000);
  //fona.sendSMS("7247147099", gps_string);
}


//remove double slash for GPS in the text message on

I know this is a dumb question, but I really have no idea how to do this. This is an example code from Adafruit that I modified to send a text to me every 5 seconds so I can make sure that my project works...

Thanks,
Joe Mancino

Which Arduino Board?

uno and eventually moving over to an AtMega328PB custom made PCB...

The AtMega328P only has one hardware USART. It appears on Uno Pins 0 & 1.

This USART is also used for Serial. So, you'd have to disconnect the Fona for code downloading and serial debugging. Other boards/processors have multiple hardware serial port.

Well my code works perfectly fine on the arduino uno but when I upload it to the AtMega328PB, it doesn't text like it should. I should say that my board is basically the FONA with a atmega chip on it. I am thinking that the FONA library is not supported on the AtMega328PB chip, therefore SoftwareSerial does not work correctly. That is why I am thinking that the HardwareSerial may work. . .

Sorry, I'm not familiar with the "PB" version.

I think it's something like:

  Serial.begin(115200);
  fona.begin(&Serial);

This compiles without error for Arduino UNO:

#include "Adafruit_FONA.h"


const byte FONA_RST = 4;


Adafruit_FONA fona = Adafruit_FONA(FONA_RST);


char gps_string[140];


void setup() {
  Serial.begin(115200);
  fona.begin(Serial);
  fona.enableGPS(true);
  fona.getGPS(0, gps_string, 140);
}


void loop() {
    fona.sendSMS("7247147099", "Testing STEM Board ATMega328PB Chip...");
    delay(5000);
    fona.sendSMS("7247147099", gps_string);
}


//remove double slash for GPS in the text message on