Arduino UNO + RFM22B + RadioHead library communication problem

Hello.

I’m trying to connect two UNOs with two RFM22Bs. The RFM22Bs are DIP, like the linked but 433mhz, without any shield (using a prototyping board). They’re connected the way it’s described in the RadioHead library by mikem (RH_RF22.h header). All required Arduino outputs go through a voltage divider (AFAICT). Additionally, the shutdown pin is connected to D3 (unused ATM).

I’m trying to get the rf22 reliable datagram client/server example working. Made some code changes.

The code for server:

// RH22 reliable datagram server

#include <RH_RF22.h>
#include <RHReliableDatagram.h>


#define CLIENT_ADDRESS 9
#define SERVER_ADDRESS 1

RH_RF22 driver(10, 2);
RHReliableDatagram manager(driver, SERVER_ADDRESS);

void setup(void) 
{ 
  randomSeed(analogRead(0));
  Serial.begin(9600);
  if (manager.init())
    Serial.println("RFM22B SERVER init OK");
  else
    Serial.println("RFM22B SERVER init FAIL");
} 

uint8_t data[] = "And hello back to you";
uint8_t buf[RH_RF22_MAX_MESSAGE_LEN];

void loop(void) 
{ 
  if (manager.available())
  {
    uint8_t len = RH_RF22_MAX_MESSAGE_LEN;
    uint8_t from;
    for (uint8_t i = 0; i < len; ++i)
      buf[i] = random(65,87);
    if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
    {
      Serial.print("got request from : 0x");
      Serial.print(from, HEX);
      Serial.print(": ");
      Serial.println((char*)buf);

      if (manager.sendtoWait(data, sizeof(data), from))
        Serial.println("sendtoWait OK");
      else
        Serial.println("sendtoWait FAIL");
    }
    else
    {
      Serial.println("no MSG");
    }
  }
  else
   Serial.println("UNAVAILABLE");

 delay(200); 
}

And the code for the client:

#include <RH_RF22.h>
#include <RHReliableDatagram.h>

#define CLIENT_ADDRESS 9
#define SERVER_ADDRESS 1

RH_RF22 driver(10, 2);
RHReliableDatagram manager(driver, CLIENT_ADDRESS);

void setup() 
{
  randomSeed(analogRead(0));
  Serial.begin(9600);
  if (manager.init())
    Serial.println("RFM22B CLIENT init OK");
  else
    Serial.println("RFM22B CLIENT init FAIL");
}

uint8_t data[] = "Hello World!";
uint8_t buf[RH_RF22_MAX_MESSAGE_LEN];

void loop()
{
  Serial.println("Sending to rf22_reliable_datagram_server");
  
  if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
  {
    Serial.println("sendtoWait OK");
    uint8_t len = RH_RF22_MAX_MESSAGE_LEN;
    uint8_t from;
    for (uint8_t i = 0; i < len; ++i)
      buf[i] = random(65,87);
    if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
    {
      Serial.print("got reply from : 0x");
      Serial.print(from, HEX);
      Serial.print(": ");
      Serial.println((char*)buf);
    }
    else
    {
      Serial.println("No reply, is rf22_reliable_datagram_server running?");
    }
  }
  else
  {
    Serial.println("sendtoWait FAIL; trying receive");
    uint8_t len = RH_RF22_MAX_MESSAGE_LEN;
    uint8_t from;
    for (uint8_t i = 0; i < len; ++i)
      buf[i] = random(65,87);
    if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
      Serial.println("received");
  }
  delay(3000);
}

The problem is that it works… for a short while.
The server prints this:

UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
got request from : 0x9: Hello World!
sendtoWait OK
DATA: And hello back to you 
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
got request from : 0x9: Hello World!
sendtoWait OK
DATA: And hello back to you 
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
UNAVAILABLE
got request from : 0x9: Hello World!

…then it hangs (i suspect in sendToWait). The client seem to work without hanging (and if i reset the server, both work again for a while):

sendtoWait OK
got reply from : 0x1: And hello back to you
Sending to rf22_reliable_datagram_server
sendtoWait OK
got reply from : 0x1: And hello back to you
Sending to rf22_reliable_datagram_server
sendtoWait OK
got reply from : 0x1: And hello back to you
Sending to rf22_reliable_datagram_server
sendtoWait OK
got reply from : 0x1:  you
Sending to rf22_reliable_datagram_server
sendtoWait FAIL
Sending to rf22_reliable_datagram_server

Also, as the client log shows, messages become garbage after a while. Anyone has idea if this is a hardware / software problem and how to debug this ? I have some experience with programming but only basic with electronics (and none with radio related electronics).

Thanks