GUIDE - NRF5 / NRF51 / NRF52 for beginners
alowhum last edited by alowhum
So you're curious about the NRF5 series boards huh? Let's dive in!
WHAT IS THE NRF5
It's a tiny Arm processor based board that can work like an Arduino. There are a few flavours.
NRF52840 $40 (new, has built in usb support)
Get the NRF52 version for now
- Arduino with built in NRF24 for just $3.
- The size of a postage stamp.
- Powerful enough to use the simple encryption functionality easily.
- Antenna socket: just plug in antenna for more range.
- Ultra low power use.
- You get to decide which pins do what. For example, you can decide through software which pins should be hardware serial pins. There's a small pin router built in.
- Built in support for NFC (swiping smart cards and tags).
- Has 3.3v internal logic. Most new sensors use 3.3v for logic too.
- Relatively new, so there might still be some bugs in MySensors.
- The pins cannot handle as much current (5ma) as the Arduino's could (40ma).
- Smaller pin spacing (1.27mm instead of 2.54mm), so harder to solder. Fewer expansion boards available.
- Unlike the Arduino Nano, the programmer doesn't also function as a serial monitor. To get serial output you have to set some pins as the serial output, and then connect to those pins with a separate usb serial port adapter. It's a bit like the Arduino Pro Mini in that sense.
- The EByte module has no onboard LED, which makes it difficult to know it's on, or to test things with a simple blink sketch.
Open the Arduino software and install these two boards in the Arduino IDE:
(click on the links to get installation instructions).
Carefully soldered some wires to your board, and connected it a programming tool. The cheapest simplest option is to get an ST-Link v2 ($3).
gnd ->gnd (in the corner)
3.3v -> vcc (in the same corner)
SWDIO -> SWDIO
SWDCLK -> SWDCLK
In the Arduino IDE open an example (file -> examples -> myboardNRF5 -> myboardNRF5). You will now have three files:
- Main file <- your main code goes here.
- MyBoardNRF5.h <- here you can set which goodies you want, on which pins.
- MyBoardNRF5.cpp <- probably no reason to change anything here.
In the main file make sure it has these lines:
In the Arduino IDe click on the tools dropdown and start set things up like this:
- Board: "MyBoardNRF5 NRF52832"
- Reset: "don't enable"
- Bootloader/SD: "none"
- Low frequency clock: "Crystal Oscilator" (RC Oscillator might work too).
- Port: none
- Programmer: ST-Link V2
First the chip you are using must be 'wiped'. This removes the bluetooth functionality. Wipe the chip by clicking "tools -> burn bootloader". You'll get an error but that's normal.
Next, when your sketch is complete, choose "sketch -> upload via programmer".
POWER HUNGRY SENSORS
If you were using an Arduino Nano before, then you might have powered your sensors directly from the Arduino's 5v pin. With these boards you can't run the power through the NRF5 board first. Make the 5V go 'around it'. Only use these boards to collect and send signals. To get a steady power supply, depending on how much you need, you could try:
- An AMS1117 regulator. It can generate a max of 800ma at 3.3v. Here's a small version.
- Special power supply boards such as this one.
- Timed out while waiting for target halted: are your pins connected ok?
- Unable to reset target: are your pins connected ok?
- Some things, like turning on a pin when you press a button, can be handled by (programmed into) the 'periphery' of the chip. Not having to wake up the main chip saves some power. An example of this can be found here.
Ebyte N73 - Manual
- Cheap: $3
- Is missing some parts that allows for super low power usage. Those can be added manually though.
- Forum users have created some nice pre-made prototyping boards, like this small one or this big one.
- Uses 91 milli amps max (while transmitting).
- Can't find the price
- Better range than the EByte
- Has the required 'DCDC' parts built in, allowing for super low battery usage.
- Uses 250ma max
- About $5
- Tiny! This also means it has less ports.
billgoolsby last edited by
So, following these steps the radio will support nrf24 protocols and you could use, for example, one of the available RF24 libraries?
smilvert last edited by
I have read https://devzone.nordicsemi.com/b/blog/posts/measuring-lithium-battery-voltage-with-nrf51 but which pin is VBG? p0.01 = adc?
Need to recalclulate the resistance for 2 aaa batteries.
@alowhum Can you clearify how to read MyBoardNRF5.h? Is PIN_AIN0 = p0.00?
What is the benift to use hwPinMode instead of using pinMode()?
alowhum last edited by
@billgoolsby I don't know about other NRF24 libraries. But MySensors definitely works.
@smilvert: I am not an expert, I'm a beginner sharing what I learnt so far. Perhaps other experts on the forum can help. It's probably a good idea to post advanced questions in the NRF5 thread.