Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jenschr/97e6b047b3b0f17f3e9a to your computer and use it in GitHub Desktop.
Save jenschr/97e6b047b3b0f17f3e9a to your computer and use it in GitHub Desktop.
Adafruit Fona modifications for Teensy 3.1, updated for latest lib + simplified
/*
Replace the first lines in your FONATest example file with the lines below. It's basically just changing from SoftwareSerial to HardwareSerial + changed pins to match the Teensy.
*/
#include <SoftwareSerial.h>
#include <HardwareSerial.h>
#include "Adafruit_FONA.h"
#define FONA_RX 1
#define FONA_TX 0
#define FONA_RST 4
// this is a large buffer for replies
char replybuffer[255];
#define HWSERIAL Serial1
HardwareSerial fonaSS = Serial1; // replaces SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
Adafruit_FONA fona = Adafruit_FONA(FONA_RST);
/*
The example indicates that you should uncomment Serial1 if using HardwareSerial. No need for that.
Next, update Adafruit_FONA.cpp to include HWSerial for the Teensy by putting this at the top:
*/
#if (ARDUINO >= 100)
#include "Arduino.h"
#ifdef SERIAL_PORT_USBVIRTUAL
#include <HardwareSerial.h>
#else
#include <SoftwareSerial.h>
#endif
#else
#include "WProgram.h"
#include <NewSoftSerial.h>
#endif
/*
Lastly, update Adafruit_FONA.h with the same as above. That's it...
*/
@MrCanBus
Copy link

I've made the changes and get compile errors in the Fona Test example with this piece

fonaSerial->begin(4800);
if (! fona.begin(*fonaSerial)) {
Serial.println(F("Couldn't find FONA"));
while (1);
}

If I change this HardwareSerial fonaSS = Serial1; to HardwareSerial fonaSerial = Serial1;
and

fonaSerial.begin(4800);
if (! fona.begin(fonaSerial)) {
Serial.println(F("Couldn't find FONA"));
while (1);
}

I can get it to compile, but it still can't communicate with the Fona.

I'm using a Teensy LC, HWSerial2 (9,10) and reset on pin 20.

Help!

@zacstewart
Copy link

@MrCanBus did you ever get your FONA working with the LC?

@MrCanBus
Copy link

MrCanBus commented Jun 1, 2019

I honestly don't remember, haven't touched it for quite a while

@zacstewart
Copy link

zacstewart commented Jun 2, 2019

I figured it out! I had TX on the Teensy connected to TX on the FONA and same with RX. I just flipped them and it fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment