This is only a preview of the January 2018 issue of Silicon Chip. You can view 37 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "Make your own Theremin – then make music!":
Items relevant to "The Lathe-E-Boy: high power Lathe Controller":
Items relevant to "Arduino LC Meter Shield Kit":
Items relevant to "High Power DC Fan Controller has loads of applications":
Items relevant to "El Cheapo Modules 12: 2.4GHz Wireless Data Modules":
Purchase a printed copy of this issue for $10.00. |
Using Cheap Asian Electronic Modules Part 12: by Jim Rowe
nRF24L01+ 2.4GHz Wireless
Data Transceiver Modules
This month we’re looking at a number of modules based on the
nRF24L01+ chip, a complete wireless data transceiver capable of up
to 2Mb/s over modest distances, in the 2.4-2.5GHz ISM (industrial/
scientific/medical) band. It has a standard SPI interface, making it
easy to use with any microcontroller.
C
onnecting a couple of Arduino,
Micromite or other popular micros
via a wireless data link, can be done by
making use of a pair of low-cost modules, based on Nordic Semiconductor’s ultra-low power nRF24L01+ chip.
There are quite a few of these modules around, most of them costing just
a few dollars, with the more expensive
units generally giving longer range (often due to a better antenna).
We published a Circuit Notebook
entry in the September 2016 issue
titled “Ultra-low-power, long-range
Arduino communications”, which you
can read online at www.siliconchip.
com.au/Article/10146
This circuit used an nRF24L01+
module, available with a whip antenna, from www.siliconchip.com.au/
Shop/7/3979
All modules based on the nRF24L01+ device operate in the internationally unlicensed 2.4-2.5GHz ISM
band and use the same kind of modulation, described below. So they can all
communicate with each other.
It’s important to realise that the 2.42.5GHz band is also used by Bluetooth
devices, most WiFi devices and is also
subject to various sources of noise like
microwave ovens. We have directly observed serious WiFi speed degradation
while a microwave oven was operating, so this isn’t just a theoretical issue.
Because it’s basically a “free-for-all”,
this is a noisy band and becoming noisier all the time. Still, there are ways to
minimise the risk of interaction and
interference, as we’ll explain later.
While you may not have heard of
Nordic Semiconductor before, many
of their chips are found in all kinds of
78
Silicon Chip
common devices like non-Bluetooth
wireless PC peripherals such as keyboards and mice, gaming controllers,
sports and fitness sensors, toys and
set-top box wireless remote controls.
Based in Trondheim, Norway, Nordic Semiconductor was established
in 1983 as a spin-off from the Technical University of Trondheim. It’s now
a publicly listed global Norwegian
company with full ISO 9001:2008 certification.
Inside the nRF24L01+ IC
Essentially, the nRF24L01+ is a
complete single-chip 2.4GHz wireless
data transceiver in a 20-pin QFN (4 x
4mm) package.
Fig.1 shows a block diagram depicting the internal circuitry of the
nRF24L01+ chip, on the left, while
that of the additional circuitry used
to augment performance in the higherpower modules is shown on the right.
For the present, let’s just concentrate
on the left-hand side.
On the left is the baseband section
which provides a full bi-directional
SPI (serial peripheral interface) port
plus an embedded “protocol engine”
(using Nordic’s “Enhanced ShockBurst” technology), transmit and receive data FIFO (first-in, first-out registers/memory buffers), a radio control
section and an array or “map” of control and configuration registers
The simplest nRF24L01+ module, with its circuit diagram shown in Fig.2.
Variants of this module might instead have a slightly different antenna track or
SMA connector for an external antenna,
Celebrating 30 Years
siliconchip.com.au
Fig.1: the internal block diagram of the nRF24L01+ IC to the left, with the additional circuitry used for performance
improvements in higher-power modules shown at right. The chip also includes a feature called Enhanced ShockBurst,
which implements a bidirectional data communication protocol that is primarily used for transferring data between two
of Nordic’s nRF51 chips (Bluetooth & 2.4GHz) or between an nRF51 and nRF24.
On the right is the RF section, which
includes an RF transmitter and receiver
plus an RF synthesiser, a power amplifier (PA) and a low noise amplifier
(LNA) for signal reception.
The chip’s SPI interface allows it
to be controlled by a micro while
the Enhanced ShockBurst baseband
engine provides a range of packet
data communication protocols, from
manual to advanced autonomous operation.
Basically, it handles all of the highspeed link layer operations. The two
FIFO buffers ensure a smooth data flow
between the RF front end and the microcontroller (via the SPI interface),
in both directions, storing data until
it can be processed.
The RF sections employ GFSK
modulation, which stands for Gaussian Frequency-Shift Keying, an en-
hanced form of frequency-shift keying in which the modulating data is
passed through a Gaussian filter to
make the transitions smoother, before
modulation.
This reduces sideband power and
cross-channel interference, at the
cost of increasing inter-symbol interference, which effectively limits the
maximum data rate to about 2Mb/s.
GFSK was the original type of modulation used in Bluetooth and is still
used in BR (basic rate) Bluetooth devices.
The nRF24L01+ can operate at data
rates of 250Kb/s, 1Mb/s and 2Mb/s,
although the 2Mb/s rate is not compatible with devices based on the earlier
nRF24L01 chip.
The transmitter is also programmable in terms of output power, with
four options available: 0dBm (1mW),
Fig.2: circuit diagram for the NRF24L01+. All connections are made via an
8-pin male header (CON1) which carries power and SPI connections.
siliconchip.com.au
Celebrating 30 Years
-6dBm, -12dBm or -18dBm (320µW).
This makes the chip very suitable for
ultra-low-power wireless links.
The RF sections of the chip can
be programmed to operate on any
of 125 frequency channels between
2.400GHz and 2.525GHz, with the
channels spaced 1MHz apart. However, the channels above 2.500GHz
are strictly out of the ISM band, leaving only the lower 100 for legal use.
In addition, since WiFi devices use
the spectrum between 2.400GHz and
2.484GHz fairly heavily, modules
using the nRF24L01+ are best programmed to use upper channels 85100 to ensure minimum interference
and the most reliable operation.
Also note that when the nRF24L01+
is being used at the highest data rate
of 2Mb/s, it can only use every second
1MHz channel because the modulation bandwidth is larger than 1MHz.
The selected channel frequency is
generated by the RF synthesiser section at lower right in Fig.1, using an
external 16MHz crystal connected between pins XC1 and XC2.
Despite its internal complexity and
multiple functions, the chip is surprisingly economical in terms of power
consumption.
Operating from a 3.3V DC supply,
the RF transmitter section draws only
11.3mA when set for the highest 0dBm
output power, while the receiver section draws only 13.5mA when receiving at the highest 2Mb/s data rate and
drops to 12.6mA at 250Kb/s.
So the nRF24L01+ is suitable for all
kinds of portable and battery-powered
applications, especially since the chip
is inexpensive.
January 2018 79
One of the fancier nRF24 modules that sports a reverse-SMA
socket with whip antenna and three extra SMD ICs to boost
RF signals. This module uses a combination of a TI CC2500/
CC2530 and SI4432, but not all modules will use the same set.
Complete modules
Quite a few wireless data transceiver modules based on the nRF24L01+
chip are currently available, falling
into two main categories:
• Those using only the chip itself
together with a handful of passive
components;
• and those which provide one or
more additional ICs to give higher RF
output and additional receiver preamplification, for longer range operation.
The basic types are the cheapest and
most popular but the higher-power
types are also quite widely used.
Fig.2 shows the complete circuit
for one of the basic modules. This
module is quite small, measuring
just 15 x 29mm, including both the
8-pin DIL header for SPI and pow-
er connections and the zig-zag PCB
track antenna.
There are other variations of this basic module which may have a hookshaped PCB track antenna instead of
the zig-zag pattern. Jaycar have this
latter module (Cat XC4508).
These have a slightly longer PCB,
measuring 15 x 33mm. Yet another variant has an SMA socket for connection
to an external antenna (instead of the
PCB track antenna) on a smaller PCB
measuring 10.6 x 23.8mm.
There’s very little in one of these
modules apart from the nRF24L01+
chip itself. The 16MHz crystal (X1)
is at lower left (in Fig.2), while the
2.4GHz antenna and the passive components used to match the chip to it
are at upper right. All of the connec-
tions to and from the micro are made
via CON1 at upper left. The remaining passive components are mainly for
supply bypassing.
Fancier versions
As with the basic versions, there
are a number of variations when it
comes to the longer-range versions.
They all seem to consist of the basic
nRF24L01+ transceiver chip coupled
to a transmit/receive “front end” circuit, along the lines of what is shown
on the right-hand side of Fig.1. The
differences are mainly with regard to
the IC or ICs used in the added front
end and the antenna arrangements.
Fig.3 shows the circuit for one of
these augmented versions. The lefthand side is virtually identical to
the basic nRF24L01+ module circuit
shown in Fig.2 and so these modules
generally use much the same software
and I/O connections to the micro.
In this particular module, all of
the additional RF matching, filtering,
transmit/receive switching, power amplification and input preamplification
is done inside IC2 (shown on the right).
This is an RFaxis/Skyworks
RFX2401C device, rated to provide
25dB of transmit gain at 2.45GHz plus
12dB of receive gain with a noise figure
of 2.5dB. Both features should give a
very useful extension of the module’s
operating range.
Some of the other longer-range modules seem to use a combination of three
ICs in place of the RFX2401C. Some use
the TI CC2500 and CC2530 chips together with an SI4432, but we haven’t
been able to find a circuit for these.
Fig.3: circuit diagram for one of the fancier nRF24L01+ variants (photo at upper right, labelled YJ-13039). While the left
half of this circuit may be identical to Fig.2, there is additional circuitry around the RFX2401C (IC2) that sets it apart.
80
Silicon Chip
Celebrating 30 Years
siliconchip.com.au
Above: one of the fancier nRF24L01+ based
modules featuring a monopole ceramic chip
antenna at the end of the PCB. It also has
CON1 in the form of a single row of PCB pads.
Right: a different nRF24 module featuring a
metal shield around the circuitry to reduce
EMI; it also comes with a simple wire antenna.
Although one of the longer-range
modules shown in the photos has a
reverse-SMA socket for the antenna
connection and comes with a matching “rubber ducky” whip antenna, this
is not always the case.
Some modules simply come with
copper pads on the end of the PCB
to either solder on an SMA connector or else have a short piece of wire
soldered directly to the centre pad to
act as a DIY whip antenna. Still others
have a monopole ceramic chip antenna
mounted on the end of the PCB. One
of these is also shown in the photos.
One further point: most of the modules, whether basic or enhanced, have
a copper ground plane on the underside of the PCB (but not under the antenna) to reduce the level of EMI from
and into the nRF24L01+ and its associated circuitry.
A small number of the enhanced
units also have a screening can over
the whole of the circuitry on the top
of the PCB and these modules have
been found to be somewhat better for
reliable long-range operation.
Apparently, some users have
achieved similar results with the modules which lack an upper screening
can by wrapping the electronics part
of the module with thin brass or aluminium metal foil.
The foil should be covered on the
inside with a thin layer of plastic to
make sure it doesn’t cause any short
circuits, and should ideally also be
connected to the module’s PCB earth
(eg, via pin 1 of CON1).
Just make sure you don’t wrap the
foil around the end of the module’s
PCB with the antenna, or you’ll seriously reduce its range rather than increase it!
Working with an Arduino
Fig.4 shows how to connect any of
these modules up to an Arduino or
Arduino clone, taking advantage of
the fact that most of the connections
needed for interfacing to an SPI bus
are made available on the 6-pin ICSP
header fitted to most Arduino variants.
The connections to the ICSP header
are consistent with many Arduino
variants, including Uno, Leonardo
and Nano, the Freetronics Eleven and
LeoStick and the Duinotech Classic
or Nano.
Fig.4: wiring diagram showing how to connect an nRF24-based module to an Arduino board. On the next page there is a
photo showing one of these modules hooked up to a Freetronics ProtoShield, which can then be plugged directly into a
compatible Arduino board.
siliconchip.com.au
Celebrating 30 Years
January 2018 81
Left: you can see the header, 10µF tantalum capacitor and
various wires that need to be soldered to the Freetronics
ProtoShield that is plugged into an Arduino. The module is
then plugged into the 4x2-pin DIL female header.
Fig.5 (above): example output from running the Arduino
sample program. The upper half of the screen grab shows
one of the modules in “transmit” mode, while the lower half
is in “receive” mode.
The only connections that are not
available via the ICSP header are those
for +3.3V, CE and CSN which need to
be connected to the IO7 and IO8 pins
respectively.
The reason why they need to be
connected to those particular pins of
the Arduino is that these are expected
by the most popular and easy to use
Arduino Library for nRF24L01+ based
modules. More on that later.
Before we move on to the firmware, in the photos above you’ll see a
Freetronics ProtoShield wired up to
connect an nRF24L01+ based module
to an Arduino Uno or its equivalent.
It’s fitted with a 4x2 DIL header
socket near the centre of the shield to
accept the nRF24L01+ module’s plug,
82
Silicon Chip
with short lengths of hookup wire to
make the connections between the
header socket pins and the appropriate Arduino pins. The 10µF tantalum
bypass is fitted very close to the pin 1
end of the header socket, to keep its
leads as short as possible.
This little shield cost less than $5,
took very little time to make and works
well. Having built it, the next step
was to install the RF24 Library in the
Arduino IDE.
The Arduino RF24 Library
Written by a programmer with the
moniker of “TMRh20”, the Library is
called RF24. The latest version is available in zipped-up form from https://
github.com/maniacbug/RF24 Click on
Celebrating 30 Years
the green “Clone or download” button
and then “Download ZIP”.
To help you get started using a couple of nRF24L01+ modules to set up a
wireless link between two Arduinos, I
have adapted one of the “Getting Started” sketches provided by TMRh20 to
show how to make use of his/her RF24
library. The revised sketch is called
“sketch_to_check_nRF24L01_modules.ino”, and is available for download from the Silicon Chip website.
Having downloaded the RF24
library zip, fire up the Arduino IDE,
open up the sketch and then get
the IDE to add the RF24 to its list of
libraries. This is done by clicking on
the “Sketch” drop-down menu, then
clicking on “Include Library” down
siliconchip.com.au
The sample program running on a
Micromite LCD BackPack. Unlike
the Arduino program, setting which
device is the receiver or transmitter is
done via the touchscreen, rather than
serial input.
Fig.6: connections required for the NRF24L01+ to a Micromite. The 10µF
capacitor between pins 1 & 2 is optional but recommended
near the bottom, and then on “Add
.ZIP Library”.
The IDE will then provide a dialog
to let you select the RF24 ZIP library
you’ve downloaded, whereupon it
will automatically unpack and install
the library.
The sketch has been written so that
it can be uploaded to two Arduinos,
one at each end of your proposed wireless link. The only thing that needs to
be changed is the value of the parameter “radioNumber”, in the first line of
code after the introductory comments
and the five #include lines. As supplied, the line looks like this:
bool radioNumber = 0;
but for the second Arduino, it should
be changed to:
bool radioNumber = 1;
Then when you power up both Arduinos (each with an nRF24L01+ module connected), they can communicate
with each other. The software is controlled via the Arduino IDE’s Serial
Monitor utility.
To start one Arduino pinging the
other, press the T key on that PC’s keyboard, and then the Enter key. That Arduino will then begin sending a number (the time it has been powered up
in microseconds) to the other, via the
wireless link.
The other should then respond by
returning the same number, after a
short delay. This should be visible
in the Serial Monitor dialog, which
should look like the screen grab shown
in Fig.5. If you then press the R key,
siliconchip.com.au
followed by Enter again, the Arduinos
should swap roles, with the local one
becoming the receiver and the other
one becoming the transmitter.
The display in the Serial Monitor
dialog should change, as shown halfway down the screen grab, with a
series of lines showing when it sends
each response back to the other
Arduino.
So this sketch shows how a couple
of Arduinos can be hooked up via a
2.4GHz wireless link, using a pair of
nRF24L01+ based modules.
Doing it with a Micromite
Connecting one of these modules up
to a Micromite is done using the connections shown in Fig.6. The MOSI,
MISO and SCK lines are connected to
pins 21, 22 and 24 of the Micromite
as shown. The CE and CSN lines are
connected to Micromite pins 17 and 18
respectively in this example. As with
the Arduinos, it’s also a good idea to
connect a 10µF tantalum capacitor between pins 1 and 2 of the nRF24L01+
module.
Now if you’re wondering why these
SPI connections to the Micromite are a
little different from those you’ve seen
in other projects, that’s because we’re
making use of an “additional” SPI port
on the Micromite, provided by means
of an embedded C function in Geoff
Graham’s MMBasic.
This is being used as an alternative to the SPI port already built into
MMBasic, to prevent timing conflicts
when you’re using an LCD BackPack
version of the Micromite.
Celebrating 30 Years
The reasoning behind this is that
there doesn’t seem to be available at
present any pre-written Micromite
applications or libraries available to
control and exchange data with the
nRF24L01+ chip – so basically, I’ve
had to write one myself.
This took quite a while, as programming the nRF24L01+ turned out to be
surprisingly complex and confusing. I
ended up having to get help from Geoff
Graham, as well as from the support
engineers at Nordic Semiconductor.
By the way, if you want to see how
complex programming the chip really
is, you can download a copy of the 78page product specification called “nRF24L01+ Product Specification v1.0”
for free from Nordic Semiconductor’s
website (www.nordicsemi.com/eng/
Products/2.4GHz-RF/nRF24L01P).
Anyway, I finally got the program to
work, with two Micromite LCD BackPacks exchanging data in both directions without problems. Whew!
You can see the display it provides
on the Micromite’s LCD screen in the
photo above, allowing the Micromite
to be configured as either Radio #0 or
Radio #1; and for either RECEIVE or
TRANSMIT.
This is configured using the LCD
touchscreen, but as with the Arduino
sketch, the actual data being transmitted or received is printed/displayed
on the PC in the MMChat windows
for each device.
The program is not very fancy, but it
should at least provide a good starting
place for writing more complex programs of your own.
The program is called “nRF24L01
checkout.bas”, and is available to
download from the Silicon Chip webSC
site.
January 2018 83
|