Preparation of a Nordic nRF52 DK

104 views
Skip to first unread message

Markus Rebbert

unread,
Feb 10, 2021, 2:57:04 AM2/10/21
to ant-api
Hi,

first of all I would like to apologise for my perhaps trivial questions.

I am currently stuck in the preparation of the Nordic nRF52-DK:
I can't manage to load the ANT Network Processor firmware properly. 
ANTwareII does not show me the device and I cannot establish a connection.

I use the nRF Programmer to load the SoftDevice or the FW, but I am not really sure how to proceed.
Therefore my questions:
1. which Softdevice do I need to use ANT+ with the antplus-arduino library (thisisant: S332, S313, S312, S212? and which version)?
2. which network processor do I use (thisisant offers S210 and S310)?
How do I combine the (HEX) files for the programmer? Do I need FW and SoftDevice? How do I proceed?

Hope, you could help me out?

KR,
Markus

Gábor Ziegler

unread,
Feb 10, 2021, 7:04:44 AM2/10/21
to Markus Rebbert, ant-api
Hi Markus,

I sense some confusion here. Let me try to clarify a few things:
  1. Curtis Malainey's ant-arduino library expects an arduino compatible MicroController Unit (MCU) to run the library on. It is supposed to talk some ANT+ radio capable device ( ANT-device, or ANT-MCU)  somehow
  2. The ANT-device can be either embedded into the same hardware which realizes the MCU (in this case the ANT-device is a software-only device, i.e., a "softdevice"), or it can be an external hardware device.
    1. If external then ant-arduino needs to have some asynch serial communication (UART)  being set up between the MCU and the ANT-device, then the ant-arduino library (together with your own Wiring-language code) needs to properly use that  asynch. serial connection to control the ANT-device. I.e., you have to solve the setup and the handling of that serial port (could be either a software-, or a hardware-serial)
    2. If internal (embedded) then
      1. the communication is done via shared memory access between the MCU and the ANT-device, i.e., instead of polling/handling of a serial communication you have to make your communication via API calls and callbacks
      2. your own (and ant-arduino's) Wiring language code and th ANT-softdevice's code will share the same HW, therefore your code must be prepared/adapted to a multithreaded real-time environment: i.e., properly handle semaphores, interrupt handlers, etc.
Now you talk about a Nordic nRF-52-DK. That is a concrete hardware development kit (DK) from NordicSemi, which contains a specific MCU type (ARM Cortex M4 CPU) integrated with some NordicSemi 2.4Ghz radio chips into some Integrated Circuit packages. Such a combination is often called a System-on-Chip (SoC). Such SoC solution corresponds to the "embedded ANT-softdevice" case above. See ANT basics, especially this pic:
image.png


You asked, what softdevice do you need. My answer: you have to study and understand the specification of the nRF-52 Development Kit, i.e., that piece of hardware in your hand. You shouldn't skip that step. As soon as you understand what is in your hand, then you will know what softdevice do you need.
Your second question about how to load the formware. Check out my Hint2 above. ;)

Your problem statement about ANTware not showing your device: the ant-arduino library alone won't do that for you. You must make up your mind and decide to write some application software on top of the library. Ant-arduino and the softdevice are not applications, they are just a softdevice and the device-driver for it. Check out Nordic's tutorial and/or the examples in the ant-arduino lib.

In order to let Antware "see" your device, it must contain some application code running on top of the ANT+ radio,  communicating over some ANT+ radio channel in a way that happens to conform to some ANT+ protocol standard's profile, see ANT+ Device Profiles. You have to make up your mind and decide: what is your desired ANT+ profile and then you should implement your software logic accordingly. Ant-arduino library examples might help there.

Br,
Gabor


--
You received this message because you are subscribed to the Google Groups "ant-api" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ant-api+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ant-api/1944bd68-6649-4809-8658-fd1af15d7670n%40googlegroups.com.

Markus Rebbert

unread,
Feb 10, 2021, 11:00:42 AM2/10/21
to ant-api
Hey, Gabor,

Thank you very much for your detailed explanation. I already knew some of it, but it helps me to connect things properly.

