{{:2012-06-17_105123.jpg|}} ===== mBed - Google API source code ===== A few people have asked me to post the source code. Here it is. Even though I have been programming for years in various database and IBM mainframe languages, I've never done much C, so feel free to send me a few tips. I'm not sure why, for example, it works only when ctTime and buffer[21] are declared outside of the subroutine they're used in?? All the libraries used can all be found on the mbed website. #include "mbed.h" #include "DS18B20.h" #include "DS18S20.h" #include "OneWireDefs.h" #include "EthernetNetIf.h" #include "HTTPClient.h" #include "NTPClient.h" #define THERMOMETER DS18S20 #define HOSTNAME "mbed" string calendar = "<<< YOUR CALENDAR PRIVATE ADDRESS >>>"; EthernetNetIf eth(HOSTNAME); HTTPClient http; NTPClient ntp; THERMOMETER device(true, false, false, p21); DigitalOut led1(LED1, "led1"); DigitalOut led2(LED2, "led2"); DigitalOut led3(LED3, "led3"); DigitalOut led4(LED4, "led4"); DigitalOut heater(p10); time_t ctTime; char buffer[21]; int targetTemp = 0; string getURL() { char url[256]; char endTime[21]; char startTime[21]; ctTime = time(NULL); strftime(buffer, 20, "%Y-%m-%dT%H:%M:00Z", localtime(&ctTime)); strcpy(startTime,buffer); ctTime = time(NULL)+60; strftime(buffer, 20, "%Y-%m-%dT%H:%M:00Z", localtime(&ctTime)); strcpy(endTime,buffer); //printf("start %s\n",startTime); //printf("end %s\n",endTime); sprintf(url, "%s?start-min=%s&start-max=%s", calendar, startTime, endTime); //printf("url %s\n",url); return url; } string getPage(char url[256]) { printf("\nQuery Google API... \n"); HTTPText txt("text/html",5000); HTTPResult r = http.get(url, &txt); if (r==HTTP_OK) { printf("Result Ok\n"); led2 = 0; return txt.gets(); } else { printf("Error %d\n",r); led2 = 1; return "FAIL"; } } void getAPI() { string testres; string results; char to[3]; char url[256]; strcpy(url,(char*)getURL().c_str()); results = getPage(url); //printf("results API %s\n",results); if (results == "FAIL") { printf("%s\n","Bad Result"); // Make no changes to the target temperature } else { testres = strstr(results.c_str(),"