We are trying to send a message using NRF24L01, raspberry pi as transmitter and arduino uno as receiver. Our concern is, the receiver arduino might not be working because we are not getting the proper output message on the serial monitor. Code for the transmitter side (python code):

import RPi.GPIO as GPIO
from lib_nrf24 import NRF24
import time
import spidev


pipes = [[0xE8, 0xE8, 0xF0, 0xF0, 0xE1], [0xF0, 0xF0, 0xF0, 0xF0, 0xE1]]

radio = NRF24(GPIO, spidev.SpiDev())
radio.begin(0, 17)



radio.openReadingPipe(1, pipes[1])

message = list("GETSTRING")
while len(message) < 32:

while True:
    start = time.time()
    print("Sent the message: {}".format(message))

    while not radio.available(0):
        if time.time() - start > 2:
            print("Timed out.")

    receivedMessage = []
    radio.read(receivedMessage, radio.getDynamicPayloadSize())
    print("Received: {}".format(receivedMessage))

    print("Translating our received Message into unicode characters...")
    string = ""

    for n in receivedMessage:
        if (n >= 32 and n <= 126):
            string += chr(n)
    print("Our received message decodes to: {}".format(string))


Code used for the receiver side (arduino):


// ce, csn pins
RF24 radio(9, 10) ;

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

  radio.begin() ;
  radio.setPALevel(RF24_PA_MAX) ;
  radio.setChannel(0x76) ;
  radio.openWritingPipe(0xF0F0F0F0E1LL) ;
  const uint64_t pipe = 0xE8E8F0F0E1LL ;
  radio.openReadingPipe(1, pipe) ;

  radio.enableDynamicPayloads() ;
  radio.powerUp() ;


void loop(void){
  radio.startListening() ;
  Serial.println("Starting loop. Radio on.") ;
  char receivedMessage[32] = {0} ;
  if (radio.available()){
    radio.read(receivedMessage, sizeof(receivedMessage));
    Serial.println(receivedMessage) ;
    Serial.println("Turning off the radio.") ;
    radio.stopListening() ;

    String stringMessage(receivedMessage) ;

    if (stringMessage == "GETSTRING"){
      Serial.println("Looks like they want a string!") ;
      const char text[] = "Hello World!" ;
      radio.write(text, sizeof(text)) ;
      Serial.println("We sent our message.") ;

  delay(100) ;
  • why would you single out the receiver as being the cause of the problem? – jsotola Mar 3 '20 at 8:50
  • I am getting the output in raspberry pi as successfully sent the message. But the message is not showing in arduino serial monitor. That's why I think the problem is with the receiver side.Maybe the receiver is not decoding the message properly. – Rangit Ray Mar 3 '20 at 17:34
  • What is "Proper output" you're expecting with your code? – Avamander Mar 3 '20 at 23:10
  • I am trying to send the message "GETSTRING" in the form of a list from raspberry pi which I want to get in the serial monitor of the arduino. In the arduino I am giving the command Serial.println(receivedMessage), but it is not getting printed. – Rangit Ray Mar 4 '20 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.