Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Show comment
Hide comment
@MrCanBus

MrCanBus Sep 20, 2015

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!

MrCanBus commented Sep 20, 2015

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!

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