I have multiple sensor outputs from different libs, e.g. date/time form time lib, humidity from DHTxx lib, temperature from DS18B20 lib, weight from the ADS1231 lib. I think all variables are float.
I like to transfer this variables with a single payload over the RFM69 lib http://lowpowerlab.com/blog/2013/06/20/rfm69-library/ values should be comma separated. The radio lib expects a char array as payload. So I have to
- trim the library output to a decent number of decimal places
- add a comma between the variables
- concatenate all stuff
First I thought converting all float to a string and than lazy merge all with a "+" together is the way to go. But I found some advices and warnings to do this. The concerns go in the direction of not sufficient declared variables. I don't know is there a general problem or is it only about accurateness.
Second plan is to convert all float with dtostrf() to a char and then concatenate all with known length and so a single char array to send it via radio.
sprintf() is not working in the Arduino IDE so what's the best and most fault-tolerant (e.g. I could have negative values by sensor errors or higher values as normally expected) to handle this?
How do you concatenate chars? Have a long char and "insert" variables at the "right" position (so I have to be 100% sure about the number of digits a value has and also plus or minus) or to add each existing variable to the next, what means get the length of the current char array, get the length of the variable I like to add, expand the array, add the new var to the existing target array, do all stuff for the next var. Strings and + is more easy, but also more dangerous or memory wasting?