I'm sending currently data from a Raspberry to an Arduino, but I have a problem with receiving response from the Arduino back to the Raspberry:

Sent the message: ['H', 'i', '.', '.', 'A', 'r', 'd', 'u', 'i', 'n', 'o', ' ', 'U', 'N', 'O', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Timed out.

Currently message received is in "got_time", so I see numerical value. When I change it to string I see "Hi..Arduino UNO" response. Problem is with timeout on the Raspberry. Raspberry sends message, Arduino receives it, Arduino should send confirmation of receipt of the message, Raspberry shows timeout of it. Can you guide me to the solution?

Arduino Nano code:

* Getting Started example sketch for nRF24L01+ radios
* This is a very basic example of how to send data from one node to another
* Updated: Dec 2014 by TMRh20

#include <SPI.h>
#include "RF24.h"
#include "printf.h"

/****************** User Config ***************************/
/***      Set this radio as radio number 0 or 1         ***/
bool radioNumber = 1;

/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
RF24 radio(9,10);

const uint64_t addresses[2] = { 0xE1E2E3E4E5LL, 0xE6E7E8E9E0LL };
// byte addresses[][6] = {"1Node","2Node"};

// Used to control whether this node is sending or receiving
bool role = 0;

void setup() {
  Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));

  // Set the PA Level low to prevent power supply related issues since this is a
  // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
  // radio.setRetries(15,15);
  // radio.setPALevel(RF24_PA_MIN);
  // radio.setAutoAck(true);

  // Open a writing and reading pipe on each radio, with opposite addresses
  if (radioNumber) {
  } else {
  // Start the radio listening for data

void loop() {
/****************** Ping Out Role ***************************/  
  if (role == 1)  { /* Not used in this case */ }
/****************** Pong Back Role ***************************/

  if (role == 0) {
    unsigned long got_time;
    if(radio.available()) {
                                                                    // Variable for the received timestamp
      while (radio.available()) {                                   // While there is data ready
        radio.read( &got_time, sizeof(unsigned long) );             // Get the payload
      radio.stopListening();                                        // First, stop listening so we can talk   
      radio.write( &got_time, sizeof(unsigned long) );              // Send the final one back.      
      radio.startListening();                                       // Now, resume listening so we catch the next packets.     
      Serial.print(F("Sent response "));

/****************** Change Roles via Serial Commands ***************************/
/* Not used in this case */
} // Loop

Raspberry Pi 0 code:

import RPi.GPIO as GPIO  # import gpio
import time      #import time library
import spidev
from lib_nrf24 import NRF24   #import NRF24 library

GPIO.setmode(GPIO.BCM) # set the gpio mode

# set the pipe address. this address shoeld be entered on the receiver alo
pipes = [[0xE1, 0xE2, 0xE3, 0xE4, 0xE5], [0xE6, 0xE7, 0xE8, 0xE9, 0xE0]]
radio = NRF24(GPIO, spidev.SpiDev())   # use the gpio pins
radio.begin(0, 25)   # start the radio and set the ce,csn pin ce= GPIO08, csn= GPIO25
radio.setPayloadSize(32)  #set the payload size as 32 bytes
radio.setChannel(0x76) # set the channel as 76 hex
radio.setDataRate(NRF24.BR_1MBPS)    # set radio data rate
radio.setPALevel(NRF24.PA_MIN)  # set PA level

radio.setAutoAck(True)       # set acknowledgement as true 

radio.openWritingPipe(pipes[0])     # open the defined pipe for writing
radio.openReadingPipe(1,pipes[1])     # open the defined pipe for writing

radio.printDetails()      # print basic detals of radio

sendMessage = list("Hi..Arduino UNO")  #the message to be sent
while len(sendMessage) < 32:    
  while True:
    start = time.time()      #start the time for checking delivery time
    radio.write(sendMessage)   # just write the message to radio
    print("Sent the message: {}".format(sendMessage))  # print a message after succesfull send
    radio.startListening()        # Start listening the radio
    while not radio.available(0):
      if time.time() - start > 2:
        print("Timed out.")  # print errror message if radio disconnected or not functioning anymore

    radio.stopListening()     # close radio
    time.sleep(3)  # give delay of 3 seconds
  GPIO.cleanup() # this ensures a clean exit

Arduino console:

*** PRESS 'T' to begin transmitting to the other node
SPI Speedz   = 10 Mhz
STATUS       = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1     = 0xe6e7e8e9e0 0xe1e2e3e4e5
RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6
TX_ADDR      = 0xe6e7e8e9e0
RX_PW_P0-6   = 0x10 0x10 0x00 0x00 0x00 0x00
EN_AA        = 0x3f
EN_RXADDR    = 0x02
RF_CH        = 0x76
RF_SETUP     = 0x03
CONFIG       = 0x0f
DYNPD/FEATURE    = 0x00 0x00
Data Rate    = 1MBPS
Model        = nRF24L01+
CRC Length   = 16 bits
PA Power     = PA_LOW
ARC      = 5
Sent response Hi..Arduino UNO
Sent response Hi..Arduino UNO
Sent response Hi..Arduino UNO
Sent response Hi..Arduino UNO

Raspberry Pi 0 console:

STATUS   = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1     =
 0xe1e2e3e4e5 0xe6e7e8e9e0
RX_ADDR_P2-5     =

TX_ADDR      =
RX_PW_P0-6   =

EN_AA        =


RF_CH        =

RF_SETUP     =

CONFIG       =


Data Rate    = 1MBPS
Model        = nRF24l01+
CRC Length   = 16 bits
PA Power     = PA_MIN
Timed out.
Timed out.
Timed out.
  • 2
    Writing to a console takes a very llng time. Perhaps the Arduino has already responded before the raspi starts listening. Try stat listening before you write out the message. Also, your Arduino code reads the whole message in a single unsigned long variable, i.e. every new send character overwrites the last one. Then it sends only the last received charackter (a 0) back to the raspi. Is that what you want? Commented Dec 14, 2020 at 15:47
  • When I commented out print("Sent the message notthing changed (still "Timed out."). All I want to stable communication and sending messages at start Rpi to Arduino. Finally 2 way.
    – NezumiRyu
    Commented Dec 14, 2020 at 23:39
  • 1
    Next try: Perhaps the arduino still responds too fast. Use a delay before the write command. delay(5); radio.write(... in the arduino code. Of cause, it is possible that there is a hardware problem. But why should it work in one direction but fail in the other? I think the problem is that you stop listening in order to send the message and the arduino responses before the Raspi starts listening again. A stable communication is only possible if you use a communication method with a connection management like bluetooth. Commented Dec 15, 2020 at 7:06
  • I added delay before radio.write from 5 up to 1000. Still timeout.
    – NezumiRyu
    Commented Dec 15, 2020 at 9:17


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.