I have a question. I want to send elapsed time via the NRF24 transceiver.
I have the transceiver working and I can send a string "ABC123" ., but now I want to send the value of elapsed time . This isn't working. I keep getting the error fails to determine size of 'data' . I hope someone can help me. Been trying for days now.
// uint8_t data[] = "ABC123,CHECK123456789"; // This works, I am able to send this
uint8_t data[] = message2; //This doesn't work . I got the error initializer fails to determine size of 'data' .
nrf24.send(data, sizeof(data));
nrf24.waitPacketSent();
// Now wait for a reply
uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
status=1;
break;
//*****************************************
What is message2?
This why we ask you to post your code.
Sorry, here is a more complete code.
int status=1;
String message1;
String message2;
unsigned long start, finished, elapsed;
// nrf24_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing client
// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
// reliability, so you should only use RH_NRF24 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf24_server.
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module
#include <SPI.h>
#include <RH_NRF24.h>
// Singleton instance of the radio driver
RH_NRF24 nrf24;
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini
void setup()
{
Serial.begin(9600);
while (!Serial)
; // wait for serial port to connect. Needed for Leonardo only
if (!nrf24.init())
Serial.println("init failed");
// Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
if (!nrf24.setChannel(1))
Serial.println("setChannel failed");
if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
Serial.println("setRF failed");
}
void loop()
{
start=millis();
message1="";
elapsed=finished-start;
Serial.print(elapsed);
Serial.println("milliseconds elapsed");
Serial.println();
//*********Send message to server after distance
Serial.println("Sending to nrf24_server");
char message[10];
int i;
// long val = 1234567;
long val=elapsed;
Serial.print("The value is: "); // Show the integer number
Serial.println(val);
ltoa(val, message, 10);
Serial.print("As a string: ");
for (i = 0; i < strlen(message); i++) {
Serial.print(message[i]); // Show as a string
message2=message2 + message[i];
}
delay(5000);
// uint8_t data[] = "ABC123,CHECK123456789"; // This works, I am able to send this
uint8_t data[] = message2; //This doesn't work . I got the error initializer fails to determine size of 'data' .
nrf24.send(data, sizeof(data));
nrf24.waitPacketSent();
// Now wait for a reply
uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
status=1;
}
...and that's why we ask you to use CODE TAGS.