I've been trying to figure out how the nodes work .
So I want to have my base node 0, and a child 1 , and a leaf node 11 .
I want to be able to send a package from 11 to 0 but to go thru note 1.
Also if I have another child 2 and leaf 12 how to make base node to listen to them ?
Can someone share with me some examples of a base node and others?
thank you , but in the long term I would like to use the RF24Network and RF24 Library .
Did some tests again still can not figure how to make the leaf node (21) to talk to base node 0 thru node 1.
This would be the first step.
/*
Copyright (C) 2012 James Coliz, Jr. <maniacbug@ymail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
*/
/**
* Simplest possible example of using RF24Network,
*
* RECEIVER NODE
* Listens for messages from the transmitter and prints them out.
*/
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
// nRF24L01(+) radio attached using Getting Started board
RF24 radio(40,53);
// Network uses that radio
RF24Network network(radio);
// Address of our node
const uint16_t this_node = 0;
// Address of the other node
const uint16_t other_node = 1;
const uint16_t leaf_node = 11;
const unsigned long interval = 2000;
unsigned long last_sent;
unsigned long packets_sent;
// Structure of our payload
struct payload_t
{
unsigned long ms;
unsigned long counter;
};
void setup(void)
{
Serial.begin(57600);
Serial.println("RF24Network BASE : NODE 00");
SPI.begin();
radio.begin();
network.begin(/*channel*/ 90, /*node address*/ this_node);
}
void loop(void)
{
// Pump the network regularly
network.update();
//Sending
// If it's time to send a message, send it!
unsigned long now = millis();
if ( now - last_sent >= interval )
{
last_sent = now;
Serial.print("Trying to send data to leaf...");
payload_t payload = { millis(), packets_sent++ };
RF24NetworkHeader header(/*to node*/ leaf_node);
bool ok = network.write(header,&payload,sizeof(payload));
if (ok)
Serial.println("ok.");
else
Serial.println("failed.");
}
// Is there anything ready for us?
while ( network.available() )
{
// If so, grab it and print it out
RF24NetworkHeader header;
payload_t payload;
network.read(header,&payload,sizeof(payload));
Serial.print("Received packet #");
Serial.print(payload.counter);
Serial.print(" at ");
Serial.println(payload.ms);
}
}
// vim:ai:cin:sts=2 sw=2 ft=cpp
My Node 11 (leaf) looks like this.
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
// nRF24L01(+) radio attached using Getting Started board
RF24 radio(9,10);
// Network uses that radio
RF24Network network(radio);
// Address of our node
const uint16_t this_node = 11;
// Structure of our payload
struct payload_t
{
unsigned long ms;
unsigned long counter;
};
void setup(void)
{
Serial.begin(57600);
Serial.println("RF24Network/examples/helloworld_rx/");
SPI.begin();
radio.begin();
network.begin(/*channel*/ 90, /*node address*/ this_node);
}
void loop(void)
{
// Pump the network regularly
network.update();
// Is there anything ready for us?
while ( network.available() )
{
// If so, grab it and print it out
RF24NetworkHeader header;
payload_t payload;
network.read(header,&payload,sizeof(payload));
Serial.print("Received packet #");
Serial.print(payload.counter);
Serial.print(" at ");
Serial.println(payload.ms);
}
}
// vim:ai:cin:sts=2 sw=2 ft=cpp
Base : Mega 2560
Node 1: UNO
Node 11: UNO
is my code ok by now ? How the code for node 1 should look like so data sent from base to leaf 11 to go thru node 1?
same boat here. Anyone have a hello-world example of RF24Network in action? I spun up the examples that were in the lib, modified things a bit, but still can't get more than 2 nodes talking.