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.

    WHAT IS THE NRF5
    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

    Advantages:

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

    Neutral:

    • Has 3.3v internal logic. Most new sensors use 3.3v for logic too.

    Negative:

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

    INSTALLATION
    Open the Arduino software and install these two boards in the Arduino IDE:
    https://github.com/sandeepmistry/arduino-nRF5
    https://github.com/mysensors/ArduinoBoards
    (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).

    Connect:
    gnd ->gnd (in the corner)
    3.3v -> vcc (in the same corner)
    SWDIO -> SWDIO
    SWDCLK -> SWDCLK

    alt text

    Software
    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".

    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.

    TROUBLESHOOTING

    • Timed out while waiting for target halted: are your pins connected ok?
    • Unable to reset target: are your pins connected ok?

    ADVANCED KNOWLEDGE

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

    POPULAR BOARDS

    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.

    UPDATE

    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 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()?



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

    0_1539373638995_62032ad8-33ff-45ec-8ecd-96bf06cf2668-image.png

    Could that be related to drivers? I've run Zadig, there are more options and I've tried all four of them
    0_1539373888360_c3271a31-a273-4576-91fc-f7f3501d51f2-image.png

    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.


 

378
Online

7.8k
Users

8.7k
Topics

92.9k
Posts