RF12 packet loss

I’ve been trying to see how many packets are lost with a Jeenode I have on my roof about 50m from the receiver in side the house. There is a lot of mechanical objects between the two nodes (furnace, etc…).

I was having times when several hours would go by without a packet, then it would be fine for a day missing only a few packets here and there. I altered the code to keep track of how many packets it tries to send and if it fails. I posted on the JeeLab’s forum and got a quick response, but nothing which solved the problem. You can see the post here.

The sensor node collects its data once per minute and tries up to 9 times to send the packet. It waits 100ms after sending to see if it gets an ACK from the receiver. If it doesn’t then it tries to send again. After 9 attempts, it gives up and increments the failed counter which will eventually get sent with the next ACK’d packet.

The sensor node also goes to sleep in between sending. It currently collects 3 temperatures (from my solar thermal setup), irradiance from a pyranometer using the MCP3833 ADC and the Lipo battery voltage also using the MCP3833.

Here is the latest code’s loop().

void loop () {
 int ack = 0;
 m.retries = 0;

 // edited out the non-relevant parts where it collects the data
// m is a struct with the data

 rf12_sleep(RF12_WAKEUP);  // turn on radio
 while (ack == 0) {
   rf12_sendStart(RF12_HDR_ACK,&m,sizeof m);

   // wait up to 100 ms to get an ack back
   MilliTimer t;
   while (!t.poll(100)) {
     if (rf12_recvDone() && rf12_crc == 0 && rf12_len == 0) {
     // Got ACK from receiver
     ack = 1;
     m.failed_packets = 0;
 if (m.retries > 8 ) {
 if(ack == 1)

It seems to work relatively well. I still lose packets for some reason. Actually seems like the rain affects sending/receiving. I’m using 915MHZ with the wire whip antenna. I might switch to 433MHZ and a SMA antenna to see if that changes anything.

You can see a graph here:

At the end you can see a couple of missed packets, so the failed packet counter goes up. The second miss of a packet was actually a case where the receiver got the packet, sent the ACK, but the receiver didn’t get it so it sent its packet again. Happens fairly frequently. I’m not sure the cause. The 8, 5 and 8 missed packets in a row is the case where the receiver got each packet and ACK’d, but the sender didn’t get the ACKs.

I have the ACK right after the rf12_recvDone(), more or less. Here is the relevant snippet in the receiver code:

// Receive Data from RFM12
 if (rf12_recvDone() && rf12_crc == 0 && (rf12_hdr & RF12_HDR_CTL) == 0 && (rf12_len == sizeof(Payload) || rf12_len == sizeof(Payload_temp))) {
   memcpy(doubleBuf, (void*) rf12_data, rf12_len);
   if (RF12_WANTS_ACK) {
     Serial.println("\n\n-----------------\n\n -> ACK");

Sometimes it will happen 3 or 4 times in rapid succession. Any thoughts??

If anyone is interested here is a graph of the 3 temps and irradiance:
Tags: ,