nRF24L01+ radio

The little green 2.4 GHz transceiver with a zigzag antenna printed on the end. Aliases: nRF24, 2.4 GHz radio, RF module.

Put down two of them on two boards, with a sketch on each that sends and receives packets. RF24.h drives it.

Every radio on the canvas shares the air

Put two radios down, wire each to its own board, and they hear each other. There is no wire to draw between them. Behind the scenes the air is the ninth pin, ANT, at the tip of the antenna: Mokxi joins the ANT of every radio on the canvas, and that shared line is the room. Two radios that talk at the same time really do spoil each other's packets, because each pulls the line low for its own bits.

You can wire a logic analyzer to ANT to watch the packets go past, one byte at a time.

Pins

Pin What it does
GND Ground.
VCC Supply, 1.9 to 3.6 V. Use the 3.3 V pin, not 5 V.
CE Chip enable: high to listen, or to send what is queued.
CSN SPI chip select.
SCK SPI clock.
MOSI SPI data in.
MISO SPI data out.
IRQ Low when a packet arrived, was sent or failed. Often left unwired.
ANT The air every radio on the canvas shares. Leave it unwired.

A common Uno wiring is CE to 9 and CSN to 10 (or 7 and 8), with SCK, MOSI and MISO on 13, 11 and 12.

What is modeled

The chip is its datasheet: every register with its reset value, the SPI commands, the three-deep TX and RX FIFOs, the 1.5 ms power up and the 130 us settling time, CE, and the IRQ pin. The packet engine is Enhanced ShockBurst: addresses of 3 to 5 bytes on six pipes, static or dynamic payloads of up to 32 bytes, a one or two byte CRC, automatic acknowledgment with ACK payloads, and retries: the sender waits ARD for the ACK and tries again up to ARC times before it gives up. So radio.write() returns false when nobody is listening, on the wrong channel, at the wrong data rate or on the wrong address, and true when the ACK comes back.

RF24.h has begin, openWritingPipe, openReadingPipe, startListening, stopListening, available, read, write, setChannel, setPALevel, setDataRate, setRetries, setPayloadSize, enableDynamicPayloads, enableAckPayload, writeAckPayload, setAutoAck, powerDown and printDetails.

What is not modeled

The radio itself: range, walls, fading, interference from WiFi, and output power, which is stored and does nothing. On the wire each byte is framed like a UART's at the air data rate, and every packet starts with the channel number, which stands in for the frequency. That framing is Mokxi's, not Nordic's, and a packet takes a little longer on this wire than in the air.