help with nrf24

Hi guys,
I would like to use nrf24 to send a temperature (float), if I use this code every thiing is ok:

 uint8_t data[] = "Hello World!";
  nrf24.send(data, sizeof(data));

but if I try to use a variable like this:

String str="hello";
uint8_t data[] = str;
  nrf24.send(data, sizeof(data));

I get this error:

initializer fails to determine size of 'data'

Can someone help me?

its the difference between a char array string and a String object, to convert the String object use tochararray() linky

to send a float you could create a structure containing a float type and pass the address of the structure to the send function.. saves manipulating the value into a char arrayon the way in and back to a float for math on the way out on the receiving side

nrf24.send(&myFloatStruc,sizeof(myFloatStruc));
if you really want to use Strings you could encapsulate one in a structure also

tho Strings and the support lib is FAT and wasteful, most would advice you drop it..

Can you make an example of the structure?

struct myFloatstruct {
float value;
// you could also load it with useful information for message control

};
linky

I tried with this:

struct DATA{
float temp;
};
DATA room;
.
. 
.
.


tempC = analogRead(tempPin);       
tempC = (5.0 * tempC * 100.0)/1024.0; 


room.temp=tempC;

  
  nrf24.send(&room, sizeof(room));

I recived this error:

nrf24_client.ino: In function 'void loop()':
nrf24_client:71: error: no matching function for call to 'RH_NRF24::send(DATA*, unsigned int)'
C:\Program Files (x86)\Arduino\libraries\RadioHead/RH_NRF24.h:512: note: candidates are: virtual bool RH_NRF24::send(const uint8_t*, uint8_t)

Ive not read any documentation on the lib your using,
the rf24 lib i have looked at is documneted here.. http://tmrh20.github.io/RF24Network/

works slightly differently, you create a header structure which contains the address of the receiving node and the type of message (default 0) and a payload structure to contain the message

your error message indicates the send wants a pointer to an int and a size?
RH_NRF24::send(const uint8_t*, uint8_t)

Simplest possible example of using RF24Network. Put this sketch on one node, and helloworld_rx.pde on the other. Tx will send Rx a nice message every 2 seconds which rx will print out for us.

/*
 Copyright (C) 2012 James Coliz, Jr. <maniacbug@ymail.com>
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 version 2 as published by the Free Software Foundation.
 
 Update 2014 - TMRh20
 */
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(9,10);                    // nRF24L01(+) radio attached using Getting Started board 
RF24Network network(radio);          // Network uses that radio
const uint16_t this_node = 1;        // Address of our node
const uint16_t other_node = 0;       // Address of the other node
const unsigned long interval = 2000; //ms  // How often to send 'hello world to the other unit
unsigned long last_sent;             // When did we last send?
unsigned long packets_sent;          // How many have we sent already
struct payload_t {                  // Structure of our payload
  unsigned long ms;
  unsigned long counter;
};
void setup(void)
{
  Serial.begin(57600);
  Serial.println("RF24Network/examples/helloworld_tx/");
 
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);
}
void loop() {
  
  network.update();                          // Check the network regularly
  
  unsigned long now = millis();              // If it's time to send a message, send it!
  if ( now - last_sent >= interval  )
  {
    last_sent = now;
    Serial.print("Sending...");
    payload_t payload = { millis(), packets_sent++ };
    RF24NetworkHeader header(/*to node*/ other_node);
    bool ok = network.write(header,&payload,sizeof(payload));
    if (ok)
      Serial.println("ok.");
    else
      Serial.println("failed.");
  }
}