rf24nework problem - sleep mode

hello all!!

i'm new in here and i have problem with the sleep mode of rf24network.

i'm trying to use the example sketch (network_ping sleep) and i get erorr in the compiling...

Arduino: 1.6.5 (Windows 7), Board: "Arduino/Genuino Uno"

Network_Ping_Sleep11.cpp.o: In function `setup':
C:\Program Files (x86)\Arduino/Network_Ping_Sleep11.ino:104: undefined reference to `RF24Network::setup_watchdog(unsigned char)'
Network_Ping_Sleep11.cpp.o: In function `loop':
C:\Program Files (x86)\Arduino/Network_Ping_Sleep11.ino:139: undefined reference to `RF24Network::sleepNode(unsigned int, int)'
collect2.exe: error: ld returned 1 exit status
Multiple libraries were found for "SPI.h"

 Used: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI

 Not used: C:\Users\yoav\Documents\Arduino\libraries\ILI9341-LCD-Module-master

Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

why it's not compile???

i dont find anyone that it's heppend to him...

yoavshtainer: why it's not compile???

Post your code so we can see what the problem might be.


the code is the example network_ping_sleep

#include <avr/pgmspace.h>
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include "printf.h"
#include <avr/sleep.h>
#include <avr/power.h>

************* Set the Node Address *************************************

// These are the Octal addresses that will be assigned
const uint16_t node_address_set[10] = { 00, 02, 05, 012, 015, 022, 025, 032, 035, 045 };

// 0 = Master
// 1-2 (02,05)   = Children of Master(00)
// 3,5 (012,022) = Children of (02)
// 4,6 (015,025) = Children of (05)
// 7   (032)     = Child of (02)
// 8,9 (035,045) = Children of (05)

uint8_t NODE_ADDRESS = 1; // Use numbers 0 through 9 to select an address from the array


RF24 radio(7,8);                                    // CE & CS pins to use (Using 7,8 on Uno,Nano)
RF24Network network(radio); 

uint16_t this_node;                                  // Our node address

const unsigned long interval = 1000; // ms           // Delay manager to send pings regularly. Because of sleepNode(), this is largely irrelevant.
unsigned long last_time_sent;

const short max_active_nodes = 10;                    // Array of nodes we are aware of
uint16_t active_nodes[max_active_nodes];
short num_active_nodes = 0;
short next_ping_node_index = 0;

bool send_T(uint16_t to);                              // Prototypes for functions to send & handle messages
bool send_N(uint16_t to);
void handle_T(RF24NetworkHeader& header);
void handle_N(RF24NetworkHeader& header);
void add_node(uint16_t node);

//This is for sleep mode. It is not really required, as users could just use the number 0 through 10
typedef enum { wdt_16ms = 0, wdt_32ms, wdt_64ms, wdt_128ms, wdt_250ms, wdt_500ms, wdt_1s, wdt_2s, wdt_4s, wdt_8s } wdt_prescalar_e;

unsigned long awakeTime = 500;                          // How long in ms the radio will stay awake after leaving sleep mode
unsigned long sleepTimer = 0;                           // Used to keep track of how long the system has been awake

