Created
February 20, 2014 13:41
-
-
Save jscrane/9113801 to your computer and use it in GitHub Desktop.
TinyRelay sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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