I'm having a hard time trying to convert a float into a char array so it's stored like '7.125' just like the float looks.
I'm trying to communicate with an ATtiny85 (slave) and a program on a Raspberry Pi (master) over I2C.
The master expects 31 bytes from the slave when data is sent to it.
When I use this code on the ATtiny85 everything works as it should, the Pi gets the data correctly.
char computerdata; computerdata = '3'; computerdata = '.'; computerdata = '8'; computerdata = '7'; computerdata = '7'; TinyWire.send(1); TinyWire.send(computerdata,30);
Of course I need to put a float variable in the array and not define numbers like I have for testing and this is where it breaks.
When I do something like this, it doesn't work, the Pi reports parsing error yet when I do this on the Due with Serial prints the char array looks good but something is different about it.
sprintf(computerdata, "%2.32f", pH); OR snprintf (computerdata, 35, "%f", pH);
What am I missing? Any ideas?