RETIRED - MG2639 Cellular Shield Hookup Guide
This Tutorial is Retired!
This tutorial covers concepts or technologies that are no longer current. It's still here for you to read and enjoy, but may not be as useful as our newest tutorials.
Example Bonus: Posting to Phant
The motivating factor behind us seeking out a solid cellular module was finding a reliable tool to remotely post environment data to our data service running Phant. We'd be remiss if we didn't show at least one example of how to use the hardware and IoT service together.
Download the Phant Library
A sketch included with the library -- MG2639_Phant -- requires an additional library to take care of Phant posts. Download the library from our Phant-Arduino repo, or by clicking the button below:
Again, follow the Installing an Arduino Library tutorial for help installing it.
Running the Example
Open the MG2639_Phant example sketch by going to File > Examples > SparkFun MG2639 CellShield > MG2639_Phant.
This sketch is set up to use a pre-defined stream -- DJjNowwjgxFR9ogvr45Q. Feel free to use that for testing, but don't abuse it or rely on it too much (it's very possible our powers combined will exceed the post limit). This example gathers the Arduino's analog pin values and posts all six of them to the stream.
To run the sketch, open the serial monitor and send any character to start a post.
Any response from the HTTP server will be routed back out to the serial monitor. Look for "HTTP/1.1 200 OK" to verify that the post was successful. You should also see an updated set of numbers on the stream page.
As the sketch continues to run, you can send another character over serial to initiate a new post. Just take care to only send one character at a time -- and don't abuse the strem!
Memory Limitations
The MG2639 library can really test the limits of the Arduino's memory. You'll notice that in most of these examples we put large, constant strings in flash (e.g. Serial.println(F("Hello, world"));
). In this example we're also storing the Phant field strings in flash.
You'll notice that most of these examples sacrifice flash storage space for as much SRAM as we can get. If your sketch mysteriously resets, or isn't working as you'd expect, you may be running out of memory. It can be a diabolically hard problem to diagnose and fix, but start with trying to eliminate big strings and large arrays.