nRF24L01 TX'ing instruxns to separate nRF RX'ers

Hello

Question: How do I send individualized instructions to separate nRF24L01’s receivers with a single transmitting nRF24L01?

I have a functioning project that needs some rework with the addition of a third nRF24L01, a receiver, and am not finding the proper resource for coding-in this second receiver to my transmitter sketch. Briefly, a handheld transmitter (TX) governs the direction and rate of rotation of a pair of continuous rotation servos (RX). RX is comprised of servos run by an Uno R3. RX is located opposite a single continuous rotation servo with Uno R3 (Head), some 30 feet away. Head is manually toggled, requiring a bit of a scramble at times. I would like to double, even treble, this distance (ropewalk), but need remote control of Head (even at present, with the shorter distance).

I desire to mount a second switch/potentiometer pair to my transmitter box to allow individualized control over two receiving radios.

Here’s my code…
Transmitter,

//kaulaTX.ino
//Arduino Micro, nRF24L01, 9V batt, half-breadboard, stuffed into snap-top container,
//controls mounted to/protrude through lid.
//associated sketches: kaulaHead.ino & kaulaRX.ino

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
int SW = 2;                //SPST mini-toggle, ON/OFF toggle for RX servos
int POT = A0;              //10k small pot, mapped value to control direction and speed of RX servos
int val = 0;
//need second SW/POT combo to control Head

void setup(void){
  pinMode(SW, INPUT_PULLUP);
  pinMode(POT, INPUT);
  radio.begin();
  radio.openWritingPipe(pipe);
}

void loop(void){
  if (digitalRead(SW) == LOW)
  {
    unsigned long val = analogRead(POT);
    val = map(val, 0, 1023, 0, 179);
    radio.write( &val, sizeof(unsigned long) );
  }
  else
  {
    unsigned long val = 90;
    radio.write( &val, sizeof(unsigned long) );
  }
}

Receiver,

//kaulaRX.ino
//associated sketches: kaulaTX.ino & kaulaHead.ino

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include <Servo.h>

RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;

Servo servoL;
Servo servoR;

void setup(){
  servoL.attach(6);
  servoR.attach(5);
  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();
}

void loop(){
  if (radio.available())
  {
    unsigned long got_val;
    bool done = false;    
    while (!done)
    {
      done = radio.read( &got_val, sizeof(unsigned long) ); 
      servoL.write(got_val);
      servoR.write(got_val);
 //     delay(10);
    }     
  }
}

and Head.

//kaulaHead.ino
//associated sketches: kaulaTX.ino & kaulaRX.ino

#include <Servo.h>

Servo headServo;

int POT = A0;            //small 10k pot
int SW = 2;              //SPST standard toggle mounted onboard
int val = 0;

void setup()
{
  headServo.attach(9);
  pinMode(SW, INPUT_PULLUP);
  pinMode(POT, INPUT);
}

void loop()
{
  if (digitalRead(SW) == LOW)
  {
    unsigned long val = analogRead(POT);
    val = map(val, 0, 1023, 0, 179);
    headServo.write(val);
  }
  else
  {
    headServo.write(86) ;
  }
}

A thorough review was made of J Coliz and Mike M resources (libraries and examples), this forum, and of course, the big G. From these resources I cobbled together the above code. My experience with programming Arduino is only months recent, so I reach out to the community for some gentle guidance in adding a second RX’er to my project.

Thanks, Mark

BTW – My first post.

I don't understand what equipment you have. It sounds like you have an Arduino with an nRF acting as the master controller and two other Arduinos each with an nRF acting as slaves. Is this correct.

If so it should be easy to have the master send out a code (as well as data) that a slave will recognize when that slave is intended to respond to the data and it will ignore codes intended for the other slave.

...R

Hi there,

The equipment is one nRF "master", one nRF "slaved", and a manually toggled unit that I would like slaved also. I say a fairly comprehensive review of relevant literature was made, however my inexperience in these matters may have led me to not see the obvious.

Perhaps you have insight into the situation I describe and may provide assistance, or direct me to some reference I have overlooked?

Thanks

By the way...

I caught your reply in re a situation in which you have comms over nRF with model trains, but you did not elaborate further about sending codes to individual receivers.

When I read that a few days ago I started looking around for some further information in that vein and was unsuccessful.

Thanks again.

