diff --git a/README.md b/README.md index 73452ca..0b2d5fb 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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/ diff --git a/examples/AutoAnswerCall/AutoAnswerCall.ino b/examples/AutoAnswerCall/AutoAnswerCall.ino new file mode 100644 index 0000000..a8ad35e --- /dev/null +++ b/examples/AutoAnswerCall/AutoAnswerCall.ino @@ -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; + } +} diff --git a/examples/wake_FONA_to_send_SMS/wake_FONA_to_send_SMS.ino b/examples/wake_FONA_to_send_SMS/wake_FONA_to_send_SMS.ino new file mode 100644 index 0000000..9bf4bac --- /dev/null +++ b/examples/wake_FONA_to_send_SMS/wake_FONA_to_send_SMS.ino @@ -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; +}