jpbarraca / pynrf24 Goto Github PK
View Code? Open in Web Editor NEWPython port of the RF24 library for NRF24L01+ radios.
License: GNU General Public License v2.0
Python port of the RF24 library for NRF24L01+ radios.
License: GNU General Public License v2.0
Hi! After python examples/recv.py
Traceback (most recent call last): File "examples/recv.py", line 14, in <module> radio.begin(1, 0, "P8_23", "P8_24") File "/usr/local/lib/python2.7/dist-packages/nrf24.py", line 233, in begin self.spidev.open(major, minor) IOError: [Errno 2] No such file or directory
From the datasheet:
bit 3 is EN_CRC (1 enables, 0 disables),
bit 2 is CRCO (0 for 8 bits, 1 for 16 bits).
bit 1 is PWR_UP
From nrf24.py:
CRC_DISABLED = 0x0
CRC_8 = 0x02
CRC_16 = 0x04
CRC_ENABLED = 0x08
CONFIG register after setCRCLength(NRF24.CRC_8): xxxx101x
Quick fix: remove config |= NRF24.CRC_8 from setCRCLength()
Better fix: use NRF24.CRCO and NRF24.EN_CRC for acessing CONFIG bits instead of NRF24.CRC_xxxx, as in getCRCLength()
Because write_register() method does not return any value, so the status will be None:
status = self.write_register(NRF24.STATUS, NRF24.RX_DR | NRF24.TX_DS | NRF24.MAX_RT)
Change to:
status = self.get_status()
self.clear_irq_flags()
You can place a connection diagram for raspberry ?
Thanks
I'm trying pynrf24. I don't use IRQ in my device, but don't know how to use this library in this case. The begin()
method seems to require the IRC pin:
def begin(self, major, minor, ce_pin, irq_pin):
GPIO.setup(self.irq_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
But if I pass a random GPIO pin, the code radio.available(pipe)
doesn't work.
I have enabled SPI, GPIO through Adafruits libraries etc,
Do i just run setup.py?
Do i have to install these libraries or can i just use them as scripts?
Is it possible? I have disabled the hdmi interface on the BBB and enabled SPI1. Now what changes must i make to the library?
Hi,
I try to communicate with my arduino to my pi. On my arduino i'm using the nrf24 tmrh20 library. I declare my addresses like this
byte addresses[][6] = {"1Node","2Node"};
On my pi, i can't so i would like to know value in hex that i have to put in pipes = [[0xe7, 0xe7, 0xe7, 0xe7, 0xe7], [0xe7, 0xe7, 0xe7, 0xe7, 0xe7]] to get the same address ?
any idea ?
Thanks by advance
Hi.
I have a beaglebone... could I use python3 or only python2?
thx
There are two EN_DPL definitions(one with value 0x04, one with value 0x02, the right value is 0x04) with different values. This will make the FEATURE to be set a wrong value.
When I want to send a packet without retransmission, I call radio.setAutoAck(0) and radio.setRetries(0, 0) to disable it. Neither of the two methods set FEATURE's EN_DYN_ACK bit, nor there is a special method to do it. Only the write_register method can be a work around.
The initial call to
self.write_register(NRF24.STATUS, NRF24.RX_DR | NRF24.TX_DS | NRF24.MAX_RT)
clears the status flags so whatHappened never returns that anything happened for RX_DR, TX_DS or MAX_RT
I can receive data from an Arduino (using RF24) when I using that(https://github.com/riyas-org/nrf24pihub/blob/master/nrf24.py) library on Raspberry pi but not using your library.
config code in python are:
radio.begin();
radio.setRetries(15, 15);
radio.setPayloadSize(PAYLOAD_SIZE);
radio.setChannel(0x22);
radio.setDataRate(RF24_2MBPS);
radio.setPALevel(RF24_PA_MAX);
radio.setAutoAck(1);
radio.openWritingPipe(remote_pipe);
radio.openReadingPipe(1, local_pipe);
and the details are:
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x1010101022 0x1010101020
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x1010101022
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x22
RF_SETUP = 0x0e
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 2MBPS
Model = nRF24l01+
CRC Length = 16 bits
PA Power = PA_HIGH
but with same config code in python, I cannot receive any data with your library.
details are:
TATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x1010101022 0x1010101020
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x1010101022
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x22
RF_SETUP = 0x0e
SETUP_AW = 0x03
OBSERVE_TX = 0x0f
CONFIG = 0x0a
FIFO_STATUS = 0x11
DYNPD = 0x00
FEATURE = 0x00
Data Rate = 2MBPS
Model = nRF24l01+
CRC Length = 8 bits
PA Power = PA_MAX
I also tried to set CRC Length to 16bits, but still got CONFIG = 0x0e( not equal to previous working one ) and not work. So I think I need to set other parameters. Thanks for your help : )
Hi,
I tried to register two listening-nodes with openReadingPipe().
This raised an "Invalid Address Lenght"-error, even though registering multiple listening-nodes should be possible.
The error is raised in line 625 of the nrf24.py:
def openReadingPipe(self, pipe, address):
if pipe >= 6:
raise RuntimeError("Invalid pipe number")
if (pipe >= 2 and len(address) > 1) or len(address) > 5:
raise RuntimeError("Invalid adress length") # -> Error occurs here
The if-condition here prevents any openReadingPipe(2, ..) till openReadinPipe(5, ...).
But why? In maniacbugs original NRF24-library there is no such restriction
void RF24::openReadingPipe(uint8_t child, uint64_t address)
{
if (child == 0){
memcpy(pipe0_reading_address,&address,addr_width);
}
if (child <= 6)
{
if ( child < 2 )
write_register(pgm_read_byte(&child_pipe[child]), reinterpret_cast<const uint8_t*>(&address), addr_width);
//--------------- Here is the Relevant Line:
else
write_register(pgm_read_byte(&child_pipe[child]), reinterpret_cast<const uint8_t*>(&address), 1);
write_register(pgm_read_byte(&child_payload_size[child]),payload_size);
write_register(EN_RXADDR,read_register(EN_RXADDR) | _BV(pgm_read_byte(&child_pipe_enable[child])));
}
}
Is there a reason for your restriction?
Hello
Should this lib work with PcDuino? I'm interested on it
Have you tested/ported rf24 network?
Thanks
The RX_EMPTY is a shift count not a mask
return self.read_register(NRF24.FIFO_STATUS) & NRF24.RX_EMPTY
should be
return self.read_register(NRF24.FIFO_STATUS) & (1 << NRF24.RX_EMPTY)
Haven't had the time to diagnose, but every input byte is 0xff when using adafruit spi on the beaglebone.
Installing spidev
with pip
seems to work.
Hey I can't actually compile the BB-nRF24-SPI0-00A0.dts on the B+ but that is part of your set up process... I must be misunderstanding something here.
Hello, there is an option to change default SPI0 to SPI1 ? I'm trying to add display to RPi3 and I have spi conflict.
Should be
setup &= ~(NRF24.RF_DR_LOW | NRF24.RF_DR_HIGH)
instead of
setup &= (~NRF24.RF_DR_LOW | NRF24.RF_DR_HIGH)
This error messes up the default rate of 1Mbps (radio will be programmed to 2Mbps instead)
hello, I have installed this library using
sudo pip install -e git+https://github.com/jpbarraca/pynrf24.git#egg=nrf24
but when I run a simple bit of code (as per the example code here on git) to receive signal from my Arduino I get:
Traceback (most recent call last):
File "./rpinrf24.py", line 4, in <module>
from nrf24 import NRF24
File "/home/pi/nrf24.py", line 4, in <module>
from nrf24 import NRF24
ImportError: cannot import name NRF24
so I assume it hasn't installed correctly, but I can't for the life of me see what I can do to get it to work.
I have a shebang directing it to python2 not python3 so that isn't the problem either.
I am using a Raspberry Pi 3 Model B.
radio.isAckPayloadAvailable() always returns false when sending a message with dynamic payload size
Sender code.
radio.write(message)
if radio.isAckPayloadAvailable():
ack = []
radio.read(ack)
print ack
Receiver code
recv_buffer = []
radio.read(recv_buffer)
ack_buffer = [1]
radio.writeAckPayload(1,ack_buffer, len(ack_buffer))
In original nRF24 C library there is an option to return pipe id, which has some data to read
bool RF24::available ( uint8_t * pipe_num)
http://maniacbug.github.io/RF24/classRF24.html#a127105eb7a3b351cfe777c1cec50627a
Is is supported somehow for this python version?
Traceback (most recent call last):
File "reciver.py", line 76, in
while radio.available(pipe):
Boost.Python.ArgumentError: Python argument types in
RF24.available(RF24, list)
did not match C++ signature:
available(RF24 {lvalue})
timeout
argument must used as keyword argument, otherwise it will no effect.None
for timeout, or the pin number
for edge detected.So, modify the code as following:
return GPIO.wait_for_edge(self.irq_pin, GPIO.FALLING, timeout=timeout) == self.irq_pin
Register EN_AA is initialized to 0x3F in reset() (as it should be), but auto_ack is initialized to 0. This can lead to a wrong timeout in write.
Hello,
I've tried the example from the library, but it seems that the communication to the module is nor working. The status after set up is the default (as if nothing was updated):
STATUS = 0xff RX_DR=1 TX_DS=1 MAX_RT=1 RX_P_NO=7 TX_FULL=1
RX_ADDR_P0-1 = 0xffffffffff 0xffffffffff
RX_ADDR_P2-5 = 0xff 0xff 0xff 0xff
TX_ADDR = 0xffffffffff
RX_PW_P0-6 = 0xff 0xff 0xff 0xff 0xff 0xff
EN_AA = 0xff
EN_RXADDR = 0xff
RF_CH = 0xff
RF_SETUP = 0xff
CONFIG = 0xff
DYNPD/FEATURE = 0xff 0xff
Data Rate = 1MBPS
Model = nRF24L01
CRC Length = 16 bits
PA Power = PA_HIGH
here is what I checked: pin connection, dmesg, SPIDEV availability, radio module integrity (tested with arduino).
What should I check to find out where is the problem?
Thank you!
Hi,
How use this library on BananaPi? Because Banana have SPI with 2 CE pins. How properly connect it to board?
Regards
Arch
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.