[SOLVED] NRF24L01+ radio module (OSError: send failed)

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
crizeo
Posts: 42
Joined: Sun Aug 06, 2017 12:55 pm
Location: Germany

[SOLVED] NRF24L01+ radio module (OSError: send failed)

Post by crizeo » Fri Sep 29, 2017 8:28 pm

Hey :?


I bought a E01-ML01DP5 module which is based on the nRF24L01+ (only amplified). I wanted to use the driver (nrf24l01.py) provided on the micropython repository, but can't get it work. The wiring should be ok (module connected to SPI; CS to pin 15, CE to pin 2) - it would give me the error "nRF24L01+ Hardware not responding" if it wasn't ok (as it was some time ago). Unfortunately, sending does not work anyway: The send(...) method always gives me an OSError. This is the same when I do it manually: send_start(...) is okay, but send_done() returns 2.

Here some simple code that fails, but should work (OSError: send failed):

Code: Select all

import machine
import nrf24l01

spi = machine.SPI(1, baudrate=4000000, polarity=0, phase=0)
cs = machine.Pin(15, mode=machine.Pin.OUT, pull=None)
ce = machine.Pin(2, mode=machine.Pin.OUT, pull=None)
nrf = nrf24l01.NRF24L01(spi, cs, ce)

nrf.open_tx_pipe(b'\xf0\xf0\xf0\xf0\xe1')
nrf.send(b'12345678')
Does anybody have an idea what the problem could be? :oops:
Last edited by crizeo on Wed Oct 04, 2017 7:37 pm, edited 1 time in total.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: NRF24L01+ radio module (OSError: send failed)

Post by pythoncoder » Sat Sep 30, 2017 8:44 am

I suggest you try nrf24l01test.py here: https://github.com/micropython/micropyt ... 2703/files. One general point: I assume you have a receiver working. IIRC transmit will fail unless an acknowledge is obtained from the receiver.
Peter Hinch
Index to my micropython libraries.

crizeo
Posts: 42
Joined: Sun Aug 06, 2017 12:55 pm
Location: Germany

Re: NRF24L01+ radio module (OSError: send failed)

Post by crizeo » Sat Sep 30, 2017 9:06 am

The above code is just a simplified version of the test file - I already tried the test file but sending fails there as well.

I do not have a receiver working - is this really required for testing? The test is just sending, not waiting for an acknowledgement - therefore sending should work without receiving I thought?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: NRF24L01+ radio module (OSError: send failed)

Post by pythoncoder » Sun Oct 01, 2017 4:32 pm

The NRF24L01+ verifies received messages via a checksum and automatically requests retransmission. You might like to read this https://github.com/peterhinch/micropyth ... /README.md brief introduction to my NRF24L01+ libraries. So there has to be a working, correctly configured receiver within range before a transmission is deemed successful. You might also like to seek out an NRF24L01+ programmers' manual or datasheet.

The reason I pointed you at the PR is that the code is configured for machine rather than pyb. I have raised a comment on GitHub suggesting that this test program should replace the current official version which is not portable. But from a quick glance at your code I think you've addressed this issue.
Peter Hinch
Index to my micropython libraries.

crizeo
Posts: 42
Joined: Sun Aug 06, 2017 12:55 pm
Location: Germany

Re: NRF24L01+ radio module (OSError: send failed)

Post by crizeo » Wed Oct 04, 2017 7:37 pm

It is working now. You were right, a receiver has to be running, otherwise sending will fail. I did not think that there was some kind of auto-acknowledgment embedded but it is - perfect! I used the files you linked - the only change I made in nrf24l01.py is replacing .low() with .value(0) and .high() with .value(1). Thank you!

Janiel
Posts: 1
Joined: Tue Oct 23, 2018 6:26 am

Re: NRF24L01+ radio module (OSError: send failed)

Post by Janiel » Tue Oct 23, 2018 6:33 am

[quote=crizeo post_id=22279 time=1507145854 user_id=3067]
[b]It is working now. [/b]You were right, a receiver has to be running, otherwise sending will fail. I did not think that there was some kind of auto-acknowledgment embedded but it is - perfect! I used the files you linked - the only change I made in nrf24l01.py is replacing .low() with .value(0) and .high() with .value(1).[b] Thank you![/b]
[/quote]

Hi Iam New to Micropython and ESP8266 and I am learning.,
Thanks for your answers about NRF24L01., I need to know if I should use nrf24l01.py as my main.py., or do something other to make it work

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: [SOLVED] NRF24L01+ radio module (OSError: send failed)

Post by pythoncoder » Tue Oct 23, 2018 6:45 am

I suggest you look at the official test program for an example of usage. I have also written some libraries here intended to simplify its usage.
Peter Hinch
Index to my micropython libraries.

Post Reply