NRF24 Daemon
The nrf24 daemon is a service which runs on a raspberry pi used to interface with a nrf24l01+ chip, especially the NRF24 board.
Setup
- Open the project with codeblocks and compile the release build.
- Open the project directory in bash and run
./install
- Change directory to
/opt/nrf24d/interrupts/
- For each device which may send commands create a script which is simply named by its id (e.g. 1500). The first parameter contains the event id while the second contains its value.
Pinout
The pin in the top left corner is pin 1 and is denoted by a square on the PCB.
Pinouts for the NRF24L01+ board.
Pinouts for the Raspberry Pi.
The following connection is necessary:
NRF24L01+ | Raspberry PI |
---|---|
GND | GND |
VCC | 3.3V |
CSN | SPI CE 0 |
CE | GPIO 3 |
IRQ | GPIO 2 |
SCK | SPI SCLK |
MOSI | SPI MOSI |
MISO | SPI MISO |
Example Interrupt Script
$ cat /opt/nrf24d/interrupts/1500
#!/bin/sh
# <arg1> = event id
# <arg2> = value
# event = event 0 (in this case turn on/off lamps)
if [ "$1" -eq "0" ]; then
# default case turn off lamps
VAL=0
#if second argument is 0 then turn on lamps
if [ "$2" -eq "0" ]; then
VAL=2
fi
# send commands to lamps
/opt/nrf24d/nrf24ctl 1521 "$VAL" &
/opt/nrf24d/nrf24ctl 1522 "$VAL"
fi
NRF24 Control Command
The command nrf24ctl
can be used to send commands to the lamps via the ipc
server. It has two different command lines:
# Sends a command to the board with the specified id to change its PORTB register
# to the specified value. This is equivalent to:
#
# /opt/nrf24d/nrf24ctl <id> 4 716 <value>
#
/opt/nrf24d/nrf24ctl <id> <value>
# Sends a command with the specified addres and value to board id.
/opt/nrf24d/nrf24ctl <id> <command> <address> <value>