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
00001 //This Program is used to turn the LED ON/OFF via telent (Wifly connected) 00002 #include "mbed.h" 00003 #include "WiflyInterface.h" 00004 #include <string.h> 00005 #include "LM75B.h" 00006 #include "MMA7660.h" 00007 #include "rtos.h" 00008 00009 #define XI_FEED_ID 1344466483 // set Xively Feed ID (numerical, no quoutes) 00010 #define XI_API_KEY "mgjx3VwlsvsMBhekqcASRLnzMPHi9Aw2gZCZCzyH0vQkefn3" // set Xively API key (double-quoted string) 00011 00012 #include "xively.h" 00013 #include "xi_err.h" 00014 00015 #include "C12832_lcd.h" 00016 00017 00018 LM75B temp(p28,p27); 00019 MMA7660 axl(p28,p27); 00020 Serial pc(USBTX,USBRX); 00021 C12832_LCD lcd; 00022 00023 /* wifly interface: 00024 * - p9 and p10 are for the serial communication 00025 * - p19 is for the reset pin 00026 * - p26 is for the connection status 00027 * - "mbed" is the ssid of the network 00028 * - "password" is the password 00029 * - WPA is the security 00030 */ 00031 //apps board 00032 WiflyInterface wifly(p9, p10, p30, p29, "MY_WIFI", "", NONE); 00033 00034 00035 00036 int main() { 00037 00038 wifly.init(); //Use DHCP 00039 pc.printf("1\r\n"); 00040 while (!wifly.connect()); 00041 pc.printf("IP Address is %s\n\r", wifly.getIPAddress()); 00042 00043 00044 xi_feed_t feed; 00045 memset( &feed, NULL, sizeof( xi_feed_t ) ); 00046 00047 feed.feed_id = XI_FEED_ID; 00048 feed.datastream_count = 4; 00049 00050 feed.datastreams[0].datapoint_count = 1; 00051 xi_datastream_t* temperature_datastream = &feed.datastreams[0]; 00052 strcpy( temperature_datastream->datastream_id, "Temperature" ); 00053 xi_datapoint_t* current_temperature = &temperature_datastream->datapoints[0]; 00054 00055 feed.datastreams[1].datapoint_count = 1; 00056 xi_datastream_t* x_axis_datastream = &feed.datastreams[1]; 00057 strcpy( x_axis_datastream->datastream_id, "X_axis" ); 00058 xi_datapoint_t* accel_x = &x_axis_datastream->datapoints[0]; 00059 00060 feed.datastreams[2].datapoint_count = 1; 00061 xi_datastream_t* y_axis_datastream = &feed.datastreams[2]; 00062 strcpy( y_axis_datastream->datastream_id, "Y_axis" ); 00063 xi_datapoint_t* accel_y = &y_axis_datastream->datapoints[0]; 00064 00065 feed.datastreams[3].datapoint_count = 1; 00066 xi_datastream_t* z_axis_datastream = &feed.datastreams[3]; 00067 strcpy( z_axis_datastream->datastream_id, "Z_axis" ); 00068 xi_datapoint_t* accel_z = &z_axis_datastream->datapoints[0]; 00069 00070 xi_context_t* xi_context 00071 = xi_create_context( XI_HTTP, XI_API_KEY, feed.feed_id ); 00072 if( xi_context == NULL ) 00073 { 00074 pc.printf("Error in Xi_Context\r\n"); 00075 exit (0); 00076 } 00077 00078 while (true) { 00079 pc.printf("In xively thread\r\n"); 00080 xi_set_value_f32( current_temperature, temp.read() ); 00081 xi_set_value_f32( accel_x ,axl.x() ); 00082 xi_set_value_f32( accel_y ,axl.y() ); 00083 xi_set_value_f32( accel_z ,axl.z() ); 00084 pc.printf("Value set\r\n"); 00085 xi_feed_update( xi_context, &feed ); 00086 pc.printf("Update\r\n"); 00087 wait(10); 00088 } 00089 }
Generated on Wed Jul 13 2022 09:59:39 by 1.7.2