Decimals missing when using radio.write(); with Arduino I'm adapting a sketch I found to send sensor data over a wifi chip (Nrf2401), and although I get the message through, the value I send contains decimals (e.g. 24.59), but the received message will only be 24.

I'm sure there's something wrong on the transmitter part of the code, but I can't see what.

Here's my code:

#include &lt;RF24.h&gt;
#include &lt;RF24_config.h&gt;
#include &lt;SPI.h&gt;
#include &lt;OneWire.h&gt;
#include &lt;DallasTemperature.h&gt;

OneWire oneWire(4);

DallasTemperature sensors(&amp;oneWire);

// ce,csn pins
RF24 radio(8,7);

// init data buffer to hold a sensor type byte and one uint16_t sensor data
unsigned char data[3] = {
  0};
unsigned long count=0;
void setup(void)
{
  sensors.begin();  
  Serial.begin(57600);
  Serial.println("**************V1 Send Sensor Data***********");
  radio.begin();
  radio.setPALevel(RF24_PA_LOW);
  radio.setChannel(0x4c);

  // open pipe for writing
  radio.openWritingPipe(0xF0F0F0F0E1LL);

  radio.enableDynamicPayloads();
  radio.setAutoAck(true);
  radio.powerUp();
  Serial.println("...Sending");
}

void loop(void)
{

  sensors.requestTemperatures();
  float currentTemp;
  currentTemp = sensors.getTempCByIndex(0);


  //assign 'T' to represent a Temperature reading
  data[0] = 'T';

  data[1] = currentTemp;

  count++;

  sprintf(data, "T %5.2f\n", currentTemp);  // build command in data[]
  radio.txMode(strlen(data));               // set # bytes to xmit
  radio.write(data);                        // send bytes

  // print and increment the counter
  Serial.print("Temperature sent:  ");
  Serial.println(currentTemp);
  // pause a second
  delay(500);
}


In this example, when I print currentTemp, it will display the decimals, but if I print data[1], it won't. 

What am I missing?

EDIT:

I've modified the code to include the answer from JRobert (updated code above), but it comes back the following error:

nrf24SendSensorDataV1_ino.cpp: In function 'void loop()':
nrf24SendSensorDataV1_ino:56: error: invalid conversion from 'unsigned char*' to 'char*'
nrf24SendSensorDataV1_ino:56: error: initializing argument 1 of 'int sprintf(char*, const char*, ...)'
nrf24SendSensorDataV1_ino:57: error: 'class RF24' has no member named 'txMode'
nrf24SendSensorDataV1_ino:57: error: invalid conversion from 'unsigned char*' to 'const char*'
nrf24SendSensorDataV1_ino:57: error: initializing argument 1 of 'size_t strlen(const char*)'
nrf24SendSensorDataV1_ino:58: error: no matching function for call to 'RF24::write(unsigned char [3])'
C:\Users\Zuh\Downloads\arduino-1.0.1\libraries\RF24L01/RF24.h:281: note: candidates are: bool RF24::write(const void*, uint8_t)


Any thoughts?

EDIT 2

I've made a dirty fix that will solve the issue.

In the transmitter code I've added:

uint16_t sensorValue = currentTemp*100;
//do the bit shift to put uint16 into uint8 array
data[1] = sensorValue &gt;&gt; 8;
data[2] = sensorValue;
// print and increment the counter
radio.write(data, sizeof(uint16_t)+1);


This will send the (temperature value)*100

On the receiver end, I just convert the uint16_t to a float element and divide it by 100.

uint16_t sensorValue = data[2] | data[1] &lt;&lt; 8;
float temp = (float) sensorValue/100;
Serial.print("T: "); 
Serial.println(temp); 


Dirty, but effective!

Many thanks guys for the help, it really pointed me and my lousy programming skills to the right direction.
Since I can't comment yet I will place this as answer. 

But have you tried to use radio.print(data[1], DEC); ?

DEC stands for Decimal for if you want to force something to print it in Decimals. When you want something to be printed in Hexadecimals you can use HEX for example. Hope this will help you.