View Source Nrf24

Elixir library for receiving and sending data through nRF24L01+ wireless transciver module. It was tested with pinout given below which is not unique and if different pinout is used, with different CE and CSN pins connections samples, should be adjusted accordingly.

pinout

Pinout

nRF24L01 Pinout

raspberry-pi-wiring

Raspberry Pi Wiring

nRF24L01+Rasbperry Pi 3B+
GNDGND (6)
VCC3.3V (1)
CEGPIO17 (11)
CSNGPIO8 (24)
SCKGPIO11 (23)
MOSIGPIO10 (19)
MISOGPIO9 (21)

Rasberry PI 3B+ Pinout

arduino

Arduino

wiring

Wiring

Library was tested with the second module connected to Arduino Nano.

nRF24L01+Arduino
GNDGND
VCC+3V3
CED9
CSND10
SCKD13
MOSID11
MISOD12

Arduino Nano Pinout

library

Library

RF24 Arduino library example GettingStarted is used for communication on the Arduino side.

installation

Installation

Package can be installed by adding nrf24 to your list of dependencies in mix.exs:

def deps do
  [
    {:nrf24, "~> 1.0.0"}
  ]
end

usage

Usage

receiving-data

Receiving data

{:ok, nrf} =
  Nrf24.start_link(
    channel: 0x4C,
    ce_pin: 17,
    csn_pin: 0,
    crc_length: 2,
    speed: :medium,
    pipes: [[pipe_no: 0, address: "aaaaa", payload_size: 4, auto_ack: true]]
  )
GenServer.call(nrf, :start_listening)
GenServer.call(nrf, {:read_data, 4})
GenServer.call(nrf, :stop_listening)

sending-data

Sending data

{:ok, nrf} =
  Nrf24.start_link(
    channel: 0x4C,
    ce_pin: 17,
    csn_pin: 0,
    crc_length: 2,
    speed: :medium,
  )
data = <<9273.69::float-little-size(32)>>
GenServer.cast(nrf, {:send, "bbbbb", data})