nrf24 / rf24network Goto Github PK
View Code? Open in Web Editor NEWOSI Layer 3 Networking for nRF24L01(+) and nRF52x on Arduino and Raspberry Pi
Home Page: https://nrf24.github.io/RF24Network/
License: GNU General Public License v2.0
OSI Layer 3 Networking for nRF24L01(+) and nRF52x on Arduino and Raspberry Pi
Home Page: https://nrf24.github.io/RF24Network/
License: GNU General Public License v2.0
Hello!
I'm currently upgrading my build environment with updated lib versions, and have encountered a problem compiling RF24Network ontop of new 'arch' model.
RF24Network_config.h has lines
#ifndef __RF24_CONFIG_H__
#define __RF24_CONFIG_H__
[skipped]
#endif
which effectively makes any arch redefinitions made in actual RF24_config.h unused while compiling RF24Network. Can macros defined in these lines be defined globally? or can actual RF24_config be included where? I'm willing to restructure config file, but I'll need some guides to save consistency across all platforms.
THMr20 proposes the use of byte offsets for the fragments.
Like the IPv4 fragmentation protocol, the RF24Network fragmentation should use byte offsets (header.fragment_id) to map the received payloads.
Duplicates should simply overwrite the existent payload in the cache.
This mechanism should save some bandwidth if e.g. two different frames take two different routes from the sender to the receiver.
Add fragmentation to the multicast code
Is this reasonable?
Is this useful?
Do we need this?
I can make two arduinos work together but not a rPi and an Arduino:
base.cpp
#include <RF24/RF24.h>
#include <RF24Network/RF24Network.h>
#include <iostream>
#include <ctime>
#include <stdio.h>
#include <time.h>
using namespace std;
//////////////////////////////////////
// Create the structures for data
//////////////////////////////////////
struct data_received {
uint16_t node;
uint16_t temp;
uint16_t humi;
uint16_t light;
uint16_t door;
uint16_t pir;
uint32_t hkey;
};
struct data_to_send {
uint32_t hkey;
}confirm;
unsigned long finish = 0;
unsigned long elapsed = 0;
//////////////////////////////////////
// Setup nRF24L01+ module & Oled
//////////////////////////////////////
RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ);
RF24Network network(radio);
const uint64_t this_node = 00; // base
//////////////////////////////////////
// loop
//////////////////////////////////////
int main(int argc, char** argv)
{
//////////////////////////////////////
// setup
//////////////////////////////////////
// Initialize interfaces
cout<<"Starting interfaces...";
radio.begin();
radio.setRetries(7,7);
delay(5);
cout<<"complete]\n";
network.begin(90, this_node);
radio.setDataRate(RF24_250KBPS);
radio.printDetails();
while(1) {
network.update();
data_received payload;
cout<<"**"<<network.available()<<'\n';
// listen for incoming clients
while ( network.available() )
{
RF24NetworkHeader header;
confirm.hkey = 0;
// read the next available header
network.peek(header);
// print NRF24 header data
cout<<"\n[header info => id: ";
cout<<header.id<<" type: ";
cout<<header.type<<" from_node: ";
cout<<header.from_node<<"]";
// read data
network.read( header, &payload, sizeof(payload) );
// Print data received
cout<<"[NODE: "<<payload.node<<" ]=> ";
cout<<"[temp: "<<payload.temp<<"*C] ";
cout<<"[humi: "<<((float)payload.humi)<<"%] ";
cout<<"[light: "<<((float)payload.light)<<"%] ";
cout<<"[door: "<<payload.door<<"] ";
cout<<"[pir: "<<payload.pir<<"] ";
cout<<"[hkey: "<<payload.hkey<<"] ";
// send back data to confirm integrity
confirm.hkey = payload.hkey;
cout<<"...";
RF24NetworkHeader header2(header.from_node);
// starts counting just before sending
elapsed = 0;
unsigned long start = millis();
bool sent_back = network.write( header2, &confirm, sizeof(confirm));
if (sent_back == true){
finish = millis();
elapsed = finish - start;
cout<<elapsed;
cout<<"ms";
cout<<" - Confirmed back \n";
}
else{
cout<<"Not confirmed";
}
}
int value = 0;
float vin = 0.0;
value = payload.light;
vin = 3.472 * value / 1024;
cout<<"VIn: "<<vin<<'\n';
cout<<"Listening for nodes.."<<'\n';
delay(1000);
}
return 0;
}
a node (arduino)
#include <dht11.h>
#include "RF24Network.h"
#include "RF24.h"
#include <SPI.h>
#include "printf.h"
#include <JeeLib.h>
//////////////////////////////////////
// Create the structures for data
//////////////////////////////////////
struct data_to_send {
uint16_t node;
uint16_t temp;
uint16_t humi;
uint16_t light;
uint16_t door;
uint16_t pir;
uint32_t hkey;
};
struct data_received {
uint32_t hkey = 0;
};
//////////////////////////////////////
// Setup nRF24L01+ module
//////////////////////////////////////
RF24 radio(8,7);
RF24Network rf24Net(radio);
const uint64_t this_node = 02; // node A
const uint64_t other_node = 00; // base
//////////////////////////////////////
// Setup the rest of it
//////////////////////////////////////
const int led_A_Pin = 6;
const int optoPin = A2;
unsigned long currentTime = 0;
unsigned long startTime = 0;
bool runOnce = true;
ISR(WDT_vect) { Sleepy::watchdogEvent(); } // Setup the watchdog
//////////////////////////////////////
// setup
//////////////////////////////////////
void setup(void) {
// Initialize interfaces
printf_begin();
Serial.begin(9600);
Serial.print(F("Starting interfaces..."));
SPI.begin();
radio.begin();
Serial.print(F("complete]\n"));
rf24Net.begin(90, this_node);
radio.setDataRate(RF24_250KBPS);
radio.printDetails();
analogReference(INTERNAL);
// initialize pins
pinMode(led_A_Pin, OUTPUT);
}
//////////////////////////////////////
// loop
//////////////////////////////////////
uint32_t txTimer = 0;
void loop(void)
{
digitalWrite(led_A_Pin, HIGH);
delay(200);
digitalWrite(led_A_Pin, LOW);
delay(200);
digitalWrite(led_A_Pin, HIGH);
currentTime = millis();
if (currentTime - startTime <= 1000) {
Serial.println(currentTime - startTime);
}
else {
digitalWrite(led_A_Pin, LOW);
}
rf24Net.update();
if (millis() - txTimer > 1000) {
data_to_send payload;
payload.node = 02;
payload.temp = 11;
payload.humi = 11;
payload.light = analogRead(A2);
payload.door = 0;
payload.pir = 0;
payload.hkey = random(10000000, 99999999);
// starts counting
unsigned long elapsed = 0;
unsigned long start = millis();
Serial.println(payload.hkey);
digitalWrite(led_A_Pin, HIGH);
delay(100);
digitalWrite(led_A_Pin, LOW);
delay(100);
digitalWrite(led_A_Pin, HIGH);
delay(100);
digitalWrite(led_A_Pin, LOW);
delay(100);
// sends packet
RF24NetworkHeader header(other_node);
Serial.println("Sending data to base every 30 sec.");
txTimer = millis();
bool ok = rf24Net.write( header, &payload, sizeof(payload) );
if (ok) {
unsigned long finish = millis();
elapsed = finish - start;
Serial.println("ok.");
Serial.print(elapsed);
Serial.print("ms\n");
rf24Net.update();
}
else {
Serial.println("failed.");
}
}
while ( rf24Net.available() )
{
Serial.println("Received packet");
RF24NetworkHeader header2;
data_received confirm;
rf24Net.read(header2, &confirm, sizeof(confirm));
Serial.println(confirm.hkey);
Serial.println("------------------------------");
Serial.println(F("Going to sleep..."));
delay(100);
radio.powerDown();
Sleepy::loseSomeTime(2000);
radio.powerUp();
Serial.println(F("Woke up!"));
}
}
Can you please help? Is it a bug or am I doing something wrong ?
The /* Sleep Mode */ code seems to conflict with custom sleep code, and for the majority of my sensor nodes that means Rocket Scream's LowPower library.
Any chance we could get a flag do disable the /* Sleep Mode */ so that we can continue to use custom power management code? Things appear to work fine without it (I commented it out for my relay nodes)
okay, on the platform I'm using if I fail to have the frame_queue declared as public, I get memory reference crashes... I resolved it by declaring it public.
line 814-818
uint8_t frame_queue[1];
uint8_t frame_queue[MAIN_BUFFER_SIZE];
Implement new fragmentation header types and fragment_id management commented in
e34a394#commitcomment-7727886
Improve the code to use a small memory footprint.
Improvements to use only the needed variables and objects.
provides just such a mistake
C:\Users\arturmon\Desktop\arduino-1.5.6-r2\libraries\RF24Network\RF24Network.cpp: In member function 'const char* RF24NetworkHeader::toString() const':
C:\Users\arturmon\Desktop\arduino-1.5.6-r2\libraries\RF24Network\RF24Network.cpp:333: error: 'snprintf_P' was not declared in this scope
C:\Users\arturmon\Desktop\arduino-1.5.6-r2\libraries\RF24Network\RF24Network.cpp: In function 'bool is_valid_address(uint16_t)':
C:\Users\arturmon\Desktop\arduino-1.5.6-r2\libraries\RF24Network\RF24Network.cpp:437: error: 'printf_P' was not declared in this scope
Is this needed?
Is there a use case?
I have started to take a look at the RF24Network library and it looks like you need to make some of the type of changes you made to the RF24 library when you added the Arch directory. Is this something you can do and what sort of time frame would it take. I am interested in it but do not want to push you as I can get by for now with the RF24 library.
I've spent several hours on this now -going back and forward between MANIGBUG and this development software.
I have routines sending data back and forward between unit 0 and 1 - unit 0 always in charge - ie sends something - waits for a reply.
In BOTH MANICBUG and the DEV version here - the OK flag (sending data) returns zero all the time - I'd never used it before so never noticed - it's supposed to be true if the send was successful.
In the DEV version I can send data to unit 1 but can't get a reply from unit 1... I'd assumed that was somehow tied to the ACK.. but no... the MANICBUG library works perfectly - data goes both ways.
Thoughts anyone (and yes, the boards work, the NRF boards have caps on them). Unit 1 is a 328-based board - unit 0 is a 1284p based board - I've checked the source and can't see any conditional code for 2560s etc that might need the 1284 board adding...
I have 3 nodes, 00, 01, and 21. 01 is just a sketch with network.update(). 21 is supposed to send data to 00 but it does not seem to be working.
I reduced the setup to just node 00 and 01 (previously 21) and sending to 00 from 01 is working fine.
Am I setting up the nodes incorrectly?
hi, I received the following error message when compiling the example of node sleep on a Arduino UNO:
Arduino: 1.5.8 (Mac OS X), Placa:"Arduino Uno"
Network_Ping_Sleep.cpp.o: In function setup': /Network_Ping_Sleep.ino:104: undefined reference to
RF24Network::setup_watchdog(unsigned char)'
Network_Ping_Sleep.cpp.o: In function loop': /Network_Ping_Sleep.ino:139: undefined reference to
RF24Network::sleepNode(unsigned int, int)'
collect2: error: ld returned 1 exit status
compile error
I copy the library RF24Network.h on Contents/Java/libraries/RF24Nework-master folder into Arduino.app
unaware that marks this mistake in advance appreciate your advice on this error.
I'm trying to use RF24Network library with platformio. During the build of my project, I get an error while building the examples (see details below).
It seems to me that the exclude
section in library.json
should contain examples
and examples_RPi
.
I do not have much experience with platformio (or even with C code in general), so I might well be completely wrong and problem on my side...
avr-g++ -o .pioenvs/nanoatmega328/RF24Network_ID435/examples_RPi/helloworld_rx.o -c -fno-exceptions -fno-threadsafe-statics -g -Os -Wall -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO_AVR_NANO -DARDUINO=10605 -I.pioenvs/nanoatmega328/FrameworkArduino -I.pioenvs/nanoatmega328/FrameworkArduinoVariant -I.pioenvs/nanoatmega328/Adafruit_DHT_ID19 -I.pioenvs/nanoatmega328/SPI -I.pioenvs/nanoatmega328/RF24_ID433 -I.pioenvs/nanoatmega328/RF24Network_ID435 .pioenvs/nanoatmega328/RF24Network_ID435/examples_RPi/helloworld_rx.cpp
.pioenvs/nanoatmega328/RF24Network_ID435/examples_RPi/helloworld_rx.cpp:12:23: fatal error: RF24/RF24.h: No such file or directory
#include <RF24/RF24.h>
^
compilation terminated.
scons: *** [.pioenvs/nanoatmega328/RF24Network_ID435/examples_RPi/helloworld_rx.o] Error 1
On an Arduino Pro Mini 3.3v, sleep mode works fine, but on a bare Atmega328 on 3.3v power on breadboard it will never go to sleep. I don't see any substantive difference in the sleep mode code in the dev branch.
Any ideas on what could be wrong or how to debug this? Thanks! Great libraries!
Hi. I can get RF24 working fine with the ATTiny84, but when I try to use RF24Network-Development, millis(), micros(), and generally any counter doesn't work (like packets_sent++ in the helloworld_tx example).
Sketch running on AtTiny84;
#include <RF24Network.h>
#include <RF24.h>
RF24 radio(8,7); // nRF24L01(+) radio attached using Getting Started board
RF24Network network(radio); // Network uses that radio
const uint16_t this_node = 1; // Address of our node
const uint16_t other_node = 0; // Address of the other node
unsigned long last_sent = 0; // When did we last send?
unsigned long packets_sent = 0; // How many have we sent already
struct payload_t { // Structure of our payload
unsigned long ms;
unsigned long counter;
};
void setup(void)
{
radio.begin();
network.begin(/*channel*/ 90, /*node address*/ this_node);
}
void loop() {
network.update(); // Check the network regularly
payload_t payload = { last_sent, packets_sent++ };
RF24NetworkHeader header(/*to node*/ other_node);
network.write(header,&payload,sizeof(payload));
last_sent++;
}
Responses on RPi;
Received payload # 16777450 at 84082433
Received payload # 16777450 at 84082433
Received payload # 16777450 at 84082433
Received payload # 16777450 at 84082433
Received payload # 16777450 at 84082433
Received payload # 16777450 at 84082433
Received payload # 16777450 at 84082433
Received payload # 16777450 at 84082433
Received payload # 16777450 at 84082433
Received payload # 16777450 at 84082433
Hi!
I'm using RF24Network (Dev branch, to check out fragmenting) on top of RF24 master branch. My devices are Arduino compatible DevDuino sensor node and Intel Galileo (I'm not using Arduino wrapper for I/O not this 1, but building "native" using Intel IoT MRAA library). I do not use Arduino IDE, and all libs are compiled and linked along with main code.
While sending a data structure of 12 bytes length, from child node to master, RF24Network::write() always gives me false, however master recieves and parses actual data.
When I switch to master branch of RF24Network for both nodes - everything seems to be working fine.
Can you confirm that there is a use case when RF24Network::write() returns true, while sending short 1 frame unfragmented packets? e.g. should I go deeper in serial/console debugging, or this is a known issue and there is a workaround? :)
Hello,
fist let me say that i was excited about this class.
I build my own Home-Control app an everything works fine.
But, if i use Message forwarding and send data which like "10", "10123", "10111", an empty message was received from the base node.
The reason is the "10" at the beginning of the payload. If it starts with "20" "11" "1110" everything works fine.
Here is a part of my code (i used the default Radio settings):
Arduino:
const uint16_t this_node = 011;
const uint16_t parrent_node = 01;
callback = "10";
Send the final one back.
String strRespTemp = callback;
char responseRF[32] = "";
char charRespTemp[31];
strRespTemp.toCharArray(charRespTemp, strRespTemp.length() + 1);
strcpy (responseRF, charRespTemp);
RF24NetworkHeader header(parrent_node);
bool ok = network.write(header,&responseRF,sizeof(responseRF));
Ras-Pi:
const uint16_t this_node = 00;
char receivePayload[32];
RF24NetworkHeader header;
network.read(header,&receivePayload,sizeof(receivePayload));
Thanks for helping, Stephan
hey,
I have been playing around with transmitting back and forth between an arduino(address 01) and RPi(address 00, using RF24Network library in both c++ and python wrapper) using my code. I've released that the arduino still believes that the message was received two or three transmissions after I've stopped the RPi program. It does not depend on time either as I have closed the RPi program waited a minute and observed the same results. The amount of misinformed receives haves the same result no matter how long in between transmissions from arduino after closing RPi script (tested up to 10 seconds in between sends). This doesn't happen when sending message from arduino to arduino.
Could you please create a new release so that this library can be submitted to the IDE's library repo?
I am using the example DemoNTSC sketch of TVOut library but as soon as I add this line
RF24Network network(radio);
the TVOut library breaks somehow. What could be the cause and is there a way I could fix it?
I have trouble to set node 0 to test sesornet example.
Do you have any hint how to do that.
Here is an issue opened in maniacbug library:
maniacbug/RF24Network#13
Because this is fork which is developed further i try to get answer here.
Arduino forum is under maintenance :(
It would be very nice to get any instructions how to set master node to 000.
If I try to set it in sesornet example
I get message:
"This sketch cannot run on node 00"
On forum was said that for this I need another sketch, but I can't find any.
Thank you for your help if it's possible.
Is one supposed to set radio details (such as data rate, PA level) before or after network.begin()
?
I had assumed we would set up the radio as desired, then call network.begin()
, e.g.
radio.begin();
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_250KBPS);
network.begin(82, base_node);
radio.printDetails();
However, I keep ending up with Data Rate = 1MBPS
with this strategy.
Reviewing the examples, I can see that in the Network Ping example it's done similarly: the radio.setPALevel
is called after radio.begin()
but before network.begin()
. None of the other examples set up any other of the radio parameters.
It looks like this is because the data rate is hard-coded into network.begin()
, so in order to work at RF24_250KBPS
and maximize my range, I have to rearrange things like so:
radio.begin();
radio.setPALevel(RF24_PA_MAX);
network.begin(82, base_node);
radio.setDataRate(RF24_250KBPS);
radio.printDetails();
It just seems odd to do go from setting up the radio to setting up the network back to configuring the radio. Is this how I'm supposed to be going about things? If so, perhaps I could put something into the documentation.
Otherwise, I wonder if we could eliminate this piece of code from RF24Network since setDataRate( RF24_1MBPS ) ;
is already set by default in radio.begin()
, and seems to be just overriding manually set values as is.
EDIT: When / if you have time to respond, it would be helpful if you could expand to include other radio settings as well, e.g. whether the preferred order would be:
radio.begin();
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_250KBPS); // Doesn't work as is, gets overridden
radio.setAutoAck(1);
radio.setRetries(15, 15); // Also gets overridden in network.begin(), should probably just leave out
network.begin(82, base_node);
or
radio.begin();
network.begin(82, base_node);
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_250KBPS);
radio.setAutoAck(1);
radio.setRetries(15, 15); // Also gets reset in network.begin(), would break anti-collision optimizations
I discoverd an issue on Arduino where a duplicate fragmented packet will corrupt the message_buffer. I have an RF24 node that sends out a message to the base when it comes online. Because of this the RF24NetworkHeader::id will always be the same: 2. The message is always the same too. If I reset the node a few times without sending out any additional fragmented messages the BASE will keep dropping the message. The problem is that something gets messed up with the message_buffer and a portion of each message gets appended to the original each time until the BASE is restarted. Here's an example:
1st: Payload: rf24/5/online^node 5 online
2nd: Payload: rf24/5/online^node 5 onlineine
3rd: Payload: rf24/5/online^node 5 onlineineine
4th: Payload: rf24/5/online^node 5 onlineineineine
If I split up the if statement and comment out this part at line 422 in RF24Network.cpp the issue goes away but I know the real bug is elsewhere. I just haven't tracked it down yet.
(frag_queue.header.id == header->id && frag_queue.header.from_node == header->from_node)
I'm running this code in the RPi:
#include <cstdlib>
#include <iostream>
#include <RF24/RF24.h>
#include <RF24Network/RF24Network.h>
#include <ctime>
#include <stdio.h>
#include <time.h>
using namespace std;
/*
IMPORTANTE: IL PRIMO PARAMETRO CAMBIA A SECONDA DELL'ARCHITETTURA:
Raspberry Pi B V2 - CE sul pin 15 (GPIO22): RPI_V2_GPIO_P1_15
Rasbperry Pi B+ - CE sul pin 22 (GPIO25): RPI_BPLUS_GPIO_J8_22
*/
RF24 radio(RPI_BPLUS_GPIO_J8_22, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_8MHZ);
RF24Network network(radio);
// Address of our node in Octal format (01,021, etc)
const uint16_t this_node = 00;
// Address of the other node
const uint16_t other_node = 01;
struct payload_t {
unsigned long request; //tipo di richiesta 0= ASK, 1=DO
unsigned long op; //ON=1, OFF=0, STATUS=2
unsigned int pin;
};
int main(int argc, char** argv)
{
// Refer to RF24.h or nRF24L01 DS for settings
radio.begin();
delay(5);
network.begin(/*channel*/ 90, /*node address*/ this_node);
//radio.printDetails();
network.update();
printf("Sending ..\n");
payload_t payload = { 1, 54, 2};
RF24NetworkHeader header(/*to node*/ other_node);
bool ok = network.write(header,&payload,sizeof(payload));
if (ok){
printf("ok.\n");
return 0;
}
else{
printf("failed.\n");
return 1;
}
}
and this one on Arduino:
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(9,10); // 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 ( 04,031, etc)
const uint16_t other_node = 00; // Address of the other node in Octal format
struct payload_t { // Structure of our payload
unsigned long request;
unsigned long op;
unsigned int pin;
};
void setup(void)
{
Serial.begin(57600);
Serial.print("receiving at node ");
Serial.println(this_node);
SPI.begin();
radio.begin();
network.begin(/*channel*/ 90, /*node address*/ this_node);
}
void loop(void){
network.update(); // Check the network regularly
while ( network.available() ) { // Is there anything ready for us?
RF24NetworkHeader header; // If so, grab it and print it out
payload_t payload;
network.read(header,&payload,sizeof(payload));
Serial.print("Received packet [req: ");
Serial.print(payload.request);
Serial.print(",op: ");
Serial.print(payload.op);
Serial.print(",pin: ");
Serial.print(payload.pin);
Serial.println("]");
}
}
Everything is working since I get, on the Arduino receiver:
Received packet [req: 1,op: 54,pin: 2])
If I change, in both the transmitter and the receiver, the payload structure according to this:
struct payload_t {
unsigned int request; //tipo di richiesta 0= ASK, 1=DO
unsigned int op; //ON=1, OFF=0, STATUS=2
unsigned int pin;
};
what I get from the Arduino receiver is:
Received packet [req: 1,op: 0,pin: 54]
which is wrong since I'm sending {1, 54, 2}. Basically changing fields from long to int seems to invalidate the transmission soundness.
Any clues?
Does the RF24Network lib actually work on the Pi? The regular RF24 works great between RPi and Arduino (with PA+LNA+antenna and the regular small ones) so maybe its just me missing something obvious.
Certainly these functions do not change the settings for me:
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_MAX);
The RPi is setup as the receiver and never gets "2" (or the payload) printed, so network.available() is never true - see scripts
When I have problems with 3.3v (I suspect caused by an USB hard drive connected to my raspberry) the communications stop working and the arduino stop receiving packets. That's normal, but
in this situation, when I try to send a packet using network.write the arduino completely freeze.
In this situation is impossible to reset the module and then the node stay offline forever.
Is this reasonable?
Is this useful?
Do we need this?
Hello,
I have the current setup, the gateway is setup with ncurses on rpi2 module and the http server is running there too. I have 5 arduino pro mini with ip 10.0.0.11- to 16 and after 12-24 hours they stop transmitting the data they are supposed to via get(temperature, humidity and etc), if i try to ping them they respond to the ping the mesh sees them, is this a bug or a problem in my configuration , i am supplying current from the pro mini directly, not enough current, or millis() crush ?
Thank you
The debug output only prints the first 2 bytes of the payload
outbuf = 00aabbccff (5 bytes long)
network.write(header,&outbuf,outbuf_len)
421331: NET Sending
421332: NET message aa00
421333: MAC Sending to 05 via 05 on pipe 0
421334: NET Pipe 0 on node 05 has address f0f0f0a53c
421336: MAC Sent on f0f0a53c Command send to node: 5 len: 5
Hello, I have problem with RF24Network and ATTiny devices. RF24 works correctly on ATTiny, RF24network does not,
I check both cores:
https://github.com/damellis/attiny
http://drazzy.com/
Both works correct with RF24 but still no communication over network...
Any clues or suggestions?
Cheers
Peter
Hi
Firstup, thankyou for a fantastic library!
I have a question regarding packet loss. I wrote a simple test program that sends and receives a small packets at a fixed rate (100ms frequency). The two nodes do exactly the same.
When my frequency is that short (100ms) I get a lot of packet loss in both receiving and sending on both nodes (about 80%+ gets lost), BUT as soon as I touch one of the RF24 Modules, the traffic sends from the one node at almost no packet loss, and the same happens if a touch the other node's RF24 module
When using a longer timeout (500ms) I got almost no packet loss (without touching the module).
Do you have any idea why touching the module helps with packets loss? And why do I get almost no packet loss by just increasing my frequency too 500ms. I've tried different modules (the long range with antennas, and the cheaper ones) they all behave the same. Both modules are on my table.
I will upload my testing code this evening, and maybe put a video on youtube if I get the chance.
If there is an other forum I should rather ask this question please guide me :) I figured you'd know best.
I'm unsure if this should be logged again the network or underlying radio but I seem unable to set the datarate to 250kbps. I use the following to setup the connection on a rpi with a similar setup on an arduino
radio.begin();
radio.setDataRate(RF24_250KBPS);
network.begin(/*channel*/ 90, /*node address*/ this_node);
radio.printDetails();
however the data rate stays at 1Mbps
Data Rate = 1MBPS
Model = nRF24L01+
Hi (this is a question before saying there is an issue),
I'm completely newbie with the module, I found your libs, blog and github I will say easily. Getting stuffs all arround the web I managed to find this tutorial close enough to my needs. I decided to take it as starting point.
Before taking this tutorial, I managed to get different data from different sensors with the same Atmega328P (working with the chip itselft and using Arduino as ISP). Getting data from light sensor, bmp085 for the pressure and temperaure, dht22 for humidity and temperature...
Of course the goal now is to send all these data to my raspberry pi.
Here is my variable declarations and message structure (the message is exactly identical in my receiver and emitter):
// Radio with CE & CSN connected to 7 & 8
RF24 radio(7, 8);
RF24Network network(radio);
// Constants that identify this node and the node to send data to
const uint16_t this_node = 1;
const uint16_t parent_node = 0;
struct message_t {
uint16_t als_lux;
int16_t wdir;
float wspeed;
float dht_humidity;
float dht_temperatureC;
float dht_heatIndexC;
float dht_dewpoint;
float bmp_temperatureC;
int32_t bmp_atmPressure;
};
message_t message;
RF24NetworkHeader header(parent_node);
I have declared the type in the emitter and filtering it in the receiver:
// radio init
SPI.begin();
radio.begin();
delay(5);
network.begin(90, this_node);
header.type = 108;
Serial.println(F("* NRF24 status: ready"));
When the Arduino run the setup(), I'm initialising the header. When it goes to the loop() header.type still have 108 as value. Once the network.write(header, &message, sizeof(message)))
is completed, the value change to 150. So the message is sent every time but treated only the first time by the receiver as the type doesn't match any more.
After looking on Google results a long time, I found something could be related is "#define NETWORK_LAST_FRAGMENT 150" from RF24Network.h but I have no clue why, and I don't know if this is normal or not. I cannot find related data to this or the research stuff are not good enough to help to find the answer (or I don't know how to make my search, but this is another problem).
As far as I know, I'm not changing this value. I also tried with other value than 108, but 150 still coming after sending. But if I send only the BMP data, no issue detected...
My message should be short enough to be sent at once, am I wrong?
Any idea what can cause this? (I believe I'm on the dev branch of RF24Network as the tutorial I followed advice to work with the dev branch).
Hey,
Is there a way to send integers from RPi(python)?
I get an error that says it did not match C++ signiture which had a string.
So I tried converting an int to string, payload = str(message) which worked, but when the number is received by the arduino it is not the same. eg. send string 22 from RPi, arduino believes the payload is 50??
It isn't a big problem I was just wondering. If I can't I'll just convert to string.
During the summer I built a small RF24 network using a RasPi and two arduino pro minis. One pro mini has a DHT22 temp and humidity device and a barometric pressure device connected. It relays its data through the other pro mini, acting as a network extension node, to the RasPi. Both the RasPi and pro minis have the NRF24l01+ PA with external antennae. This setup works superbly. This week I decided to add a couple of new nodes. The Arduino IDE informed me of library updates for RF24 and RF24Network. I updated. Using previously good code no longer works. My existing network never receives any data from the new nodes. Are there compatibility issues I'm not aware of? Is there any way I can get the previous RF24 and RF24Network releases?
Ok, so after a long time coming, the dev branch has been merged into the master branch, and the installer updated to master.
The 'old' version will not be supported, so please report any potential related issues here, or create a new issue if you have identified the issue and have info etc..
The current RF24Network - Stable and tested 'release candidate'
The current DEV version - for additional changes etc.
The 'old' RF24Network - Pretty much the original maniacbug code, updated for the optimized RF24 lib
I am using the RF24 Python wrapper with Python 3.2, sending binary data between my RPi and Arduino. Data transmission from RPi to Arduino works flawlessly, but transmitting numbers, e.g. signed shorts, as binary data from Arduino to RPi results in following error when they include a hexadecimal pair greater than 0x7f in value:
File "/usr/local/lib/python3.2/dist-packages/aurora/controller/hardware/rf24controller.py", line 49, in loop
header, payload = self.network.read(30)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
The above error is given when trying to read a short of 128 in value.
Correct me if I'm wrong, but after glancing over it, my guess would be that the issue is caused by using a char array as a buffer in the Python wrapper for the network.read() method.
Hi,
after your suggestion in RF24Mesh I tried to send multicast messages but the never works. Am I missing something?
actually on the master node I call:
if (!network.multicast(resHeader,&resMsg,sizeof(resMsg),4))
{
Serial.println("reset failed");
}else{
Serial.println("reset sent");
}
and in the receiver I simply call this:
while (network.available()) {
RF24NetworkHeader header;
payload_t payload;
network.read(header, &payload, sizeof(payload));
but I never receive the packet
Here you will find the code: https://gist.github.com/zarya/5d3f43ab019edc9fdd6d
Here is the output:
================ SPI Configuration ================
CSN Pin = CE0 (PI Hardware Driven)
CE Pin = Custom GPIO25
Clock Speed = 8 Mhz
================ NRF Configuration ================
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x0000000000 0xf0f0f0f05a
RX_ADDR_P2-5 = 0x69 0x96 0xa5 0xc3
TX_ADDR = 0xf0f0f0a53c
RX_PW_P0-6 = 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA = 0x3f
EN_RXADDR = 0x3f
RF_CH = 0x50
RF_SETUP = 0x07
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX
*** WARNING *** Invalid address 05400
Hi,
Can I ask why sleep mode is not included with RF24Network for the attiny84?
Cheers
Glen.
in the rf24network.cpp file at line 643:
maxlen = min(maxlen,bufsize);
needs to be
maxlen = rf24_min(maxlen,bufsize);
Currently the update() function encapsulated the following activities:
I propose to split this function activities into functions to handle exclusively each action.
Additionally handling different frame types could be also splitted into different functions.
This measure could make the code easy to read and implementing different frame types would be easy: define new type, add type to switch-case, define new type handling function.
Would be this code changes a problem using arduino?
On the last dev branch, while sending a zero length payload, the read method returns "The total number of bytes copied into message" plus a 10 bytes offset.
network.write(header,&payload,0);
network.read(header, &payload, sizeof(payload)); --> returns 10
The issue seems to be around line 631 of RF24Network.cpp
In nrf24 library there was a method radio.printDetails(); which used to print some useful information in the serial interface. What about RF24Network library? I couldn't find this anywhere in the source but it doesn't display an error when compiling.
I did a long search about this issue and found lots of people talking about acknowledge packets that fail to be received for numerous reasons. My issue is the same, with two arduinos and two NRF24L01+ modules that send and receive perfectly but bool ok = rf24Net.write( header, &payload, sizeof(payload) );
always is false. I am using the latest NRF24 and NRF24Network commits. Any ideas that might work?
This is my setup for both nodes:
rf24Net.begin(90, this_node);
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_MAX) ;
I am mentioning again that everything seem to work fine and the payload is being sent successfully, but I can't use this feature in order to put my atmega to sleep :)
I am having some problems understanding how the RF24Network library works with addresses. I have read all the documentation but I'm still confused on the description of the octal addresses and topology; it doesn't explain very well how to choose the addresses for multiple microcontrollers and how does the hierarchy work
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.