Wireless Chat using NRF24L01+ 2.4GHz RF Transceiver on Arduino & Raspberry Pi Ubuntu Linux

After a bit of success implementing an Arduino 2.4GHz Transceiver, I was encouraged to explore a more familiar environment, something with Python and Linux in the mix.

After a short period of research I landed on the circuitpython-nrf24l01 pypi project page, and quickly began digging through their examples.

It wasn’t long after I had a working prototype that mirrored my Arduino code quite closely:


import sys
import select

from circuitpython_nrf24l01 import RF24
import board
import digitalio as dio

# addresses needs to be in a buffer protocol object (bytearray)
address = b'Nessy'

# change these (digital output) pins accordingly
ce = dio.DigitalInOut(board.D4)
csn = dio.DigitalInOut(board.D5)

# using board.SPI() automatically selects the MCU's
# available SPI pins, board.SCK, board.MOSI, board.MISO
spi = board.SPI()  # init spi bus object

# initialize the nRF24L01 on the spi bus object
nrf = RF24(spi, csn, ce, ask_no_ack=False, data_rate=250)
nrf.dynamic_payloads = False # this is the default in the TMRh20 arduino library
nrf.payload_length = 32

# get username
username = input('Enter Username: ')

# set address of RX node into a TX pipe

# set address of TX node into a RX pipe
nrf.open_rx_pipe(1, address)

nrf.listen = True

print('Welcome %s' % username)
while True:

    # handle write
    if select.select([sys.stdin,],[],[],0.0)[0]:
        nrf.listen = False
        for line in sys.stdin:
            msg = b'[%b] %b' % (username.encode(), line.rstrip().encode())

    # handle recieve
    if not nrf.listen:
        nrf.listen = True

    if nrf.any():
        # retreive the received packet's payload
        buffer = nrf.recv()
        data = buffer.decode().replace('\x00', '')

Wireless Chat using Arduino & NRF24L01+ 2.4GHz RF Transceiver

It has been quite some time since I’ve tinkered with an Arduino, and this go around I decided to learn something new.

The NRF24L01 2.4GHz Transceiver is an extremely affordable wireless chip, I managed to pickup 10 units for around $12. This chip allows sending and receiving on the 2.4GHz wireless band.

Lucky for us there is a great Arduino library just waiting to be imported, thanks maniacbug!

So what did I set out to accomplish you ask? Why a chat application of course!


Source Code

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   9
#define CSN_PIN 10

const byte Address[5] = {'N','e','s','s','y'};

RF24 radio(CE_PIN, CSN_PIN);

String username = "";
String dataInput;
char dataToSend[32];
char dataReceived[32];

void setup() {
    Serial.println("Enter username...");
    radio.setRetries(3, 5);
    radio.openReadingPipe(1, Address);

void loop() {

  // set username
  while (username == "") {
    if ( Serial.available() ) {
      username = Serial.readStringUntil('\n');
      Serial.print("Welcome ");

  // listen for radio data
  if ( radio.available() ) {
    // read data from radio
    radio.read( &dataReceived, sizeof(dataReceived) );

  if( Serial.available() ) {
    // stop listening on radio
    // get serial input
    dataInput = "[" + username + "] " + Serial.readStringUntil('\n');
    dataInput.toCharArray(dataToSend, 32);

    // send data
    radio.write( &dataToSend, sizeof(dataToSend) );  

Grafana 5.x Running on Raspberry Pi

Got around to upgrading my Raspberry Pi 3 Model B weather station with a newer version of Grafana, the Debian packages for ARM are hosted on Grafana’s download page under ARMv7.

Moving from a 2.x word to a 5.x has been impressive, most notably the drag, drop, and resize functionality.

I’m still using InfluxDB and Telegraf to store and populate my time data points.

Latest Raspbian’s (stretch) comes with Influx 1.0.2 and works nicely:

# dpkg -l | grep influxdb
ii  influxdb     1.0.2+dfsg1-1 armhf

While I needed to grab the Telegraf as a Linux Binary (ARM) from Influx’s download page.