I reduced my description to the preparation of the board (my mistake), as I had found a reference to this in the first message here in the group. However, what I initially had in mind corresponds exactly to the picture on the left and the intention of the library (as I understand it): Connect an Arduino (Leonardo) to the DK via the serial interface.

But yes, you're right, I partially skipped the Nordic Getting started section. Partly because some Windows applications were required (and I actually work on a Mac). I will do better. 

About Antware: I had assumed that I would see the device even without the application. Thank you for pointing this out.

Thanks & BR,
Markus

Gábor Ziegler

unread,
Feb 10, 2021, 4:08:04 PM2/10/21
to Markus Rebbert, ant-api
Hi Markus,

Markus Rebbert <markus....@gmail.com> ezt írta (időpont: 2021. febr. 10., Sze, 17:00):
Hey, Gabor,

Thank you very much for your detailed explanation. I already knew some of it, but it helps me to connect things properly.

I reduced my description to the preparation of the board (my mistake), as I had found a reference to this in the first message here in the group. However, what I initially had in mind corresponds exactly to the picture on the left and the intention of the library (as I understand it): Connect an Arduino (Leonardo) to the DK via the serial interface.
That might work, but then you have to keep in your mind two important things.

On one hand: the nRF-52 DK is --- a DK. That is, it is intended for development.  That is without any application code.

If your intended use-case is to use the DK as a "dumb" ANT radio module, then first you have to somehow either develop, or obtain application software, which application software would realize the business logic which makes that DK board into an "ANT network processor". 

A more cheaper, simpler, less painful solution would be to purchase a real  (and "dumb") ANT network processor. AFAIK, the currently available such devices on the market are ANT+ "USB-sticks". You might be able to buy some earlier non-USB models on eBay, but with the nRF-52 DK you have to solve the problem  of "dumbifying" the DK yourself.

Note, that nRF-52 DK is a hardware DK which comes with a software-DK (SDK), i.e., with the nRF5 SDK. That SDK has many-many examples, several of them are examples of how one could make an application realizing, say, the ANT+ HRM profile.  That SDK is for the C++ programming language, on which the Wiring language is based, too.

Summary: if you want to connect the nRF-52 DK as a "dumb" ANT-radio to some external Arduino compatible MCU -- that is quite possible, too, provided that
  • you define a suitable serial communication protocol for yourself
  • and write the appropriate C++ code for the DK that sends/receives messages according to that protocol over the hardware serial port of the nRF-52 DK board and controls the ANT+ radio of the board accordingly
  • and you write some Wiring code on your favourite Arduino compatible MCU (the Leonardo) that speaks the same protocol and use that protocol  over the serial port of the said MCU
  • and finally you connect the serial ports of both your MCU and the DK board via a suitable cabling
However, on the other hand, you have to note that the n-RF52 DK is not a dumb ANT+ radio (albeit it can emulate such one), not at all. It is a complete SoC. It contains, among others, a quite powerful ARM Cortex M4 MCU itself, which is an Arduino compatible MCU, much more powerful alone than the MCU in the Leonardo board...

In other words, if you have both the Leonardo and the nRF-52 DK, then forget about the Leonardo and use the onboard Arduino compatible MCU of the DK. After you have read the "Getting Started" of the DK board, you will have learnt that the DK board:
  • is an Arduino compatible MicroController Unit (MCU) itself
  • its PCB board and its hardware GPIO interfaces are configured such way that you can use any Arduino form-factor compatible "shield" with the DK
  • its ARM Cortex M4 MCU is far more powerful than the ATmega32u4 MCU on the Leonardo board...
  • and so on and so forth.
In other words, using a Leonardo to control an nRF52-DK "in dumb ANT+ radio mode" is a pure waste, IMHO,

I would simply suggest you to assign all your "Arduino code" to the ARM Cortex M4 onboard on the n-RF 52DK instead of the good old Leonardo, which is a mediocre MCU compared to the Cortex M4....

///G


Br,
Gabor



 

Curtis Malainey

