Skip to content

Instantly share code, notes, and snippets.

@jscrane
Created February 20, 2014 13:41
Show Gist options
  • Save jscrane/9113801 to your computer and use it in GitHub Desktop.
Save jscrane/9113801 to your computer and use it in GitHub Desktop.
TinyRelay sketch
#include <SoftwareSerial.h>
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include <EEPROM.h>
RF24 radio(2, 3);
RF24Network network(radio);
const int rx = 1, tx = 0;
SoftwareSerial serial(rx, tx);
const uint16_t master_node = 0;
uint16_t this_node;
void setup(void)
{
pinMode(rx, INPUT);
pinMode(tx, OUTPUT);
serial.begin(9600);
serial.println("Sensor Relay.");
SPI.begin();
radio.begin();
radio.enableDynamicPayloads();
radio.setAutoAck(true);
this_node = EEPROM.read(0);
network.begin(90, this_node);
}
void loop(void)
{
network.update();
while (network.available()) {
// message for us
RF24NetworkHeader h;
network.peek(h);
// FIXME: do something
serial.println("got message");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment