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:

Components

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
nrf.open_tx_pipe(address)

# 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())
            nrf.send(msg)
            break

    # 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', '')
        print(data)

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!

Components

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.begin(9600);
    Serial.println("Enter username...");
    
    radio.begin();
    radio.setDataRate(RF24_250KBPS);
    radio.setRetries(3, 5);
    radio.openWritingPipe(Address);
    radio.openReadingPipe(1, Address);
}


void loop() {

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

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

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

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

Reaper Bone Miniature Preparation

I can’t believe it’s been nearly 7 years since I’ve backed Reaper Miniatures Bones II: The Return Of Mr Bones!; it was my first real exposure to the miniature painting hobby.

Over the years, I’ve had ups and downs with these affordable figurines, and I’ve certainly learned a thing or two.

By no means is this the only way to prepare a Reaper Bones Miniature, this is merely the approach I take to help illuminate those fine details before adding color.

Bath

As you may have heard Reaper Bones Miniatures often retain their mold release agent; this can effect how paint adheres to it.

It’s never a bad idea to give your figure a soapy wash & scrub. I use an old frayed toothbrush and some dish soap.

Make sure to let it fully dry before applying any paint!

Base

It wasn’t until recently that I leaped back into the miniature painting hobby I recalled that I had a large hoard of Reaper Bones Miniatures just stashed away on a bookshelf.

This time I was more inspired, and had many excellent sources on YouTube to learn from:

The absolute best tips I’ve had in regards to Reaper Bones Miniatures was from Black Magic Craft: I should be base coating with a cheap acrylic paint rather than spray primer. This really helps with paint adhesion later on.

I like to use Antique White Apple Barrel Acrylic with a healthy mixture of Liquitex Professional Matte Fluid Medium. Then, with a heavy hand, I make sure every surface is coated.

Be sure to leave your miniature to fully dry; it shouldn’t take much longer than a hour.

After grabbing a sandwich or ale, your figure should look something like this:

Wash

We are now ready for the fun, and frankly, if I’m honest, the messiest part of preparation.

I keep a container of cheap black wash in an old glass jar. This mixture consists of water, any ol’ black acrylic paint, Liquitex Professional Matte Fluid Medium, and a single drop of dish soap.

Go ahead and add your signature touch. I attach my figure to an old paint bottle using some Aleene’s Instant Tacky Craft Putty, then give it a couple of dunks in the mixture. Make sure to drip the excess wash back into the container.

After dunking you can thin large globs of wash using an old paint brush, you can also add more wash from the jar if you feel some areas are lacking.

Once I’m satisfied with the wash I let the figure dry overnight, remember you can always give it another couple dunks the following morning.

And that’s it.

I’m now able to see those finer details, and take advantage of translucent acrylic paints.