unread,
Feb 10, 2021, 8:27:12 PM2/10/21
to Gábor Ziegler, Markus Rebbert, ant-api
Hi Markus and Gabor,

I agree with Gabor for selecting which radio you need, typically they correlate to various radio protocols support (e.g. ANT vs ANT+BLE vs ANT+BLE central). Know your use case so you can optimize memory.

On Wed, Feb 10, 2021 at 1:08 PM Gábor Ziegler <orr...@gmail.com> wrote:
Hi Markus,

Markus Rebbert <markus....@gmail.com> ezt írta (időpont: 2021. febr. 10., Sze, 17:00):
Hey, Gabor,

Thank you very much for your detailed explanation. I already knew some of it, but it helps me to connect things properly.

I reduced my description to the preparation of the board (my mistake), as I had found a reference to this in the first message here in the group. However, what I initially had in mind corresponds exactly to the picture on the left and the intention of the library (as I understand it): Connect an Arduino (Leonardo) to the DK via the serial interface.
That might work, but then you have to keep in your mind two important things.

On one hand: the nRF-52 DK is --- a DK. That is, it is intended for development.  That is without any application code.

If your intended use-case is to use the DK as a "dumb" ANT radio module, then first you have to somehow either develop, or obtain application software, which application software would realize the business logic which makes that DK board into an "ANT network processor". 

Dynatstream publishes the code for the network processor, you can fetch it from thisisant.com That being said I have never personally loaded it since all the D52 modules come preloaded with the network processing firmware. My guess is you could use nrfutil a segger tool to load the hex published which might contain the softdevice for you.
 

A more cheaper, simpler, less painful solution would be to purchase a real  (and "dumb") ANT network processor. AFAIK, the currently available such devices on the market are ANT+ "USB-sticks". You might be able to buy some earlier non-USB models on eBay, but with the nRF-52 DK you have to solve the problem  of "dumbifying" the DK yourself.

Lol i should read before I write,  but yes my recommendation for those who dont want to futz with tooling. Digikey is usually the best source.
 

Note, that nRF-52 DK is a hardware DK which comes with a software-DK (SDK), i.e., with the nRF5 SDK. That SDK has many-many examples, several of them are examples of how one could make an application realizing, say, the ANT+ HRM profile.  That SDK is for the C++ programming language, on which the Wiring language is based, too.

Summary: if you want to connect the nRF-52 DK as a "dumb" ANT-radio to some external Arduino compatible MCU -- that is quite possible, too, provided that
  • you define a suitable serial communication protocol for yourself
  • and write the appropriate C++ code for the DK that sends/receives messages according to that protocol over the hardware serial port of the nRF-52 DK board and controls the ANT+ radio of the board accordingly
  • and you write some Wiring code on your favourite Arduino compatible MCU (the Leonardo) that speaks the same protocol and use that protocol  over the serial port of the said MCU
  • and finally you connect the serial ports of both your MCU and the DK board via a suitable cabling
However, on the other hand, you have to note that the n-RF52 DK is not a dumb ANT+ radio (albeit it can emulate such one), not at all. It is a complete SoC. It contains, among others, a quite powerful ARM Cortex M4 MCU itself, which is an Arduino compatible MCU, much more powerful alone than the MCU in the Leonardo board...

Very true, some boards (when using the shared memory method) can enable high level ANT protocols such as ANT blaze (not used in ANT+ or ANT-FS) which is a mesh networking system.
 

In other words, if you have both the Leonardo and the nRF-52 DK, then forget about the Leonardo and use the onboard Arduino compatible MCU of the DK. After you have read the "Getting Started" of the DK board, you will have learnt that the DK board:
  • is an Arduino compatible MicroController Unit (MCU) itself
  • its PCB board and its hardware GPIO interfaces are configured such way that you can use any Arduino form-factor compatible "shield" with the DK
  • its ARM Cortex M4 MCU is far more powerful than the ATmega32u4 MCU on the Leonardo board...
  • and so on and so forth.
In other words, using a Leonardo to control an nRF52-DK "in dumb ANT+ radio mode" is a pure waste, IMHO,

Agreed, the nRF52 is much more powerful
 


I would simply suggest you to assign all your "Arduino code" to the ARM Cortex M4 onboard on the n-RF 52DK instead of the good old Leonardo, which is a mediocre MCU compared to the Cortex M4....

Yes and if you load the right soft device you can use BLE as well. If you want to use my libs you still can, they can work when the radio is on the same chip as well to help enable quick sports profiles.

Curtis
 

Gábor Ziegler

unread,
Feb 11, 2021, 1:40:48 AM2/11/21
to Curtis Malainey, Markus Rebbert, ant-api
Nrfutil is actually "the" flasher tool used by the Arduino framework...

Curtis Malainey

unread,
Feb 11, 2021, 2:00:02 AM2/11/21
to Gábor Ziegler, Markus Rebbert, ant-api
On Wed, Feb 10, 2021 at 10:40 PM Gábor Ziegler <orr...@gmail.com> wrote:
Nrfutil is actually "the" flasher tool used by the Arduino framework...

Makes sense, its an official nordic tool https://github.com/NordicSemiconductor/pc-nrfutil 

Gábor Ziegler

unread,
Feb 12, 2021, 6:54:12 AM2/12/21
to Markus Rebbert, ant-api
I feel that it would have seemed more friendly to "just" answer  your questions - but I am not sure if that would have been more helpful, either, since that might have led you astray, too. Anyway, here it goes:
1. which Softdevice do I need to use ANT+ with the antplus-arduino library (thisisant: S332, S313, S312, S212? and which version)?
"A SoftDevice that combines Bluetooth and ANT is the S332 SoftDevice for the nRF52 Series", see NordicSemi's Getting Started guide

2.which network processor do I use (thisisant offers S210 and S310)? As long as you (just) want to use ANT, it does not matter. Note, however, that S310 and S210 are not for the nRF52, but for the nRF51 series. See https://www.nordicsemi.com/Software-and-tools/Software/ANT-software

How do I combine the (HEX) files for the programmer? It depends on the toolchain you choose.
* The NordicSemi documentation refers to 4 different toolchains: https://www.nordicsemi.com/Software-and-tools/Development-Tools/IDEs-and-Toolchains
* Arduino tool chain: I have written a tutorial for dummies (like me) about a (specific) nRF52 chip-series based based (specific) SoC integration into the Arduino IDE: https://blogarak.wordpress.com/2020/03/29/arduino-ide-integration-for-the-nrf52840-feather-express-with-s340/. Note, that the tinyUSB bootloader of Adafruit has been significantly overhauled meanwhile, so some of the steps in my blogentry might be outdated.
Many of the toolchains eventually use the NordicSemi utility 'mergehex' , but not all.

Do I need FW and SoftDevice? The SoftDevice is a part of the FW, like your application should be compiled into the same  "FW".

How do I proceed? I suggest you should describe what your end goal is. What do you want to achieve? Then we might be able to suggest a learning path. Depending on your use-case I might suggest to completely abandon the microcontroller path, for example and go, say, for a single-board computer like a Raspberry and use (say) Python and a USB-stick for ANT+ communication...

///G

Markus Rebbert <markus....@gmail.com> ezt írta (időpont: 2021. febr. 10., Sze, 8:57):
--

Markus Rebbert

unread,
Feb 12, 2021, 7:54:42 AM2/12/21
to ant-api
Hi Gabor,

sorry for the delay - I've been busy at work and can't get to my projects right now.
Your (Curtis' and yours) informations was really helpful in getting the things into the right order (even though I haven't made much progress yet due to time constraints). As I said, even though I might have already known or guessed the individual parts, I found it difficult to combine them.

And yes, you're right, the DK ist much oversized for the first use case. It was more of a one size fits all purchase - because I didn't know exactly what I wanted to do with it in the end and I didn't know any better.. In retrospect, it would have been better to buy a much smaller solution.

But you asked what I want to achieve in a very first step: I would like to control a fan depending on heart rate, (virtual) speed and temperature. The fan is controlled with an AC dimmer; the connected Arduino is controlled via RF-433Mhz. (works already). That's it (for the moment).
 So one thing led to another. I wanted to stay with Arduino and not learn a new IDE, debugger etc., but concentrate on the use case. In the process, I found this helpful library, including the reference to the two serial interfaces, which makes debugging more convenient, etc. - therefore the Leonardo. And yes, you're also right, maybe an RPi and Go, Python & Co. would bring me closer to my goal (and would be closer to where I come from - but where's the fun in that? ;))

I think I now have three alternatives:
1. use the DK also as MCU (I had actually already started with that - but found the debugging a bit unusual)
2. switch completely to RPI etc.
3. find an ANT+ alternative (stick, etc.) (any suggestions?) - and use it with the Leonardo.

Thanks again for your explanations and links. This is very helpful.

Best Regards,
Markus

Gábor Ziegler

unread,
Feb 12, 2021, 8:23:34 AM2/12/21
to Markus Rebbert, ant-api
Hi,

Markus Rebbert <markus....@gmail.com> ezt írta (időpont: 2021. febr. 12., P, 13:54):
But you asked what I want to achieve in a very first step: I would like to control a fan depending on heart rate, (virtual) speed and temperature.
Let me guess: indoor bike training?


The fan is controlled with an AC dimmer; the connected Arduino is controlled via RF-433Mhz. (works already). That's it (for the moment).
 So one thing led to another. I wanted to stay with Arduino and not learn a new IDE, debugger etc., but concentrate on the use case. In the process, I found this helpful library, including the reference to the two serial interfaces, which makes debugging more convenient, etc. - therefore the Leonardo. And yes, you're also right, maybe an RPi and Go, Python & Co. would bring me closer to my goal (and would be closer to where I come from - but where's the fun in that? ;))

I think I now have three alternatives:
1. use the DK also as MCU (I had actually already started with that - but found the debugging a bit unusual)
I also use an MCU from the nRF-52 series. Particularly, I use the Adafruit nRF52804 Feather Express, but I started with the corresponding NordicSemi DK: the nRF52840-DK (which was an expensive overkill, too). The nRF52840-DK board has been fully integrated with the ArduinoIDE: the Adafruit-nRF52 Arduino-framework contains direct support for that.

Now, about your nRF-52DK: checkout this webpage: https://jimmywongiot.com/2020/09/07/arduino-ide-with-nrf52-dk-board/
It seems SparkFun has made the integration for you...

2. switch completely to RPI etc.
That has pros and cons. If battery operated is the goal, then I think the MCU alternative makes sense. Otherwise, if AC-power is available for your project then I think your life would be much-much more simpler on a Raspberry, as ANT+ has pretty good SW support with Python on Linux (and RaspberryOS is a Linux variant, albeit the HW can run Windows-for-IOT, too). Raspberries give much better programming environments for hobbyists, IMHO.
Check out  https://github.com/WouterJD/FortiusANT, for example, an awesome Python-based ANT+ project for indoor bike trainers.


3. find an ANT+ alternative (stick, etc.) (any suggestions?) - and use it with the Leonardo.
An ANT+ USB stick would be a simple solution, but then you need an USB-host for communication with that (and to power it). A Raspberry can be a USB host, but USB-host role is not common in the MCU world. I know that Ha Thach, the maintainer of the TinyUSB  project for MCU-s works on eventual USB-OTG support, but I do not know how mature is that. Anyway, you would need an MCU with true HW-support for USB, many cheaper MCU-s use software-only quirks to implement the USB-client role, if at all. 

Cujo has already linked in D52 modules from Garmin, but they cost almost as much as the nRF-52DK itself, AFAIK...

Anyway, an nRF-52DK is suitable as Arduino compatible microcontroller and it is ANT capable, indeed.

///G

Markus Rebbert

unread,
Feb 12, 2021, 9:40:18 AM2/12/21
to ant-api
Hi,

orr...@gmail.com schrieb am Freitag, 12. Februar 2021 um 14:23:34 UTC+1:
Hi,

Markus Rebbert <markus....@gmail.com> ezt írta (időpont: 2021. febr. 12., P, 13:54):
But you asked what I want to achieve in a very first step: I would like to control a fan depending on heart rate, (virtual) speed and temperature.
Let me guess: indoor bike training?

correct.

I think I now have three alternatives:
1. use the DK also as MCU (I had actually already started with that - but found the debugging a bit unusual)
I also use an MCU from the nRF-52 series. Particularly, I use the Adafruit nRF52804 Feather Express, but I started with the corresponding NordicSemi DK: the nRF52840-DK (which was an expensive overkill, too). The nRF52840-DK board has been fully integrated with the ArduinoIDE: the Adafruit-nRF52 Arduino-framework contains direct support for that.

Now, about your nRF-52DK: checkout this webpage: https://jimmywongiot.com/2020/09/07/arduino-ide-with-nrf52-dk-board/
It seems SparkFun has made the integration for you...

Right. I already did that - but I use PlatformIO instead - including the JLINK-Debugger-Support.
 
2. switch completely to RPI etc.
That has pros and cons. If battery operated is the goal, then I think the MCU alternative makes sense.

This is the reason why i wanted to use the MCU. 

3. find an ANT+ alternative (stick, etc.) (any suggestions?) - and use it with the Leonardo.
An ANT+ USB stick would be a simple solution, but then you need an USB-host for communication with that (and to power it). A Raspberry can be a USB host, but USB-host role is not common in the MCU world. I know that Ha Thach, the maintainer of the TinyUSB  project for MCU-s works on eventual USB-OTG support, but I do not know how mature is that. Anyway, you would need an MCU with true HW-support for USB, many cheaper MCU-s use software-only quirks to implement the USB-client role, if at all. 

Cujo has already linked in D52 modules from Garmin, but they cost almost as much as the nRF-52DK itself, AFAIK...

ah, i see.. have to think about that.
 
BR,
Markus

PS: Repost, because i lost the group in cc: in my 1st answer.

Gábor Ziegler

unread,
Feb 12, 2021, 10:34:21 AM2/12/21
to Markus Rebbert, ant-api
Hi,


Markus Rebbert <markus....@gmail.com> ezt írta (időpont: 2021. febr. 12., P, 15:40):
Hi,

orr...@gmail.com schrieb am Freitag, 12. Februar 2021 um 14:23:34 UTC+1:
Hi,

Markus Rebbert <markus....@gmail.com> ezt írta (időpont: 2021. febr. 12., P, 13:54):
But you asked what I want to achieve in a very first step: I would like to control a fan depending on heart rate, (virtual) speed and temperature.
Let me guess: indoor bike training?

correct.

I think I now have three alternatives:
1. use the DK also as MCU (I had actually already started with that - but found the debugging a bit unusual)
I also use an MCU from the nRF-52 series. Particularly, I use the Adafruit nRF52804 Feather Express, but I started with the corresponding NordicSemi DK: the nRF52840-DK (which was an expensive overkill, too). The nRF52840-DK board has been fully integrated with the ArduinoIDE: the Adafruit-nRF52 Arduino-framework contains direct support for that.

Now, about your nRF-52DK: checkout this webpage: https://jimmywongiot.com/2020/09/07/arduino-ide-with-nrf52-dk-board/
It seems SparkFun has made the integration for you...

Right. I already did that - but I use PlatformIO instead - including the JLINK-Debugger-Support.
 
2. switch completely to RPI etc.
That has pros and cons. If battery operated is the goal, then I think the MCU alternative makes sense.

This is the reason why i wanted to use the MCU. 
But an indoor bike trainer is inherently close to AC-power...

I do recommend to check out Fortius Ant, anyway, which is a project to bridge older, non-ANT+ FE-C compliant Tacx trainers to Zwift/TrainerRoad via ANT+. There you could get a lot of inspiration for ANT+ handling and maybe the integration of the fan-control to that would be easy.
Note, that the Rapsberry also has plenty of GPIO ports, so you can hook it to the fan-control Arduino, too.

///G
Reply all
Reply to author
Forward
0 new messages