Help with RF24Network and nRF24L01+

Hi to all!

I've posted this thread on another section some weeks ago but I'm still blocked. Hope someone can help me, I cannot figure out how to proceed :frowning:

I'm having again problems with RF24Network library :slight_smile:
I'm trying to create an arduino Network based on the library RF24Network developed by maniacbug and descrived here: RF24Network for Wireless Sensor Networking | maniacbug

I'm starting using the 'meshping.pde' example: http://maniacbug.github.com/RF24Network/meshping_8pde-example.html

I was able to setup the hardware correctly and so send and receive messages. I've then introduced a DHT11 sensor. My goal is to create a meshed network, but messages should not flow only from external leafes to node00, but also node00 should be able to send messages out to leafes, this to have interaction with external leafes, but doing so I noticed a strange behaviour.

Sending a char array sometimes the radioMessage received is overwritten by anothe rmessage. I cannot understood if it's an issue on the program or the library doesn't allow a Node00 to Nodexx comunication. This is the meshping example modified:

----->>>>>>> See attached file 'meshping_mod.txt'

The code should generate on every cycle a random char array formed by:
[node_number];0;1;[DHT11_humidity];[DHT11_temperature];0;0;0;10;50
OR
[node_number];0;1;[DHT11_humidity];[DHT11_temperature];0;0;0;0;4;
The last 5 values separated by commas are random added one or the other.

Now, loading this on two nodes, Address '0' and address '5' the output from the serial ports are follow:

Node0:

RF24Network/examples/meshping/
VERSION: Unknown
ADDRESS: 0
STATUS           = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1     = 0xf0f0f0f03c 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            = 0x64
RF_SETUP         = 0x07
CONFIG           = 0x0f
DYNPD/FEATURE    = 0x00 0x00
Data Rate        = 1MBPS
Model            = nRF24L01+
CRC Length       = 16 bits
PA Power         = PA_HIGH
||NO RADIO||
||NO RADIO||
[1095] >> APP Received '5;0;1;5500;2000;0;0;0;0;;50;' from 05   <--------
1096: APP Added 05 to list of active nodes.
||!! RADIO|
||NO RADIO||
||NO RADIO||
---------------------------------
2110: APP Sending active nodes to 05...
----------
[2614] >> APP Sending 0;0;1;5000;1900;0;0;0;0;4; to 05...
----------
2618: APP Send ok
||NO RADIO||
||NO RADIO||
||NO RADIO||
----------
[4145] >> APP Sending 0;0;1;5000;1900;0;0;0;10;50; to 00...
----------
4148: APP Send ok
[4152] >> APP Received '0;0;1;5000;1900;0;0;0;10;50;' from 00   <--------
||!! RADIO|
||NO RADIO||
||NO RADIO||
[5191] >> APP Received '5;0;1;5500;2000;0;0;0;0;4;' from 05   <--------
||!! RADIO|
||NO RADIO||
||NO RADIO||
---------------------------------
6199: APP Sending active nodes to 05...
----------
[6702] >> APP Sending 0;0;1;5000;1900;0;0;0;0;4; to 05...
----------
6707: APP Send ok
||NO RADIO||
[7232] >> APP Received '5;0;1;5500;2000;0;0;0;0;;50;' from 05   <--------
||!! RADIO|
||NO RADIO||
||NO RADIO||

Node5:

RF24Network/examples/meshping/
VERSION: Unknown
ADDRESS: 5
STATUS           = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1     = 0xf0f0f0a53c 0xf0f0f0a55a
RX_ADDR_P2-5     = 0x69 0x96 0xa5 0xc3
TX_ADDR          = 0xf0f0f0f0c3
RX_PW_P0-6       = 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA            = 0x3f
EN_RXADDR        = 0x3f
RF_CH            = 0x64
RF_SETUP         = 0x07
CONFIG           = 0x0f
DYNPD/FEATURE    = 0x00 0x00
Data Rate        = 1MBPS
Model            = nRF24L01+
CRC Length       = 16 bits
PA Power         = PA_HIGH
||NO RADIO||
||NO RADIO||
||NO RADIO||
||NO RADIO||
----------
[2096] >> APP Sending 5;0;1;4900;2400;0;0;0;0;4; to 00...
----------
2101: APP Send ok
||NO RADIO||
||NO RADIO||
||NO RADIO||
3628: APP Received nodes from 00
3628: APP Added 05 to list of active nodes.
||!! RADIO|
||NO RADIO||
----------
[4134] >> APP Sending 5;0;1;4900;2400;0;0;0;10;50; to 05...
----------
4139: APP Send ok
[4142] >> APP Received '0;0;1;4800;2100;0;0;0;0;;50;' from 00   <--------
4154: APP Added 00 to list of active nodes.
[4162] >> APP Received '5;0;1;4900;2400;0;0;0;10;50;' from 05   <--------
||!! RADIO|
||NO RADIO||
||NO RADIO||
||NO RADIO||
||NO RADIO||
----------
[6202] >> APP Sending 5;0;1;4900;2400;0;0;0;0;4; to 00...
----------
6207: APP Send ok
||NO RADIO||
||NO RADIO||
||NO RADIO||
7734: APP Received nodes from 00
||!! RADIO|
||NO RADIO||
----------
[8236] >> APP Sending 5;0;1;4900;2400;0;0;0;0;4; to 00...
----------
8240: APP Send ok
||NO RADIO||
||NO RADIO||
||NO RADIO||
||NO RADIO||
----------
[10267] >> APP Sending 5;0;1;4900;2400;0;0;0;10;50; to 05...

