Fair enough, Below is the code I have been trying to modify :
TX
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
define RELAY_PIN 8
RF24 radio(9,10);
// Network uses that radio
RF24Network network(radio);
// Address of our node
const uint16_t this_node = 1;
// Address of the other node
const uint16_t other_node = 0;
// How often to send 'hello world to the other unit
// const unsigned long interval = 2000;
// When did we last send?
unsigned long last_sent;
// How many have we sent already
unsigned long packets_sent;
// Structure of our payload
struct payload_t
{
unsigned long ms;
unsigned long counter;
};
void setup(void)
{
pinMode(RELAY_PIN, OUTPUT);
Serial.begin(57600);
SPI.begin();
radio.begin();
network.begin(/channel/ 90, /node address/ this_node);
Serial.println("Press the spacebar to toggle relay on/off");
}
void loop(void)
{
// Pump the network regularly
network.update();
unsigned long now = 0;
static int relayVal = 0;
int cmd;
while (Serial.available() > 0)
{
cmd = Serial.read();
switch (cmd)
{
case ' ':
{
relayVal ^= 1; // xor current value with 1 (causes value to toggle)
if (relayVal)
Serial.println("Relay on");
else
Serial.println("Relay off");
break;
}
default:
{
Serial.println("Press the spacebar to toggle relay on/off");
}
}
if (relayVal)
digitalWrite(RELAY_PIN, HIGH);
else
digitalWrite(RELAY_PIN, LOW);
}
// if ( now - last_sent >= interval )
{
// last_sent = now;
//Serial.print("Waiting for spacebar to toggle...");
//payload_t payload = { millis(), packets_sent++ };
RF24NetworkHeader header(/to node/ other_node);
//bool ok = network.write(header,&payload,sizeof(payload));
// if (ok)
// Serial.println("ok.");
// else
// Serial.println("failed.");
}
}
RX
#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 = 0;
// Address of the other node
const uint16_t other_node = 1;
// 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));
digitalWrite(8, HIGH);
//delay(200);
//digitalWrite(13, LOW);*/
/Serial.print("Received packet #");
//Serial.print(payload.counter);
//Serial.print(" at ");
// Serial.println(payload.ms);/
}
}
I just need to know how to send the information to the rx node. Any help?