Nrf24 (nrf24 v2.0.0)
View SourceLibrary for trasmitting and receiveing data with nRF24L01+ transciever.
It works, by default, in ShockBurst mode with ACK (auto acknowledgement) and CRC check enabled. However it can be configured to disable both.
Examples
# Receiving data
{:ok, nrf} =
Nrf24.start_link(
bus_name: "spidev0.0",
ce_pin: 17,
csn_pin: 0,
channel: 0x4C,
crc_length: 2,
speed: :medium,
pipes: [[pipe_no: 0, address: "1Node", payload_size: 4, auto_ack: true]]
)
Nrf24.start_listening(nrf)
Nrf24.receive(nrf, 4)
Nrf24.stop_listening(nrf)
# Sending data
{:ok, nrf} =
Nrf24.start_link(
bus_name: "spidev0.0",
ce_pin: 17,
csn_pin: 0,
channel: 0x4C,
crc_length: 2,
speed: :medium,
)
data = <<9273.69::float-little-size(32)>>
Nrf24.send(nrf, "2Node", data)
Summary
Functions
Returns a specification to start this module under a supervisor.
nRF24L01+ GenServer start_link options
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec start_link(init_options()) :: GenServer.on_start()
nRF24L01+ GenServer start_link options
:name- GenServer nome:bus_name- SPI bus name (e.g. "spidev0.0", "spidev1.0", default: "spidev0.0"):ce_pin- Rasbperry PI pin to which transciever's CE pin is connected:csn_pin- Rasbperry PI pin to which transciever's CSN pin is connected:channel- Frequency channel on which transciever will operate (default: 0x4c):crc_length- CRC length for transmitted data verification (values: 1, 2, default: 2):speed- Data transfer speed (values: low, med, high, default: med):pipes- Data pipes configuration to be used
Data speed values:
:low- 250Kbp:medium- 1Mbps:high- 2Mbps
Pipe configuration options:
:pipe_no- Pipe number (values 0 to 5):address- For pipes 0 and 1 5-byte address and for other single byte address:payload_size- Size of data that will be received through the pipe:auto_ack- Turning auto-acknowledge on or off for the pipe (default: true)
If pipes configuration is missing, default, factory set, values will be used.
Example
{:ok, nrf} =
Nrf24.start_link(
bus_name: "spidev0.0",
ce_pin: 17,
csn_pin: 0,
channel: 0x4C,
crc_length: 2,
speed: :medium,
pipes: [[pipe_no: 0, address: "1Node", payload_size: 4, auto_ack: true]]
)