Go Down

Topic: reliable datagram RF22 library question (Read 3 times) previous topic - next topic


Mar 20, 2013, 12:52 pm Last Edit: Mar 20, 2013, 12:56 pm by Boffin1 Reason: 1
For my next project, which is a remote control and telemetry link to a very large robot,  I want to have a safe wireless link with a range of at least 300meters.  I can use a decent antenna at the control centre, and a dipole on the robot, so range should be no problem.

I have used the RFM22B modules before, but only in the basic simplex mode,   I now have 2 of them hooked up on the bench and using the RF22 libraries "reliable datagram"  example from Mikem , with 2 Duemilanova boards for now ( they will have embedded chip pcbs in the final units ).

It worked first time, and I have found how to simply read the temperature and signal strength etc.

Now I am looking at how to structure my data, (  which is joysticks and switch data going to the robot, and a few oil pressure, fuel guage, temperature , signal strength and GPS position data coming back )

I was planning to collect the data and put it in a buffer to send, all in the main loop as usual.

In Mikes example below, he has defined the data and datalength between the setup and loop sections ?
Is there significance to this ?
I guess thats the same as having them at the top with the definitions if they are not going to change ?  

and I can find no reference to        while (1)  ?  and why    // Dont put this on the stack:

Code: [Select]

// rf22_reliable_datagram_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple addressed, reliable messaging client
// with the RF22ReliableDatagram class.
// It is designed to work with the other example rf22_reliable_datagram_server
#include <RF22ReliableDatagram.h>
#include <RF22.h>
#include <SPI.h>
// Singleton instance of the radio
RF22ReliableDatagram rf22(CLIENT_ADDRESS);
void setup()
if (!rf22.init())
Serial.println("RF22 init failed");
// Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
uint8_t data[] = "Hello World!";
// Dont put this on the stack:
uint8_t buf[RF22_MAX_MESSAGE_LEN];
void loop()
while (1)
Serial.println("Sending to rf22_datagram_server");
// Send a message to rf22_server
if (!rf22.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
Serial.println("sendtoWait failed");
// Now wait for a reply from the server
// Serial.println(rf22.lastRssi(), HEX); // of the ACK
uint8_t len = sizeof(buf);
uint8_t from;
if (rf22.recvfromAckTimeout(buf, &len, 2000, &from))
Serial.print("got reply from : 0x");
Serial.print(from, HEX);
Serial.print(": ");
Serial.println("No reply, is rf22_datagram_server running?");

With my mobile phone I can call people and talk to them -  how smart can you get ?


Is there significance to this ?

No. Anything declared outside of a function is global. Whether that happens before the first function, between functions, or after the last function does not matter.

and I can find no reference to        while (1)  ?

It's running an infinite loop, inside an infinite loop, so it's silly. Get rid of it.

and why    // Dont put this on the stack:

It's suggesting that the array should not be passed as an argument to a function. Passing arguments makes use of the stack. Of course, it would only out the address on the stack, and there is no problem with that, so the comment is useless.


Thanks Paul,   I shall move on now then
With my mobile phone I can call people and talk to them -  how smart can you get ?


On a different point, have you verified the RFM22s can communicate out to 300m?
I would check this before going very far with the rest of it. What frequency are you
using, 433 Mhz? BTW, I have the RFM12, 1 mW module, and got range to about
120 feet [36m] at 433. RFM22 will certainly be a lot farther.

How do you plan to connect antennas to the modules? They are made for those 1/4
whip antennas [ie, piece of wire soldered on]. Do you know if the modules will
function properly with something else, like a soldered-on coax leading to a external


I have only got these modules hooked up accross the bench at the moment , but I want to test the range tomorrow.

I had over 150m range with the modules in the simplex mode ( I didn't check further as I was at the end of the road and only needed 100m ! )
With my mobile phone I can call people and talk to them -  how smart can you get ?

Go Up