GUIDE - NRF5 / NRF51 / NRF52 for beginners

  • So you're curious about the NRF5 series boards huh? Let's dive in!

    // updates can be found below.

    It's a tiny Arm processor based board that can work like an Arduino. There are a few flavours.
    NRF51 $3
    NRF52 $3
    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)

    alt text

    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:
    #define MY_RADIO_NRF5_ESB
    #include <MySensors.h>

    Upload settings
    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".

    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).

    Fanstel BT832X

    • 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

    Holyiot TinyBLE

    • About $5
    • Tiny! This also means it has less ports.


    The easiest way to get started with NRF5 might actually be the BCC Microbit.

  • @alowhum ,
    So, following these steps the radio will support nrf24 protocols and you could use, for example, one of the available RF24 libraries?

  • Hi.

    I have read 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()?

  • @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.

  • I am starting to experiment with NRF51822. Thank you all for this thread. I am stuck with setting up IDE on Win10 and my MCU is not communicating. What is the correct setup for Arduino IDE?
    I have Port still grayed out and error: The selected port not exist


    Could that be related to drivers? I've run Zadig, there are more options and I've tried all four of them

    I am not able to upload even erase sketch. Any suggestion where to focus (IDE/Zadig/other)?

  • Mod

    @xmonika which programming tool are you using? ST-Link v2? Could you post a photo of your wiring?

  • @xmonika have you tried to erase it? In most cases if is start with a new module I first need to erase is once.

    Shortcut => burn bootloader, this will give an error but you should be good to go from there.

  • @omemanti @mfalkvidd Thank you, I think I did it. It works now - or I hope so from the code.

    ** Programming Finished **
    ** Verify Started **
    nrf51.cpu: target state: halted
    target halted due to breakpoint, current mode: Thread 
    xPSR: 0x61000000 pc: 0x2000002e msp: 0x20004000
    verified 1412 bytes in 0.038633s (35.692 KiB/s)
    ** Verified OK **
    ** Resetting Target **
    shutdown command invoked

    What I was confused is that there is erase sketch, but to make it erased there is this trick with burn bootloader. Still the port is greyed out, but it seems I am able to flash blank sketch. Thanks

  • @xmonika I use the ST-Link, mine is always greyed out. The only time im able to select a port, it's when I'm using an FTDI to use the serial monitor. So I think everything looks normal.

  • @omemanti

    I have tried EVERYTHING to get an ST-LINK V2 to program an NRF52. That includes - multiple ST-LINK's, multiple computers, Linux, "burn bootloader" first, and pretty much everything I could read on this forum. The error message is always:

    Open On-Chip Debugger 0.10.0-dev-00254-g696fc0a (2016-04-10-10:13)
    Licensed under GNU GPL v2
    For bug reports, read
    debug_level: 2
    Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
    adapter speed: 10000 kHz
    Info : Unable to match requested speed 10000 kHz, using 4000 kHz
    Info : Unable to match requested speed 10000 kHz, using 4000 kHz
    Info : clock speed 4000 kHz
    Info : STLINK v2 JTAG v32 API v2 SWIM v7 VID 0x0483 PID 0x3748
    Info : using stlink api v2
    Info : Target voltage: 3.252590
    An error occurred while uploading the sketch
    Error: init mode failed (unable to connect to the target)
    in procedure 'program'
    in procedure 'init' called at file "embedded:startup.tcl", line 473
    in procedure 'ocd_bouncer'
    ** OpenOCD init failed **
    shutdown command invoked

    Any ideas?


  • Hero Member

    Are you powering the target from an external power source? If not, try that.

  • Unfortunately- I did try that - although without an led it’s hard to know if the board really is getting power. I will check with a multimeter.

  • @ileneken3 said in GUIDE - NRF5 / NRF51 / NRF52 for beginners:

    hat - although without an led it’s hard to know if the board really is getting power. I will check with a multimeter.

    did you use zadig to install the drivers for the ST-Link?

  • @omemanti

    Yes, I used Zadig. From the Device Manager in Windows, it displays "STM32 STLink" when the programmer is plugged in.
    In Linux, the device seems to be recognized automatically without installing any drivers.

  • @ileneken3

    Yes, I'm connecting 3.3 volts to VCC and GND on the board, while connecting the programmer to the PC's USB port. I'm assuming there is no need for a common ground?

    Oh well...

  • This post is deleted!