Arduino and raspberry pi nrf24l01 wireless communication

Hello there,

I want to transfer data wirelessly via nrf24l01 with raspberry pi and arduino pro mini.

My raspberry pi and arduino codes are as follows.
But I can't send the data in any way.
Where could I have made a mistake?

Can you tell me how can I send it?
The cable pins are connected correctly. everything is correct, but I can't send wireless data


 public sealed partial class MainPage : Page
    {
        private const byte CS_LINE = 0;
        private const byte CE_PIN = 16;
        private const byte IRQ_PIN = 21;
        private const byte CHANNEL = 76;
        //private byte[] NODE1 = Encoding.UTF8.GetBytes("1Node");
        private byte[] SENDER_NODE1 = Encoding.UTF8.GetBytes("0xF0F0F0F0E1AL");
        
        //private byte[] NODE2 = Encoding.UTF8.GetBytes("2Node");
        private byte[] RECEIVER_NODE2 = Encoding.UTF8.GetBytes("0xF0F0F0F0E3CL"); // karsılıgı: 646546666465
        

        public RF24 sender;
        public RF24 receiver;
        bool isInitialized = false;

        public MainPage()
        {
            this.InitializeComponent();
            SendButton.Click += ButtonSend_Click;

            DataRate.ItemsSource = Enum.GetValues(typeof(DataRate));
            PowerLevel.ItemsSource = Enum.GetValues(typeof(PowerLevel));

            sender = new RF24();
            sender.OnDataReceived += Radio_OnDataReceived;
            sender.OnTransmitFailed += Radio_OnTransmitFailed;
            sender.OnTransmitSuccess += Radio_OnTransmitSuccess;

            receiver = new RF24(); // 
            receiver.OnDataReceived += Radio_OnDataReceived;
            receiver.OnTransmitFailed += Radio_OnTransmitFailed;
            receiver.OnTransmitSuccess += Radio_OnTransmitSuccess;

            isInitialized = true;
        }


        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            await sender.Initialize(23, 0, 24, "SPI0");
            await receiver.Initialize(5, 0, 6, "SPI1"); //

            sender.IsEnabled = true;
            receiver.IsEnabled = true; //

            sender.Channel = 76;
            receiver.Channel = 76; //

            sender.Address = SENDER_NODE1;
            receiver.Address = RECEIVER_NODE2;

            //Debug.WriteLine(sender.details());
            //Debug.WriteLine(receiver.details()); //

            //Sender
            Debug.WriteLine("Address: " + Encoding.UTF8.GetString(sender.Address));
            Debug.WriteLine("PA: " + sender.PowerLevel);
            Debug.WriteLine("IsAutoAcknowledge: " + sender.IsAutoAcknowledge);
            Debug.WriteLine("Channel: " + sender.Channel);
            Debug.WriteLine("DataRate: " + sender.DataRate);
            Debug.WriteLine("IsDynamicAcknowledge: " + sender.IsDyanmicAcknowledge);
            Debug.WriteLine("IsDynamicPayload: " + sender.IsDynamicPayload);
            Debug.WriteLine("IsEnabled: " + sender.IsEnabled);
            Debug.WriteLine("Frequency: " + sender.Frequency);
            Debug.WriteLine("IsInitialized: " + sender.IsInitialized);
            Debug.WriteLine("IsPowered: " + sender.IsPowered);

            //Receiver
            Debug.WriteLine("Address: " + Encoding.UTF8.GetString(receiver.Address));
            Debug.WriteLine("PA: " + receiver.PowerLevel);
            Debug.WriteLine("IsAutoAcknowledge: " + receiver.IsAutoAcknowledge);
            Debug.WriteLine("Channel: " + receiver.Channel);
            Debug.WriteLine("DataRate: " + receiver.DataRate);
            Debug.WriteLine("IsDynamicAcknowledge: " + receiver.IsDyanmicAcknowledge);
            Debug.WriteLine("IsDynamicPayload: " + receiver.IsDynamicPayload);
            Debug.WriteLine("IsEnabled: " + receiver.IsEnabled);
            Debug.WriteLine("Frequency: " + receiver.Frequency);
            Debug.WriteLine("IsInitialized: " + receiver.IsInitialized);
            Debug.WriteLine("IsPowered: " + receiver.IsPowered);
        }

        private void ButtonSend_Click(object sender1, RoutedEventArgs e)
        {
            var addr = Encoding.UTF8.GetBytes(SendToAddress.Text);
            Array.Reverse(addr);

            sender.SendTo(RECEIVER_NODE2, Encoding.UTF8.GetBytes(SendBuffer.Text));
        }

        private void Radio_OnTransmitSuccess()
        {
            Debug.WriteLine("Transmit Succeeded!");
            if (isInitialized)
                Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => SendStatus.Text = "Transmit Succeeded");
        }

        private void Radio_OnTransmitFailed()
        {
            Debug.WriteLine("Transmit FAILED");
            if (isInitialized)
                Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => SendStatus.Text = "Transmit FAILED");
        }

        private void Radio_OnDataReceived(byte[] data)
        {
            Debug.WriteLine("Received: " + Encoding.UTF8.GetString(data));
            if (isInitialized)
                Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => ReceiveBuffer.Text = Encoding.UTF8.GetString(data));
        }
    }