The nRF24L01+ transceivers use addressing to identify the recipient for each message. Just allocate a unique address to each slave, and have the master send to the address of the slave the message is destined for.

bambuino:
I caught your reply in re a situation in which you have comms over nRF with model trains, but you did not elaborate further about sending codes to individual receivers.

I don’t use nRF devices, but Cypress transceivers which I suspect are similar and may even be compatible with each other. I wrote about the process here.

Have you managed to get your two Arduinos talking to each other using the nRF transceivers?

…R

bambuino:
Transmitter:

RF24 radio(9,10);

const uint64_t pipe = 0xE8E8F0F0E1LL;




Receiver:


RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;

Hello,
Recently started tinkering with nRF24 modules. I have a few doubts to clear.

  1. The pipe address is 5 bytes long. Why these above addresses are 6 bytes?
  2. Can I use any 5 byte address for these pipes?
  3. According to this wiki page, http://www.elecfreaks.com/wiki/index.php?title=2.4G_Wireless_nRF24L01p
    nRF module has "126 RF channels" & one RF channel can have upto 6 pipes. So how many nRF modules can talk to a single such module? is it 126 x 6 numbers?

    .......

    I am trying to implement a wireless sensor network with hopping feature included. Till now my progress is sending data from one node to another in simplex mode. Now, trying to figure out how to receive data from more than one TX node (simplex mode)
    Data loss in RX node (Wireless sensor monitoring using nRF24L01+) - #8 by nightcrawler218 - Project Guidance - Arduino Forum
    I was using a different library (included in the above thread) but planning to learn & utilize the RF24 library.
    Any help shall be appreciated.
    Thank you.

Hi there,

Thank you for the kind replies, containing some references which I can revisit with better scrutiny. I have had a couple successes with these nRF modules, one being a baby monitor incorporating PIR motion sensing that triggered an LED at my bedside. This project is a step up.

Attached is a photo of the equipment I have constructed, test pieces destined for upgrade of motive components should this prove useful. In bottom right of photo is finished material composed of the bark of a hibiscus that grows locally. So far, rate of production is about 2x that of the method I learned from my father. In practice, the rate of rotation of the two end pieces vary inversely according to where my closing jig is located, as it progresses the length of the cable, such that rateRX>rateHead at start, rateRX=rateHead in middle, rateRX<rateHead at finish. By remotely varying the rate of rotation via these nRFs while work is in progress, I am saved the occasional scramble to adjust the rate of the non-nRF’d piece. I am looking to eventually produce 200 foot lengths.

On a historical note, a more prized fiber obtained from another endemic was used in the construction of expensive alpining ropes exported to Europe, up until the advent of Aramid fibers in the 1930’s. During its heyday, whaling ships would have their running rigging swapped out for our locally produced cables.

Thanks again for the leads. I should be receiving a couple extra radio modules in a day or two, and will get to work on the coding. Thanks for the reference to addressing of modules, which I probably came across, but was looking for an application example for more insight, given my lack of knowledge in these matters.

Mark
(I hope the image links work)

The addresses you quoted are five byte values, not six bytes. The trailing 'LL' just tells the compiler to treat the value as a long long int.

You can use any address, but I believe you will need to ensure that the top 32 bits of all addresses that are being listened to simultaneously on any given device are the same. You need to assign addresses such that only one device sends from each address and only one device listens to each device. I've found it's best to avoid having long sequences of all bits zero or all bits one in addresses and payloads.

Each transceiver can listen to up to six pipes (addresses) at a time. Note that pipe zero is also the writing pipe so needs special handling if you also want to listen to it.

The addresses you quoted are five byte values, not six bytes. The trailing 'LL' just tells the compiler to treat the value as a long long int.

Sorry, I do not understand how this helps my situation. Is it relevant to my original post/thread? I suppose I have much to learn.

Thanks PeterH for the clarification.

bambuino:
Sorry, I do not understand how this helps my situation. Is it relevant to my original post/thread? I suppose I have much to learn.

I suspect you haven't read all the posts. This was a reply to a question from @nightCrawler218

..R

bambuino:
Sorry, I do not understand how this helps my situation. Is it relevant to my original post/thread? I suppose I have much to learn.

My mistake - I was responding to questions by nightcrawler218 and didn’t realise they had hijacked your thread.

I didn't hijack the thread. :roll_eyes:
I had a question regarding the topic. That's why I asked.