void setup(){

  this_node = node_address_set[NODE_ADDRESS];            // Which node are we?
  SPI.begin();                                           // Bring up the RF network
  network.begin(/*channel*/ 100, /*node address*/ this_node );

  network.setup_watchdog(wdt_1s);                       //The watchdog timer will wake the MCU and radio every second to send a sleep payload, then go back to sleep

void loop(){
  network.update();                                      // Pump the network regularly

   while ( network.available() )  {                      // Is there anything ready for us?
    RF24NetworkHeader header;                            // If so, take a look at it

      switch (header.type){                              // Dispatch the message to the correct handler.
        case 'T': handle_T(header); break;
        case 'N': handle_N(header); break;
   /************* SLEEP MODE *********/
  // Note: A 'sleep' header has been defined, and should only need to be ignored if a node is routing traffic to itself
  // The header is defined as:  RF24NetworkHeader sleepHeader(/*to node*/ 00, /*type*/ 'S' /*Sleep*/);    
         case 'S': /*This is a sleep payload, do nothing*/ break;
        default:  printf_P(PSTR("*** WARNING *** Unknown message type %c\n\r"),header.type);

  if(millis() - sleepTimer > awakeTime&& NODE_ADDRESS){  // Want to make sure the Arduino stays awake for a little while when data comes in. Do NOT sleep if master node.
     sleepTimer = millis();                           // Reset the timer value
     delay(100);                                      // Give the Serial print some time to finish up
     radio.stopListening();                           // Switch to PTX mode. Payloads will be seen as ACK payloads, and the radio will wake up
     network.sleepNode(8,0);                          // Sleep the node for 8 cycles of 1second intervals
   // network.sleepNode( cycles, interrupt-pin );
   // network.sleepNode(0,0);         // The WDT is configured in this example to sleep in cycles of 1 second. This will sleep 1 second, or until a payload is received 
   // network.sleepNode(1,255);       // Sleep this node for 1 second. Do not wake up until then, even if a payload is received ( no interrupt ) Payloads will be lost.
                                /****  end sleep section ***/  
  unsigned long now = millis();                         // Send a ping to the next node every 'interval' ms
  if ( now - last_time_sent >= interval ){
    last_time_sent = now;

    uint16_t to = 00;                                   // Who should we send to? By default, send to base
    if ( num_active_nodes ){                            // Or if we have active nodes,
        to = active_nodes[next_ping_node_index++];      // Send to the next active node
        if ( next_ping_node_index > num_active_nodes ){ // Have we rolled over?
    next_ping_node_index = 0;                   // Next time start at the beginning
    to = 00;                                    // This time, send to node 00.

    bool ok;

    if ( this_node > 00 || to == 00 ){                    // Normal nodes send a 'T' ping
        ok = send_T(to);   
    }else{                                                // Base node sends the current active nodes out
        ok = send_N(to);
    if (ok){                                              // Notify us of the result
        printf_P(PSTR("%lu: APP Send ok\n\r"),millis());
        printf_P(PSTR("%lu: APP Send failed\n\r"),millis());
        last_time_sent -= 100;                            // Try sending at a different time next time

bool send_T(uint16_t to)
  RF24NetworkHeader header(/*to node*/ to, /*type*/ 'T' /*Time*/);
  // The 'T' message that we send is just a ulong, containing the time
  unsigned long message = millis();
  printf_P(PSTR("%lu: APP Sending %lu to 0%o...\n\r"),millis(),message,to);
  return network.write(header,&message,sizeof(unsigned long));

bool send_N(uint16_t to)
  RF24NetworkHeader header(/*to node*/ to, /*type*/ 'N' /*Time*/);
  printf_P(PSTR("%lu: APP Sending active nodes to 0%o...\n\r"),millis(),to);
  return network.write(header,active_nodes,sizeof(active_nodes));

void handle_T(RF24NetworkHeader& header){

  unsigned long message;                                                                      // The 'T' message is just a ulong, containing the time
  network.read(header,&message,sizeof(unsigned long));
  printf_P(PSTR("%lu: APP Received %lu from 0%o\n\r"),millis(),message,header.from_node);

  if ( header.from_node != this_node || header.from_node > 00 )                                // If this message is from ourselves or the base, don't bother adding it to the active nodes.

void handle_N(RF24NetworkHeader& header)
  static uint16_t incoming_nodes[max_active_nodes];

  printf_P(PSTR("%lu: APP Received nodes from 0%o\n\r"),millis(),header.from_node);

  int i = 0;
  while ( i < max_active_nodes && incoming_nodes[i] > 00 )

 * Add a particular node to the current list of active nodes
void add_node(uint16_t node){
  short i = num_active_nodes;                                    // Do we already know about this node?
  while (i--)  {
    if ( active_nodes[i] == node )
  if ( i == -1 && num_active_nodes < max_active_nodes ){         // If not, add it to the table
      active_nodes[num_active_nodes++] = node; 
      printf_P(PSTR("%lu: APP Added 0%o to list of active nodes.\n\r"),millis(),node);

Post a link to where you got the code. I don't see it on maniacBug's github.

Have you installed the libraries properly?


yes, i think i install the libraries properly... all other examples work fine.

the link is:


i download the RF24Network_Devlopmet

and he need the the RF24 - MASTER (i change this library to RF24 according to the writer)

I discovered tmrh20's version of the basic RF24 library yesterday and I plan to use it. However I am not familiar with the network library.


thenk you for your replay.

if any one know what is going wrong in my case, please help me!!

Go to RF24Network_config.h and erase the comments in line //#define ENABLE_SLEEP_MODE //AVR only