sprintf() to assemble String and float pieces locks up I'm trying to parse many variables into a URL so that I can update a website through a simple HTTP API with sensor data. After talking to a buddy of mine, he suggested going with the code below. 

When I put this in, the Arduino Yun boots up. I see the L13 red LED turn on, but then it hoses. When I comment out the sprintf(); line, everything works fine — except no URL is parsed.

I've tried to debug to the best of my ability and am looking for thoughts on what may be happening. 

I'm not sure how much code to post without posting the whole 130 line sketch, so I'm just dumping the parts from the loop that is trying to piece together the URL.

  // Get update time
  Process date;
  date.runShellCommand("date --utc \"+%Y-%m-%d%%20%H:%M:%S\"");
  String utcDateString = "";
  while (date.available()) {
    char d = date.read();
    utcDateString += d;
  }

      char url[512];
      url[0]='\0';
      float humid, baro, windspeed, raingauge;
      int winddir;
      Serial.print("humid: ");
      Serial.println(humid);
        Serial.print("baro: ");
      Serial.println(baro);
        Serial.print("windspeed: ");
      Serial.println(windspeed);
        Serial.print("raingauge: ");
      Serial.println(raingauge);
        Serial.print("winddir: ");
      Serial.println(winddir);
 //sprintf(url,"http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=123456&amp;PASSWORD=xxxxxx&amp;dateutc=%s&amp;temp=%2.2f&amp;humidity=%2.2f&amp;baromin=%f&amp;winddir=%d&amp;windspeedmph=%3.2f&amp;rainin=%3.2f&amp;softwaretype=Custom%%20Arduino&amp;action=updateraw",
//         utcDateString,Thermistor(analogRead(0)),humid,baro,winddir,windspeed,raingauge);
        Serial.print("url: ");
      Serial.println(url);

double Thermistor(int RawADC) {
  double Temp;
  Temp = log(11100.0/((1024.0/RawADC-1)));  // Was 10000... Manually dialed down to increase accuracy. 9400 is a good value. Changing again to match wunderground
  Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
  Temp = Temp - 273.15;            // Convert Kelvin to Celcius
  Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
  return Temp;
}


Here's the output from those Serial.print() calls:

humid: 0.00
baro: 0.00
windspeed: 0.00
raingauge: 0.00
winddir: 0
url:


I'm not sure how else to debug this because when I uncomment sprintf(); the Yun locks up and I have to press the 32U4 Reset button and power cycle the Arduino to get it to work again.
This variable:

String utcDateString = "";


Is a C++ String, not a character array like sprintf() is expecting.  To convert this string to a character array such that sprintf is expecting, you must use .c_str() in your sprintf, i.e.:

sprintf(foo,"This is a format for %s", utcDateString.c_str());


Doing this should prevent the sprintf line from causing a memory fault.