nRF24L01+ and bidirectional communication

Hi there,

I hava a nest box with a cam some meters far away from the house. I need to send commands to the Arduino in the box and would like receive data, like e.g. temperature from the box. In the house I have an arduino with switches and a display. I managed to send commands to the nest box but I didnt know how to receive data from the nest box? I'm using the RF24Network library at the moment
Thanks :slight_smile:

I managed to send commands to the nest box

So, you have some code that you are not sharing.

but I didnt know how to receive data from the nest box?

Are we supposed to know if you know how? I'll assume that you don't.

I'm using the RF24Network library at the moment

Are you planning on changing?

Hello,

yes I have some code but it isn't very special so far. Basically it's just the RF24Network Transmit Example modified with some inputs

I would like to know if there's a solution with this library or if I should use something else instead.
I'm new into that RF stuff and trying to understand and learn it

Are you planning on changing?

No, it's quite handy as I'd like to use different remote controls in the final project.

/*
 Copyright (C) 2012 James Coliz, Jr. <maniacbug@ymail.com>

 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.
 */

/**
 * Simplest possible example of using RF24Network 
 *
 * TRANSMITTER NODE
 * Every 2 seconds, send a payload to the receiver node.
 */

#include <SPI.h>
#include <RF24.h>
#include <RF24Network.h>

#if defined(ENERGIA)
#if defined(__MSP430FR5739__)
#  define CE P1_2
# define CS P1_3
#elif defined(__MSP430G2553__)
# define CE P2_1
# define CS P2_0
#endif
#       define BAUD     9600
#else
#       define CE       9
#       define CS       10
#       define BAUD     115200
#endif


/*-----( Declare Constants and Pin Numbers )-----*/
#define JOYSTICK_X     A2  //Pin Numbers
#define JOYSTICK_Y     A3
#define SCHALTER_1     8
#define SCHALTER_2     7
#define SCHALTER_3     6

RF24 radio(CE, CS);

// Network uses that radio
RF24Network network(radio);

// Address of our node
const uint16_t this_node = 1;

// Address of the other node
const uint16_t other_node = 0;
const uint16_t other_node2 = 2;
// How often to send 'hello world to the other unit
const unsigned long interval = 60; //ms

// How often to send 'hello world to the other unit
const unsigned long interval2 = 1000; //ms

// When did we last send?
unsigned long last_sent;


// When did we last send?
unsigned long last_sent2;

// How many have we sent already
unsigned long packets_sent;

// Structure of our payload
struct payload_t
{
  unsigned long ms;
  unsigned long counter;
  unsigned long joystick_xx;
  unsigned long joystick_yy;
  unsigned long transmit_1;
  unsigned long senderID;
};

int senderID = 11;
int transmit_1 = 0;
int joystick1;
int joystick2;
int joystick1_var;
int joystick2_var;

int joystick_w1 =0;
int joystick_w2 =0;
 
 

void setup(void)
{
  Serial.begin(BAUD);
  Serial.println("RF24Network/examples/helloworld_tx/");
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);

  pinMode(SCHALTER_1, INPUT);           // set pin to input
  digitalWrite(SCHALTER_1, HIGH);       // turn on pullup resistors
  pinMode(SCHALTER_2, INPUT);           // set pin to input
  digitalWrite(SCHALTER_2, HIGH);       // turn on pullup resistors
  pinMode(SCHALTER_3, INPUT);           // set pin to input
  digitalWrite(SCHALTER_3, HIGH);       // turn on pullup resistors
}

//******************SENDEN**********************************************
void senden(void)
{
    Serial.print("Sending...");
    payload_t payload = { millis(), packets_sent++,joystick_w1,joystick_w2,transmit_1,senderID };
    RF24NetworkHeader header(/*to node*/ other_node);
    bool ok = network.write(header,&payload,sizeof(payload));
    if (ok)
      Serial.println("ok.");
    else
      Serial.println("failed.");
}
//******************SENDEN***ENDE*******************************************


//******************LOOP******************
void loop(void) {
  joystick1  = map(analogRead(JOYSTICK_X), 0, 1023, 0, 255);
  joystick2 =map(analogRead(JOYSTICK_Y), 0, 1023, 0, 255);
  
  if (!digitalRead(SCHALTER_1))  {  //schalter, setzt wert auf 90 zurück
    joystick_w1=90;
    joystick_w2=90;
    senden();
  }

  if (!digitalRead(SCHALTER_2)) {Serial.println("A.");}
  if (!digitalRead(SCHALTER_3)) {Serial.println("B.");}
  
  // If it's time to send a message, send it!
  unsigned long now2 = millis();
  if ( now2 - last_sent2 >= interval2  )  {
    // Pump the network regularly
    network.update();
    last_sent2 = now2;
  }
  
  // baut delay ein
  unsigned long now = millis();
  if ( now - last_sent >= interval  ) {
    last_sent = now;

    /******************joystick1***************************/
    if (joystick1 <120) { 
      if (joystick_w1 <180){joystick_w1++;};
      if (joystick_w1 <180 && joystick1 <1) {joystick_w1++;};
      Serial.print("Hoch");Serial.println(joystick_w1);
      senden();
    }
    if (joystick1 >134) { 
      if (joystick_w1 >0){joystick_w1--;};
      if (joystick_w1 >0 && joystick1 <1) {joystick_w1--;};
      Serial.print("Runter");Serial.println(joystick_w1);
      senden();
    }
    if (joystick1 != joystick1_var) {
      joystick1_var = joystick1;
    } 
    /******************joystick1****ENDE***********************/

    /******************joystick2***************************/
    if (joystick2 <120) { 
      if (joystick_w2 <180){joystick_w2++;};
      if (joystick_w2 <180 && joystick2 <1) {joystick_w2++;};
      Serial.print("Rechts");Serial.println(joystick_w2);
      senden();
    }
    if (joystick2 >134) { 
      if (joystick_w2 >0){joystick_w2--;};
      if (joystick_w2 >0 && joystick2 <1) {joystick_w2--;};
      Serial.print("Links");Serial.println(joystick_w2);
      senden();
    }
    if (joystick2 != joystick2_var) {
      joystick2_var = joystick2;
    } 
    /******************joystick2****ENDE***********************/
  }
}
//******************LOOP**ENDE****************

It's just a general question wether someone know a ressource, an example of a bidirectional communication of two of these modules.
I'm grateful for any hint.

(attached is my set-up)

There are several examples of bidirectional communication included in the maniacbug library.
Start by going through the pingpair example.