Hi,
Hope someone can help me, I have been tryng all day to work out how to accomplish the following:
I have been using this code for a year and it works well, I obtain a float temparature reading, then its converted to decimal places and then sent out via nRF24L01 transmitter.
My needs have changed and I know need to send text as well, such as: TurnOnLed
I cannot work out how to convert the text to be sent using this part of the code:
RF24NetworkHeader header(other_node);
bool ok = network.write(header,&payload,sizeof(payload));
I think it may involve using a char is some way, but not really sure ?
Thanks in anticipation
Gary
float Float_to_Decimal;
struct payload_t // Defines a structure (a template), NO STORAGE is allocated. When used variables ARE IN THIS ORDER.
{
float Anything; // This is just a name, usually descriptive, could be anything at all, as its a 'member' of struct.
float Sensor; //
};
void RF_send_temperature (void)
{
network.update(); // Pump the network regularly.
unsigned long currentTime = millis(); // millis = used as part of a timer.
if ( currentTime - previousTime >= Temperature_interval) // Not really used, but left in for compatibility, Set to 1 ms in 'Start page'.
{
previousTime = currentTime;
Temparature_float_2_decimals(); // Convert the float to 2 decimals places after decimal point.
payload_t payload = {packets_sent++, Float_to_Decimal}; // Create an instance called 'payload' of the struct and put values in it.(Was 'payload_t payload).
Print_temperature();
RF24NetworkHeader header(other_node);
bool ok = network.write(header,&payload,sizeof(payload));
if (ok)
Serial.println(F("sent ok."));
else
Serial.println(F("failed."));
}
}