Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Example Files and update Readme.md #88

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

**This library requires Arduino v1.0.6 or higher**

This is a library for the Adafruit FONA Cellular GSM Breakouts etc
This is a library for the Adafruit FONA Cellular GSM Breakouts, including the 3G modules etc.

Designed specifically to work with the Adafruit FONA Breakout
* https://www.adafruit.com/products/1946
* https://www.adafruit.com/products/1963
* http://www.adafruit.com/products/2468
* http://www.adafruit.com/products/2542
* http://www.adafruit.com/products/2696
* http://www.adafruit.com/products/2691
* http://www.adafruit.com/products/2687

These modules use TTL Serial to communicate, 2 pins are required to interface

Expand All @@ -27,3 +30,6 @@ Check that the Adafruit_FONA folder contains Adafruit_FONA.cpp and Adafruit_FONA

Place the Adafruit_FONA library folder your *arduinosketchfolder*/libraries/ folder.
You may need to create the libraries subfolder if its your first library. Restart the IDE.

To Contribute to our code, please fork the ADAfruit_FONA repository and then submit a pull request to merge it back in with the master. To learn more about forking & pull requests etc. Follow the github help:
https://guides.github.com/activities/contributing-to-open-source/
54 changes: 54 additions & 0 deletions examples/AutoAnswerCall/AutoAnswerCall.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// This code provided by Adafruit Support Rick, it is an example of how to do something upon an event, in this case
// How to do an action upon recieving a phone call (ringing).
//
// In your sketch, attach your own interrupt routine to the RING line. In the routine, set a boolean flag to true.
// Poll the boolean in your loop routine. Whenever it becomes true, do a pickup and then set the flag back to false.
//
// Let's assume you're using pin 2 for your RI line. (if you're on a Uno, you can only use pins 0, 1, 2, 3 for RI.
// But 0 and 1 are already used for the serial monitor). I've moved the other pins as necessary

#include "Adafruit_FONA.h"
#include "SoftwareSerial.h"

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

SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;
Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST);

volatile bool ringing = false;
void RingInterrupt()
{
ringing = true;
}

void setup() {
Serial.begin(115200);

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

attachInterrupt(RING_PIN, RingInterrupt, FALLING);
}

void loop() {

if (ringing)
{
delay(1000); //let it ring for a second
// pick up!
if (! fona.pickUp()) {
Serial.println(F("Failed"));
} else {
Serial.println(F("OK!"));
}
ringing = false;
}
}
107 changes: 107 additions & 0 deletions examples/wake_FONA_to_send_SMS/wake_FONA_to_send_SMS.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/***************************************************
This is an example for our Adafruit FONA Cellular Module

Designed specifically to work with the Adafruit FONA
----> http://www.adafruit.com/products/1946
----> http://www.adafruit.com/products/1963
----> http://www.adafruit.com/products/2468
----> http://www.adafruit.com/products/2542

These cellular modules use TTL Serial to communicate, 2 pins are
required to interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/

/*
THIS CODE IS STILL IN PROGRESS!

Open up the serial console on the Arduino at 115200 baud to interact with FONA

Note that if you need to set a GPRS APN, username, and password scroll down to
the commented section below at the end of the setup() function.
*/
#include "Adafruit_FONA.h"

//The atmega is wired as follows:
#define TMP 0
#define PS_LIGHT 5
#define FONA_KEY 6
#define FONA_PS 7
#define FONA_NS 8
#define FONA_TX 9
#define FONA_RX 10
#define FONA_RST 11
#define FONA_VIO 12

//TMP is the TMP36
//PS_LIGHT Is the power LED. This is used to indicate when power is on, a connection fails, or a message fails to send.

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

bool FonaWake() {
digitalWrite(FONA_VIO, HIGH);
if (digitalRead(FONA_PS) == LOW)
{
digitalWrite(FONA_KEY, LOW);
delay(4000);
}

digitalWrite(FONA_KEY, HIGH);

while (!Serial);
Serial.begin(115200);
Serial.println(F("Booting up FONA"));

fonaSerial->begin(4800);

if(! fona.begin(*fonaSerial)) {
failBlink(200);

return false;
}

Serial.println(F("FONA is OK"));

if (digitalRead(FONA_NS) == HIGH) {
return true;
}

// Give it a second to finish booting
delay(500);

return digitalRead(FONA_NS) == HIGH;
}

void FonaSleep() {
if (digitalRead(FONA_PS) == HIGH)
{
digitalWrite(FONA_KEY, LOW);
delay(4000);
digitalWrite(FONA_KEY, HIGH);
}

digitalWrite(FONA_VIO, LOW);

if (digitalRead(FONA_PS == LOW)) {
Serial.println("FONA OFF");
}
}

bool sendSms(char *phoneNumber, char *message) {
// send an SMS!
flushSerial();

if (!fona.sendSMS(phoneNumber, message)) {
failBlink(500);
return false;
}

return true;
}