The car is controlled by the PS2 controller and the temperature is sent on xively via the wifly.
Dependencies: C12832_lcd WiflyInterface libxively mbed-rtos mbed LM75B MMA7660
Fork of IOT-Project-Wifly-Xively by
main.cpp
- Committer:
- bhakti08
- Date:
- 2014-06-09
- Revision:
- 6:9abfe16d39e0
- Parent:
- 5:efa4a9eafe7d
- Child:
- 7:c7023f76310e
File content as of revision 6:9abfe16d39e0:
//This Program is used to turn the LED ON/OFF via telent (Wifly connected) #include "mbed.h" #include "WiflyInterface.h" #include <string.h> #include "LM75B.h" #include "MMA7660.h" #include "rtos.h" #define XI_FEED_ID 209829319 // set Xively Feed ID (numerical, no quoutes) #define XI_API_KEY "T0izYrB6TZVkmhhEWpzs5L7F5wqpJixxc6MtenkLDg3BLMIu" // set Xively API key (double-quoted string) #include "xively.h" #include "xi_err.h" #include "C12832_lcd.h" LM75B temp(p28,p27); MMA7660 axl(p28,p27); Serial pc(USBTX,USBRX); C12832_LCD lcd; /* wifly interface: * - p9 and p10 are for the serial communication * - p19 is for the reset pin * - p26 is for the connection status * - "mbed" is the ssid of the network * - "password" is the password * - WPA is the security */ //apps board WiflyInterface wifly(p9, p10, p30, p29, "MY_WIFI", "", NONE); int main() { wifly.init(); //Use DHCP pc.printf("1\r\n"); while (!wifly.connect()); pc.printf("IP Address is %s\n\r", wifly.getIPAddress()); xi_feed_t feed; memset( &feed, NULL, sizeof( xi_feed_t ) ); feed.feed_id = XI_FEED_ID; feed.datastream_count = 1; feed.datastreams[0].datapoint_count = 1; xi_datastream_t* temperature_datastream = &feed.datastreams[0]; strcpy( temperature_datastream->datastream_id, "Temperature" ); xi_datapoint_t* current_temperature = &temperature_datastream->datapoints[0]; xi_context_t* xi_context = xi_create_context( XI_HTTP, XI_API_KEY, feed.feed_id ); if( xi_context == NULL ) { pc.printf("Error in Xi_Context\r\n"); exit (0); } while (true) { pc.printf("In xively thread\r\n"); xi_set_value_f32( current_temperature, temp.read() ); pc.printf("Value set\r\n"); xi_feed_update( xi_context, &feed ); pc.printf("Update\r\n"); wait(10); } }