configuration:
-iOS mavericks
-arduino uno
-SEEED GSM/GPRS V2.0
-unlocked and verified AT&T SIM card with data only (No SMS or Voice Calls)
How do I stream voltage readings from an analog sensor onto the web?
I'm using m2x.att.com as my API, but I'm open and interested in other options--perhaps something with a better support community.
This is the code I'm using:
#include "SerialModem.h"
#include "jsonlite.h"
#include "M2XStreamClient.h"
SerialModemClient client;
char m2xFeedId[] = "df60542f9f2ee9c1fed588320363b823"; // Feed you want to post to
char m2xKey[] = "30700b29c45af8922ec95e659e5da7a0"; // Your M2X access key
M2XStreamClient m2xClient(&client, m2xKey);
const int SENSOR = 0; // selects the input pin for the thermistor
int val = 0; //variable used to store the value coming from the sensor
void setup() {
// Note: Analogue pins are always and
// automatically set as inputs
Serial.begin(115200); // in tutorial it was 9600
while (!Serial);
SerialModem.setDriver(DRIVER_MTSMC_H5);
SerialModem.setSerial(&Serial, 115200);
while (!SerialModem.ready()) {
Serial.println("waiting for modem ready..");
delay(100);
}
while (SerialModem.getNetworkStatus() < NETWORK_STATUS_ROAMING) {
Serial.println("waiting for network registration");
delay(2000);
}
while (!SerialModem.setAPN("wap.cingular")) {
Serial.println("setting APN");
delay(2000);
}
}
void loop() {
val = analogRead(SENSOR); //read the value from the sensor
Serial.println(val); // print the value to the serial port
delay(1000); // wait 100 ms between each send
}
I also tried using the following code to test my modem:
/*
This example test if your modem is working correctly.
Circuit:
* GSM shield attached (using digital pins 2, 3, and 7)
Created 12 Jun 2012
by David del Peral
modified 21 Nov 2012
by Tom Igoe
*/
// libraries
#include <GSM.h>
// modem verification object
GSMModem modem;
// IMEI variable
String IMEI = "";
void setup()
{
// initialize serial communications
Serial.begin(9600);
// start modem test (reset and check response)
Serial.print("Starting modem test...");
if(modem.begin())
Serial.println("modem.begin() succeeded");
else
Serial.println("ERROR, no modem answer.");
}
void loop()
{
// get modem IMEI
Serial.print("Checking IMEI...");
IMEI = modem.getIMEI();
// check IMEI response
if(IMEI != NULL)
{
// show IMEI in serial monitor
Serial.println("Modem's IMEI: " + IMEI);
// reset modem to check booting:
Serial.print("Reseting modem...");
modem.begin();
// get and check IMEI one more time
if(modem.getIMEI() != NULL)
{
Serial.println("Modem is functoning properly");
}
else
{
Serial.println("Error: getIMEI() failed after modem.begin()");
}
}
else
{
Serial.println("Error: Could not get IMEI");
}
// do nothing:
while(true);
}
and I got "Error: Could not get IMEI"