Arduino uno server

//vcc
//gnd
//csn          digital-7
//ce           digital-8
//mosi(spi)    11
//sck          13
//irq
//miso         12


//uno server
//tx 0x45998843b0 transmit
//rx Receive
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include "printf.h"

//L0E1ALLLL0E1AL
RF24 radio (8, 7); 
const uint64_t pipes[3] = { 0xF0F0F0F0E1AL, 0xF0F0F0F0E2BL, 0xF0F0F0F0E3CL };
#define PLOAD_WIDTH  32 

byte pip;
byte pload_width_now;
byte yeni_veri;
unsigned char rx_buf[PLOAD_WIDTH] = {0};

struct dataStruct2 { int p1; int t1; int s1;} transmitter2_data;

void setup()
{
  radio.begin();
  printf_begin();
  radio.setChannel(76);
  radio.setPALevel(RF24_PA_MAX); //
  radio.setCRCLength(RF24_CRC_16); //
  Serial.begin(9600);
  radio.setDataRate(RF24_2MBPS);
  radio.enableDynamicPayloads();
  radio.openReadingPipe(0, pipes[0]);
  radio.openReadingPipe(1, pipes[1]);
  radio.openReadingPipe(2, pipes[2]);
  radio.openReadingPipe(3, pipes[3]);
  radio.openReadingPipe(4, pipes[4]);
  radio.startListening();
  radio.printDetails();
  delay(1000);
}

void loop()
{
  if ( radio.available(&pip) )
  {
    pload_width_now = radio.getDynamicPayloadSize();// Fetch the payload, and see if this was the last one.

    if (!pload_width_now) 
    {
    }
    else
    {
      radio.read( rx_buf, pload_width_now );
      yeni_veri = 1;

    }
  }

  if (yeni_veri == 1)
  {
    yeni_veri = 0;

   
    if (pip == 2 && pload_width_now == sizeof(transmitter2_data))
    {
      memcpy(&transmitter2_data, rx_buf, sizeof(transmitter2_data));

      Serial.print(" Pressure//temp//status ");
      Serial.print(transmitter2_data.p1);
      Serial.print(" // ");
      Serial.print(transmitter2_data.t1);
      Serial.print(" // ");
      Serial.print(transmitter2_data.s1);
    }

    Serial.println("");
  }
}

original addres

Have you been able to verify if the nrf24L01 modules work between two Arduino Pro Minis ?

hi, yes i can send data between arduino uno and arduino pro mini.
ArduinoUNO -> Arduino pro mini (Sending successful)
Arduino pro mini -> ArduinoUNO (Sending successful)
Arduino pro mini ->raspberry pi (Failed)
Raspberrypi ->arduino pro mini (Failed)

I'm pretty sure the pin connections are connected correctly.

windows 10 iot core installed.
Which pins should I plug in for the nRF24l01 (SPI0 and SPI1)

ints have a different size on Raspi and Arduino.

And the structures may be different sizes too.

They will have a different size, for sure.
If you want to stick to int16_t, you also have to watch out for packing.

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