Hi, y'all!
I have set up two arduinos with a nrf905 on each. Using Zak Kemble's nrf905 wireless serial link example, it works like a charm.
But after searching everywhere for some time, I cannot find any example where DATA is sendt with Arduino/NRF905, all examples I have found are for sending a fixed text ("hello world") etc.
Can anyone point me in the right direction?
I want to make a data structure (or what you pros call them):
struct dataStruct {
int temperature;
int alarm;
int humidity
}myData;
Post a simple program that illustrates how you send data with the nRF905. I am only familiar with the nRF24L01+.
If it is just serial data then have a look at the examples in Serial Input Basics - simple reliable ways to receive data. It should be easy to figure out the corresponding code to send data.
thank you for the reply.
I guess someone out there are using NRF905 modules to send data from sensors, and I am hoping one of them will help me out.
Oddly, or typically, the RadioHead library example for the NRF905 is only sending text, too. ("hello world").
The NRF24 modules work really well, but the 905 has ten times more transmitting power and a much lower frequency, probably allowing the signals to pass through walls and trees more easily. But again I want to send some data, not "hello world"
Do you pros know if sending data this simple is possible with the nrf905 module?
With radiohead nrf905 I do not see why the standard instruction with a byte cast will not work. You won't harm anything to try.
RH_NRF905 nrf905;
nrf905.send((uint8_t*)&data, sizeof(data));
I believe that the radiohead library uses common methods across the devices, and when I used the syntax above with RH NRF69 and that radio unit, all was well.
torestabell:
thank you for the reply.
I guess someone out there are using NRF905 modules to send data from sensors, and I am hoping one of them will help me out.
How about posting a link to the documentation for the Radiohead library that you are using?
C:\Users\acer\Documents\Arduino\libraries\RadioHead/RH_NRF905.h:347:10: note: no known conversion for argument 1 from 'dataStruct*' to 'const uint8_t* {aka const unsigned char*}'
There was a typo in my first posting. Use uint8_t* for the byte cast, which RadioHead requires for the sending of the struct. This compiles and should be received with an equivalent struct in the receiving sketch.
You, Sir, are a genious wizard and magician! Now I can send doubles, longs and whatever from one nrf905 to the other.
That saves my day, week, month and year! You have no idea how much time I have spent trying to figure that out.
I think that the TMRh20 version of the RF24 library and the ManiacBug RF24 library used with the nRF24L01 radios use
radio.write(&dataToSend, sizeof(dataToSend))
On the receive, you can use memcpy to transfer the bytes from the standard library receive buffer into the data structure you want, or receive directly to the memory address of the data structure.