I wanted to be able to send a single broadcast transmission to several receivers and change the RF channels. No handshakes or acknowledges. To do this I needed more detailed set up and control of the nRF24L01+ modules.
I started with the rRF24 library published by Erel. I have revealed several more of the functions available from the RF24 GitHub project through to the B4R IDE including access to the full 5 byte address for Rx/Tx packets. The included XML also contains comprehensive information for all functions made available through the pop-ups in the IDE.
Probably, one of the most useful functions for me was "PrintDetails()" which reads the current settings from the registers in the RF24 module itself. A great tool to verify SPI communications and get things going.
I did my testing on the ESP8266 based WEMOS-D1 and NODEMCU modules. I don't have regular Arduino hardware. It would be good if other users could post confirmations when using this library on other mcu hardware.
To show backward compatability and the available new functions, the example below uses my rRF24xt library to communicate with devices programmed with the original rRF24 library example provided by Erel.
You may need to play around with this example a bit as although I wrote it, I don't have any MEGA or UNO hardware, so I haven't tested this specific example.
This example requires inclusion of libraries; rCore, rESP8266extras, rRandomAccessFile, rRF24xt
Here is my rRF24xt library for download.
Now updated to v1.02
See postings below for details on changes.
I started with the rRF24 library published by Erel. I have revealed several more of the functions available from the RF24 GitHub project through to the B4R IDE including access to the full 5 byte address for Rx/Tx packets. The included XML also contains comprehensive information for all functions made available through the pop-ups in the IDE.
Probably, one of the most useful functions for me was "PrintDetails()" which reads the current settings from the registers in the RF24 module itself. A great tool to verify SPI communications and get things going.
I did my testing on the ESP8266 based WEMOS-D1 and NODEMCU modules. I don't have regular Arduino hardware. It would be good if other users could post confirmations when using this library on other mcu hardware.
To show backward compatability and the available new functions, the example below uses my rRF24xt library to communicate with devices programmed with the original rRF24 library example provided by Erel.
You may need to play around with this example a bit as although I wrote it, I don't have any MEGA or UNO hardware, so I haven't tested this specific example.
B4X:
#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
Sub Process_Globals
Public Serial1 As Serial
Private rf24 As RF24xt
Private const MEGA = 1, UNO = 2 As long
Private raf As RandomAccessFile
Private ep As Wemos_D1_R2_Pins
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
rf24.Initialize(ep.D4, ep.D8, "rf24_NewData")
rf24.SetChannel(76)
rf24.SetGroupID(0xAB) 'high byte of address (for both TX and RX)
rf24.SetDataRate(1) '0=250kbs, 1=1Mbs, 2=2Mbs
rf24.UseAutoAck(True)
rf24.SetRetries(15,15) 'NB: only required if UseAutoAck(True)
rf24.UseCRC(False)
rf24.SetPower(0) 'low Tx power
'0xABCDABCD00 is the address used by original RF24 library (plus 1 or 2)
rf24.OpenReadingPipe(0xCDABCD00 + UNO)
rf24.OpenWritingPipe(0xCDABCD00 + MEGA)
rf24.Sleep(False) 'NB: Sleep(True) .. power-down RF24 module
rf24.PrintDetails 'read the registers in the RF24 module and output to log
End Sub
Sub rf24_NewData (Data() As Byte)
raf.Initialize(Data, True)
Log("UNO Millis: ", raf.ReadULong32(raf.CurrentPosition))
End Sub
This example requires inclusion of libraries; rCore, rESP8266extras, rRandomAccessFile, rRF24xt
Here is my rRF24xt library for download.
Now updated to v1.02
See postings below for details on changes.
Attachments
Last edited: