NRF24L01 communication problem with Nano

Hi,
I am using 2 Nano boards. The first one, with a NRF24L01, will be a remote with a button that when it is pushed it will send the signal to the second Nano (with another NRF24L01) which will activate a servo.
I am using Radiohead library.
I am able to upload the code for the "transmitter", and it seems to work fine. Here the code for the "transmitter" and a picture of the serial monitor when it is working:

//Programa del Emisor (Mando a distancia)
#include <SPI.h>
#include <RH_NRF24.h>

RH_NRF24 nrf24;
#define Pulsador 2
bool Estado_Pulsador = 0;

void setup() 
{
  pinMode (Pulsador, INPUT_PULLUP);

  Serial.begin(9600);
  
  if (!nrf24.init())
    Serial.println("fallo inicializacion");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(2))
    Serial.println("fallo en establecer canal");
  if (!nrf24.setRF(RH_NRF24::DataRate250kbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("fallo en opciones RF");    
}

void loop()
{
  //Si presionamos el pulsador enviaremos el caracter "1"
  Estado_Pulsador = !digitalRead(Pulsador);
  Serial.println(Estado_Pulsador);
  //delay (500);

  if (digitalRead(Pulsador) == LOW){
    Serial.println("Boton activado, Enviando señal para activar servo");
    uint8_t data[] = "Activa el servo";
    nrf24.send(data, sizeof(data));
    nrf24.waitPacketSent();
  }
  // Now wait for a reply
  uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  if (nrf24.available())
  { 
    // Should be a reply message for us now   
    if (nrf24.recv(buf, &len))
    {
      Serial.print("Recibido: ");
      Serial.println((char*)buf);
    }
    else
    {
      Serial.println("fallo en recepcion");
    }
  }
  delay(1000);
}

The problem is when I check and upload the code for the "receiver". It shows some "compile error problems" that I do not understand. Here the code and a picture of the error messages:

//Programa del Receptor (Maquina de pelotas)

#include <SPI.h>
#include <RH_NRF24.h>

RH_NRF24 nrf24;

#include <Servo.h>

Servo miservo;

int PINSERVO = 5; // Pin D5 del arduino nano, que controlará el servo
/*int PULSOMIN = 1000; // Un ancho de pulso de 1ms (1000 microsegundos) equivale a 0 grados
int PULSOMAX = 2000; // Un ancho de pulso de 2ms equivale a 180 grados
                     // // Un ancho de pulso de 1.5ms equivale a 90 grados*/

void setup() 
{
  Serial.begin(9600);

  miservo.attach (PINSERVO); //, PULSOMIN, PULSOMAX);
  miservo.write (0);
  
  if (!nrf24.init())
    Serial.println("fallo de inicializacion");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(2))
    Serial.println("fallo en establecer canal");
  if (!nrf24.setRF(RH_NRF24::DataRate250kbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("fallo en opciones RF");  

    Serial.println("Base iniciada");  
}

void loop()
{
  if (nrf24.available())
  {
    // Should be a message for us now.
    //En la variable "buf" almacenamos la cadena recibida (texto/mensaje enviado por el emisor) y en la variable "len" la longitud de la cadena recibida 
    uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
    if (nrf24.recv(buf, &len))
    {
//      NRF24::printBuffer("request: ", buf, len);
      Serial.print("Recibido: ");
      Serial.println((char*)buf);

      //compara dato recibido para poder activar el servo
      //if ((char*)buf[0] == 'Activa el servo') { //El codigo recibido debe ser "1"
        miservo.write (180);
        Serial.println ("servo on");
        delay (1000);
        miservo.write (0);
        delay (1000);
      //}
      // Send a reply
      uint8_t data[] = "Recibido 1: Activando Servo";
      nrf24.send(data, sizeof(data));
      nrf24.waitPacketSent();
      Serial.println("Respondiendo");
    }
    else
    {
      Serial.println("fallo en recepcion");
    }
  }
}

It is very strange because if I take the code and remove the "servo section" I am able to upload the code to Arduino. Here the code and a picture, but there is no communication with the transmitter:

#include <SPI.h>
#include <RH_NRF24.h>

RH_NRF24 nrf24;

void setup() 
{
  Serial.begin(9600);
  
  if (!nrf24.init())
    Serial.println("fallo de inicializacion");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(2))
    Serial.println("fallo en establecer canal");
  if (!nrf24.setRF(RH_NRF24::DataRate250kbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("fallo en opciones RF");  

    Serial.println("Base iniciada");  
}

void loop()
{
  if (nrf24.available())
  {
    uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
    if (nrf24.recv(buf, &len))
    {
      Serial.print("Recibido: ");
      Serial.println((char*)buf);

      uint8_t data[] = "Recibida señal de activacion servo: Servo Activado";
      nrf24.send(data, sizeof(data));
      nrf24.waitPacketSent();
      Serial.println("Respondiendo");
    }
    else
    {
      Serial.println("fallo en recepcion");
    }
  }
}

Could anyone help me? I have not experience enough in Arduino.

PD.- sorry for my English :wink:

Please do not post pictures of error messages. Copy the full error message using the button provided in the IDE and post here using code tags when you do

The error appears to be caused by two libraries trying to use the same interrupt vector. To solve the problem you need to look for either a different Servo library or a different NRF24 library and even then you may still have the same problem

/Users/carloslinacerogracia/Library/Caches/arduino/sketches/BE2152D2F50059A0CDC85FB207CF6279/libraries/Servo/avr/Servo.cpp.o (symbol from plugin): In function `ServoCount':
(.text+0x0): multiple definition of `__vector_11'
/Users/carloslinacerogracia/Library/Caches/arduino/sketches/BE2152D2F50059A0CDC85FB207CF6279/libraries/RadioHead/RH_ASK.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

Sorry for the mistake about error messages.
How could I make your solution? Controlling, for example, the servo with another library (installing the new library)?

The results of using the forum search for __vector_11:

The results of using the forum search to locate previous examples of your error:

And you have been a member more than long enough to know not to post screen shots of code or errors.

You could try installing and using this library but I am not sure that it would solve the problem

It is the second time I use this forum, and the last time was more than a year ago. I have apologize once and put in the right way. Any explanation more????????

It works perfectly. Thanks a lot!

That's good

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.