Created
April 9, 2018 17:06
-
-
Save paulirwin/53e4a5a1bc4768fd11ebff4fa9890303 to your computer and use it in GitHub Desktop.
RF24 issue with Hologram Dash
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
/* | |
Copyright (C) 2012 James Coliz, Jr. <[email protected]> | |
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. | |
Update 2014 - TMRh20 | |
*/ | |
/** | |
* Simplest possible example of using RF24Network | |
* | |
* TRANSMITTER NODE | |
* Every 2 seconds, send a payload to the receiver node. | |
*/ | |
#include <RF24Network.h> | |
#include <RF24.h> | |
#include <SPI.h> | |
RF24 radio(D01,D02); // nRF24L01(+) radio attached using Getting Started board | |
RF24Network network(radio); // Network uses that radio | |
const uint16_t this_node = 01; // Address of our node in Octal format | |
const uint16_t other_node = 00; // Address of the other node in Octal format | |
const unsigned long interval = 2000; //ms // How often to send 'hello world to the other unit | |
unsigned long last_sent; // When did we last send? | |
unsigned long packets_sent; // How many have we sent already | |
struct payload_t { // Structure of our payload | |
unsigned long ms; | |
unsigned long counter; | |
}; | |
void setup(void) | |
{ | |
Serial.begin(57600); | |
for (int i = 10; i > 0; i--) { | |
Serial.print("Waiting "); | |
Serial.print(i); | |
Serial.println(" seconds for serial monitor..."); | |
delay(1000); | |
} | |
Serial.println("RF24Network/examples/helloworld_tx/"); | |
Serial.println("SPI starting..."); | |
SPI.begin(); | |
Serial.println("RF24 radio starting..."); | |
radio.begin(); | |
Serial.println("RF24 network starting..."); | |
network.begin(/*channel*/ 90, /*node address*/ this_node); | |
} | |
void loop() { | |
network.update(); // Check the network regularly | |
unsigned long now = millis(); // If it's time to send a message, send it! | |
if ( now - last_sent >= interval ) | |
{ | |
last_sent = now; | |
Serial.print("Sending..."); | |
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."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment