ATmega328P microcontroller and nRF24L01 no serial data received

Keep trying to get a server and client between two ATmega328P microcontrollers and 2 nRF24L01 and I have downloaded the RadioHead library for it. Whenever I run it I can't get the end result and get the error of Error, no serial data received. I am lost and any help is appreciated.

For the Client:

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

RH_NRF24 nrf24;

void setup() 
{
  Serial.begin(9600);
  while (!Serial) 
    ; 
  if (!nrf24.init())
    Serial.println("init failed");
 
  if (!nrf24.setChannel(1))
    Serial.println("setChannel failed");
  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("setRF failed");    
}


void loop()
{
  Serial.println("Sending to nrf24_server");
  
  uint8_t data[] = "Hello World!";
  nrf24.send(data, sizeof(data));
  
  nrf24.waitPacketSent();
  
  uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  if (nrf24.waitAvailableTimeout(500))
  { 
      
    if (nrf24.recv(buf, &len))
    {
      Serial.print("got reply: ");
      Serial.println((char*)buf);
    }
    else
    {
      Serial.println("recv failed");
    }
  }
  else
  {
    Serial.println("No reply, is nrf24_server running?");
  }
  delay(400);
}
For the Server: 

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

RH_NRF24 nrf24;

void setup() 
{
  Serial.begin(9600);
  while (!Serial) 
    ;
  if (!nrf24.init())
    Serial.println("init failed");
 
  if (!nrf24.setChannel(1))
    Serial.println("setChannel failed");
  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("setRF failed");    
}

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("got request: ");
      Serial.println((char*)buf);
      
      
      uint8_t data[] = "And hello back to you";
      nrf24.send(data, sizeof(data));
      nrf24.waitPacketSent();
      Serial.println("Sent a reply");
    }
    else
    {
      Serial.println("recv failed");
    }
  }
}

I have it connected the correct way I believe. It could be wrong on the 328P side though... I haven't had a specific pinout or tutorial for the chip with the nRF24L01 so the pins just go into D7-8, and D10-12 with them being in the "order" I have seen from other tutorials using the transceiver. I also have a 10-micro farad capacitor between VCC and ground as i read. The code I am sure of though, I've checked that over several times.

Post an annotated schematic showing exactly how you have wired it, be sure to supply all connections, power, ground, power source(s).

The specific error is "A fatal error occurred: Failed to connect to ESP32-S2: No serial data received, Failed uploading: uploading error: exit status 2."

I used this troubleshooting guide after it wasn't working and to make sure I was hooking up the nRF24L01 right and then bought the 10-micro Farad capacitor as well from that.

The original tutorial I went off of is:

These are the original two I have gone off of and still am with after a few variations I have tried to get it to work.

The pinout that I have used for the microcontroller is this:


I hope this helps, I'm still getting into this so I am a little lost so I apologize. If you need anymore I'll do my best.

Nice picture but it tells nothing about your design or how you have it connected to what and what is powering it for starters. There are many CAD (Computer Aided Design) software packages that are available at no cost such as KiCad being my favorite. Normal design procedure is to generate a schematic and then check that to be sure it meets the requirements. If so then build a prototype and update the schematic as you make changes.

Here is the chip I bought off Amazon, I read that it was a clone, and the picture I posted matches what I have visually. I've had several videos/tutorials tell me which board to use and I haven't been completely sure which one to use. On the IDE I have the board as ATMegaZero ESP32-S2 because it was the closest to what the chip says it is. I have tried Arduino Nano and I received the same error. I wouldn't know which other board to use.

I appreciate you helping me out! Right now, after selecting arduino nano on the IDE, the client is saying

Sending to nrf24_server No reply, is nrf24_server running?

The server meanwhile is saying

Init Failed

The code is the same as I posted earlier as well.

Sorry, I meant the same error when I chose the ESP32 Dev board and ATmegazero ESP32-S2. Those were the boards a few videos I watched a few days ago said. This is the first time I am getting this so you've helped me make some progress.

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

// Singleton instance of the radio driver
RH_NRF24 nrf24(8, 10);
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

void setup() 
{
  Serial.begin(9600);
  while (!Serial) 
    ; // wait for serial port to connect. Needed for Leonardo only
  if (!nrf24.init())
    Serial.println("init failed");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(1))
    Serial.println("setChannel failed");
  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("setRF failed");    
}


void loop()
{
  Serial.println("Sending to nrf24_server");
  // Send a message to nrf24_server
  uint8_t data[] = "Hello World!";
  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.waitAvailableTimeout(500))
  { 
    // Should be a reply message for us now   
    if (nrf24.recv(buf, &len))
    {
      Serial.print("got reply: ");
      Serial.println((char*)buf);
    }
    else
    {
      Serial.println("recv failed");
    }
  }
  else
  {
    Serial.println("No reply, is nrf24_server running?");
  }
  delay(400);
}

This is from the client, it prints the line INIT FAILED when it "Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm"

got it, I'll take a step back and try and make sure I'm not getting over my head! The wiring I will look over again and redo it based on a nano tutorial and let you know.

I was able to get it to work after using this tutorial and redownloading some libraries. Thanks for the help.

If your question has been answered to your satisfaction, please mark the thread as solved so that other members that wish to help will not waste their time opening the thread only to find that you no longer require assistance.

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