Well, you can notice often the radiomessage seems overwritten by the previous(?) message, in example:

[4142] >> APP Received '0;0;1;4800;2100;0;0;0;0;;50;' from 00
[7232] >> APP Received '5;0;1;5500;2000;0;0;0;0;;50;' from 05

Seems the double ';;' are the radiomessage '5;0;1;4900;2400;0;0;0;10;50;' overwritten by '5;0;1;4900;2400;0;0;0;0;4;' resulting in:

'0;0;1;4800;2100;0;0;0;0;;50;'

I'm not sure. The sent message, printing 'radiomessage' before sending it out, seems always correct, also I think the issue is on incoming traffic.

Could someone help me?

Thank's a lot!

Simon

meshping_mod.txt (7.65 KB)

You seem to be writing a shorter value into radioMessage, so the previous data is still there. Clear the content of radioMessage each time through the loop.

Sorry for maybe stupid question but how is the best way to clean the variable? Reading around seems not so straight forward as on typical programming languages like php I use. I'm new on C.
Hope at least the rest is correct.

Thank you!!

Simon

Have a look at this other thread:

http://arduino.cc/forum/index.php/topic,44145.0.html

JohnHoward:
Have a look at this other thread:

http://arduino.cc/forum/index.php/topic,44145.0.html

Hi John.

Thank's for the link. And I obmit to say I've tried to search many times on the forum before posting. :frowning: :slight_smile: I'll try these suggestions, seems what I was searching for!

Have a nice day!

simon

Hi again!

I've tested your suggestions but still not work.
The first attempt was to "reset" the char array setting it to '\0' in the function where I get the message:

void handle_T(RF24NetworkHeader& header)
{
  // The 'T' message is just a ulong, containing the time
  unsigned long message;

  radioMessage[0] = '\0';              ///////// <------------------------------------- HERE
  network.read(header,radioMessage,sizeof(radioMessage));

  printf_P(PSTR("[%lu] >> APP Received '%s' from 0%o   <--------\n\r"),millis(),radioMessage,header.from_node);

    // If this message is from ourselves or the base, don't bother adding it to the active nodes.
  if ( header.from_node != this_node || header.from_node > 00 )
    add_node(header.from_node);
  
}

But I still get these values:

Slave sends:
5;0;1;5100;1700;0;0;0;10;50;
Master receives:
5;0;1;5100;1700;0;0;0;0;;50;

It happens randomly. Somewhere there is a reason.

Then, I've tried a different approach. I've defined a new char array to handle incoming messages different from those I send, also, from the sketch I've added at the beginning:

char radioBuffer[40];

and then the function looks like this:

/**
 * Handle a 'T' message
 *
 * Add the node to the list of active nodes
 */
void handle_T(RF24NetworkHeader& header)
{
  // The 'T' message is just a ulong, containing the time
  unsigned long message;

  radioBuffer[0] = '\0';
  network.read(header,radioBuffer,sizeof(radioBuffer));

  printf_P(PSTR("[%lu] >> APP Received '%s' from 0%o   <--------\n\r"),millis(),radioBuffer,header.from_node);

    // If this message is from ourselves or the base, don't bother adding it to the active nodes.
  if ( header.from_node != this_node || header.from_node > 00 )
    add_node(header.from_node);
  
}

Well, now seems radioBuffer is always populated not more than a defined size of characters. Look here:

NODE0:

[12723631] >> APP Sending 0;0;1;4600;2100;0;0;0;10;50; to 00...
----------
12723635: APP Send ok
[12725639] >> APP Received '0;0;1;4600;2100;0;0;0;10' from 00   <--------

this on the same node.

And from other node, NODE5:

[12781575] >> APP Sending 5;0;1;5300;1700;0;0;0;0;4; to 00...

To NODE0

[12877550] >> APP Received '5;0;1;5300;1700;0;0;0;0;' from 05   <--------

This makes me crazy, what's wrong?

Please help :slight_smile:

Simon

Beginner question. I have not managed to get hardware working, I tried examples Maniacbug pingpair and GettingStarted

?I wonder why serial monitor is giving garbage like following
¬ú+>°ù?»»nfú»Ø~%:» Ü?;;8>?!7ã8:i»?©>Ã))W(b9´:c»?¯??Ö?fè

Hardware is
Arduino Nano ATMega328 (also tried with another Nano ATMega168, and other similar radiomodule)
SCK=13, MOSI=11, MISO=12.
CSN=D9, and D10 for CE, vcc=3.3V, ground in module = ground in arduino

I have not connected IRQ to anything, should I...

Module is like in this photo (but I need to maybe check chip version?)

Could this be caused by power problem? I have connected Arduino just with USB-cable, not any external power. Arduino is working fine if I try with temperature and network module. But just if I remove all modules, then connect nrf24l01 and try examples I can not get this working, I think radio.printDetails(); is giving garbage(?)

Check the serial speed and try using another terminal software, not the built in on Arduino. I'm using PUTTY (speed set to 57600 on both sketch and terminal).

Simon

Thank you very much, I didn't know this. I need to read now more documentation and hopefully can attach temperature/humiditu sensors

you're welcome :slight_smile:

I'm trying the same: attach sensors is not the problem. I'm having difficult to send bidirectional strings, and waiting someone can help me with what above descrived :frowning:

Bye, Simon

Sorry if I bring my thread back up, but I really cannot find a solution to my case.
I really don't know if the library can handle bidirectional messages or if it's a simple issue on my char array that will be overwritten. I've no idea if in some cases same pipe on underlying radio are used for different messages or whatever.

I'm trying/editing this code for weeks with no useful results...

Please, need some help :cry:

Simon