Im want to read from a dht22 and store the values in an array and send to emoncms. So far in my code I have this:
void loop(){
//For DHT22 Grove Pro
static char outstr1[15];
static char outstr2[15];
float h = dht.readHumidity();
float t = dht.readTemperature();
String dataString1 = dtostrf(h, 8, 2, outstr1);
String dataString2 = dtostrf(t, 8, 2, outstr2);
}
And now I want to put that data into a char[200] array in order to send it via post to emoncms. How do I put those individual strings, dataString1 and 2 into the char[] array?
Look at the reference for the dtostrf function. What does the function return? Why would you put the return value into a String?
It returns a pointer to a char, but not a char[], so i cant assign it to my char[200]. I needed it as a string in order to post it to a web service.
Marciokoko:
It returns a pointer to a char, but not a char[], so i cant assign it to my char[200]. I needed it as a string in order to post it to a web service.
A pointer is a pointer. It points to a memory address. The only thing the typing does is to indicate how the addresses beyond the base and the contents are treated. Regardless, the pointer (on the 328P) is simply a 16-bit address. If you have a character string, char array[], by default array is a pointer to array[0] and if you print array and &array[0] you'll get the same result.