Modifying the sample code
Dependencies: GPRSInterface HTTPClient USBDevice libxively mbed
Fork of Seeed_ARCH_GPRS_V2_Xively_HelloWorld by
Revision 4:6bf017e6aa4e, committed 2015-02-25
- Comitter:
- EthanGoldman
- Date:
- Wed Feb 25 20:19:45 2015 +0000
- Parent:
- 3:3b7881cf8bd0
- Commit message:
- Playing around...
Changed in this revision
diff -r 3b7881cf8bd0 -r 6bf017e6aa4e HTTPClient.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HTTPClient.lib Wed Feb 25 20:19:45 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/donatien/code/HTTPClient/#277279a1891e
diff -r 3b7881cf8bd0 -r 6bf017e6aa4e main.cpp --- a/main.cpp Mon Sep 15 07:13:30 2014 +0000 +++ b/main.cpp Wed Feb 25 20:19:45 2015 +0000 @@ -22,18 +22,21 @@ #include "mbed.h" #include "GPRSInterface.h" #include "USBSerial.h" +/* no more xively stuff needed #include "xively.h" #include "xi_err.h" +*/ +#include "HTTPClient.h" #define PIN_PWR P1_2 //power up gprs module #define PIN_PWR_KEY P1_7 #define PIN_TX P1_27 #define PIN_RX P1_26 -#define XI_FEED_ID 571464242 // set Xively Feed ID (numerical, no quoutes) -#define XI_API_KEY "niUYuSJkjqyzPFwnWqpApm7lLNv8fInUD6ijAoRrikqKFWbg" // set Xively API key (double-quoted string) - +#define TS_FEED_ID "JR669X7UY6DE1WJX" // set ThingSpeak Feed ID (alphanumeris, so quotes I guess) +/* #define XI_API_KEY "niUYuSJkjqyzPFwnWqpApm7lLNv8fInUD6ijAoRrikqKFWbg" // set Xively API key (double-quoted string) +*/ AnalogIn soundSensor(P0_12); -GPRSInterface gprs(PIN_TX,PIN_RX,115200,"cmnet",NULL,NULL); +GPRSInterface gprs(PIN_TX,PIN_RX,115200,"live.vodafone.com",NULL,NULL); USBSerial pc(0x1f00, 0x2012, 0x0001, false); DigitalOut power(PIN_PWR); DigitalOut powerKey(PIN_PWR_KEY); @@ -89,11 +92,11 @@ } // successful DHCP pc.printf("IP Address is %s\n", gprs.getIPAddress()); - +/* THIS ALL SHOULD BE REPLACED WITH THINGSPEAK CODE xi_feed_t feed; memset( &feed, NULL, sizeof( xi_feed_t ) ); - feed.feed_id = XI_FEED_ID; + feed.feed_id = TS_FEED_ID; feed.datastream_count = 1; feed.datastreams[0].datapoint_count = 1; @@ -107,12 +110,16 @@ // check if everything works if( xi_context == NULL ) { return -1; +*/ + } while(1) { float val = 100*soundSensor.read(); pc.printf("val = %f\n",val); + /* MORE THINGSPEAK CODE GOES HERE - SEE http://blog.hendriklipka.de/archives/2014/01/temperature_monitoring.html xi_set_value_f32(current_sound, val); xi_feed_update( xi_context, &feed ); + */ wait( 10 ); } } \ No newline at end of file
diff -r 3b7881cf8bd0 -r 6bf017e6aa4e ts_user_config.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ts_user_config.h Wed Feb 25 20:19:45 2015 +0000 @@ -0,0 +1,22 @@ +#ifndef __TS_USER_CONFIG_H__ +#define __TS_USER_CONFIG_H__ + +// The following settings should lower memory footprint. +// The library currently allows one to send batch datapoint +// and feed updates, but it's not needed in most use cases +#define TS_MAX_DATAPOINTS 1 +// The number of channels can be increased if needed +#define TS_MAX_DATASTREAMS 5 + +// Below are optimisations that reduce some minor functionality +#define TS_OPT_NO_ERROR_STRINGS + +// If you wish to enable assertions, set this to 1 +#define TS_DEBUG_ASSERT 0 +// If you wish to disable debug output, set this to 0 +#define TS_DEBUG_OUTPUT 0 + +// On the mbed app board we can use the LCD for debug output, +// but one may wish to modify this and write to file instead + +#endif /* __TS_USER_CONFIG_H__ */