Timing system for Alpine skiing based on Arduino. Radio channel on modules nRF24L01+

The radio channel for communication of single board microcomputers Arduino is organized using radio modules. I’ve considered that like in common networks, an address is assigned to a microcomputer at which at a certain frequency another microcomputer, of course within radio visibility, can find it. Then these computers communicate with each other using some protocol, which you don’t need to understand. As a result, data is exchanged using simple, high-level commands.

The module based on the nRF24L01 + chip, rather old (unchanged for more than five years), is not the best by modern standards, but quite popular. Judging by the references in the reviews, at the hardware and software level, you can organize a “grid” of 6 microcomputers, which can (when buying a board with noise reduction and an amplifier) ​​communicate up to 1 km away. This information seemed to me enough for the project “Timing for skiing on Arduino”, since I need to link the 3 microcomputers (Start, Finish and base unit) and in the future another one (remote display), that is, less than six. And at a distance of 500 meters, that is less than a kilometer.

In this article I share the experience of implementation. Unfortunately, all was not very easy.

Microcircuit nRF24L01+

We have to start with the chip (chip) nRF24L01+. Manufacturer Nordic Semicoductor (Norway).  On the website you can download a description (datasheet), very detailed, on 78 pages, but for specialists. True, over the last couple of weeks, the nRF24L01 + module has moved to the section on the site: nRF24 Series (legacy), which mean “old version” with remark “Not recommended for new designs”. And the pages on which I recently read about the difference between the version with the “plus” at the end from the previous one, which was made in the period “10 years ago – five years ago”, were removed from the site.

It can be concluded that the nRF24L01 + microcircuits are no longer produced. But if the modules on these microcircuits do not disappear with Ali-Express within six months, you will have to make another conclusion: the nRF24L01+ microcircuits have nothing to do with Nordic Semiconductor, and perhaps already 🙂

On pages 66-77 of the description of the nRF24L01+ chip, as examples, the recommended scheme of the finished module is presented and several drawings of printed circuit boards are given. For example:

In general, I got the impression that there is a beautiful, time-tested (10 years in total for versions with plus and no plus) nRF24L01+ microcircuit, which is guaranteed by the manufacturer Nordic Semiconductor and is documented in detail. And there are implementations in the form of modules, for which Nordic Semiconductor is certainly not responsible for the work. The simplest implementation is to simply take the PCB drawing presented as an example. Unfortunately, this is unlikely to work. To organize data exchange, it is necessary to connect (according to the example scheme) 16 MHz quartz to the chip. This is radio frequency. And at the output, the chip delivers 2.4 GHz carrier frequency. This is already a microwave, close to the border of the centimeter range. There is a big risk that if “just” diluting the board, there will be mutual pickups. Therefore, it is advisable to follow the specific advice of the Internet guru when buying modules from a specific manufacturer (meaning from those presented on Ali-Express). And of course look at the number of orders and positive feedback. Of course I did 🙂 But I didn’t avoid problems. And to the “datashit” it did not come from a good life 🙂 And this, too, as it turned out, is typical 🙂

About the choice of the module and in general 🙂

In general, choosing a module for a radio channel was not an easy task. To begin with, I am not an expert, but according to my ideas, the frequency for communication over a distance of about a kilometer should be, for example, from the allowed range of 433 MHz. A 2.4 GHz is for a short range, as implemented in Wi-Fi and Bluetooth. On 433 MHz I did not find a reliable solution. That is, I saw modules on Ali, read reviews, then I looked for real experience for projects on Arduino and refused 🙂

We’ll have to dwell on the essence of the Arduino platform. Of course, radio modules (and almost all other modules) are not made for Arduino, but “by themselves”. Arduino is a platform that combines a certain type of single-board computers (that is, a microprocessor with a “strapping”), a programming environment and Internet experience gained in the form of libraries, examples and forums. Arduino is not the only such platform, different in that it has a fairly simple “entrance”.

Therefore, for example, to implement a radio channel, it is necessary that the following coincide:

  1. The module must be hardware compatible with Arduino. For example, the nRF24L01+ chip (and the module based on it) is controlled by the protocol and the “bus” SPI (Serial Peripheral Interface). From Wikipedia: a full-duplex serial synchronous data transfer standard designed to provide simple, low-cost, high-speed pairing of microcontrollers and peripherals. SPI is also sometimes called a four-wire (four-wire) interface). Arduino has specially dedicated four wires on which this protocol is implemented.
  2. For the module should be a library. Where does it come from? Suppose there is a specialist who is able to master the description of the chip and / or module based on it (datasheet). In addition, the specialist is oriented in the protocols implemented in both Arduino and the module, that is, it can provide reliable pairing of modules at a low (hardware-software) level. And the most important. For some reason, this specialist translates all this from the “bird language” to the Arduino library, free of charge in a burst of enthusiasm, so that procedures in the Arduino programming language (C ++) appear. Unfortunately, the likelihood of such a coincidence is small, since the described specialist is a professional (or the one that is about to become), and the environment of Arudino is for amateurs, there is nothing for the professional to do here. In general, in “real” computers this process is called “driver creation”. Drivers are supplied in the required order by the manufacturer of the module. But in the Arduino environment it is not.
  3. There should be examples of the implementation of the module and the library. For one module there can be several different libraries. But most importantly, real experience should be gained on the Internet. Otherwise, the amateur may not have enough qualifications.

For modules on 433 MHz, sections 1-3 did not work out for me. But the positive information about the modules based on the nRF24L01+ chip fell out.
The final choice made after watching the video from AlexGyver “Arduino and nRF24L01. Wiring and wireless control by Arduino” (russian language).

Connecting and configuring nRF24L01 to Arduino (wireless module) – YouTube from AlexGyver. In this screenshot, the top board is a radio module in the version with two amplifiers — transmit and receive; – Arduino Nano. The right two wires are power, the left wires are signals. Wires are soldered and made as short as possible.

The video demonstrates reliable data transfer over a distance of more than a kilometer. In the description of the video there is a link to the library (with examples). I ordered the modules from the seller that AlexGyver recommended, although the auxiliary module for power supply 3.3 V was not there, I had to order elsewhere (and this, as it turned out later, was very bad).

After I ordered the modules, I got a link to the project, which one-in-one corresponds to the theme: “Timing for skiing on Arduino”: “OMEGA — Автоматизация подсчета времени на спортивных мероприятиях” (in russian) from Sergey Melnikov. It uses exactly the same radio modules that work normally.

Omega from Sergey Melnikov

This strengthened confidence in the right choice 🙂


On the modules that came (with difficulty), you can see the nRF24L01+ microcircuit:

Usually, the operation and correctness of the module connection is checked by an example “listen air” from the library. The module in the receiver mode scans the frequency channels and shows on which other devices work and which ones are clean. If the picture is exactly that, the module is considered good. If all channels are clean, it may be suspicious that the module does not receive anything. This test went great. And almost all the other tests that are so well shown in the commercials, did not pass at all. These tests are based on the operation of the modules in the transmitter-receiver switching mode (such as ping-pong). The tests did not pass, because the modules did not switch to the transmitter mode.

I had to plunge into a 100-page forum with a scary name: “nRF24L01+ : побеждаем модуль” (“nRF24L01+ : defeating the module”, in russian). In parallel, I had to type in information in order to more or less understand what they were writing about. For example, I used datasheet on the Nordic Semiconductor website to understand how module addressing is organized, since the term Data Pipe in the forum slang was referred to as “pipe”, and the explanations of what it meant were stupor.

The datasheet is pretty clear that the main mode of the chip is the receiver. Switching to the transmitter mode should take place in the form of a specific ritual, which includes, in particular, feeding the corresponding leg of a chip with high-level with a duration of at least 10 μs.

(The TX mode is an active mode for transmitting packets. To enter this mode, the nRF24L01+ must have the PWR_UP bit set high, PRIM_RX bit set low, a payload in the TX FIFO and a high pulse on the CE for more than 10µs).

There were doubts that the ritual was properly done in the library, so it can work, maybe not. The main experience on the Internet is presented by working with the library “RF24”. I tried on the “old” library “Mirf”, the same thing. Before that, of course, I walked through the hardware, as advised: I soldered all the wires, tried to hang capacitors, and then I went round and round 🙂

Judging by the forum, such walking in the circle are not uncommon. Sometimes the result is good, and sometimes not. The peculiarity is that the radio is not a digits. Therefore, it happens that there are no states “it works – it doesn’t work”. Sometimes, in some examples, “ping-pongs” were held, albeit with long delays. Attempts to cling to it in general did not lead to stable work.

Stable operation of modules

There was good news too. In the AlexGyver examples there is an option (it is not in the standard library) a simple transiver or receiver modes (without “ping-pong”). That is, without switching for confirmations of received information, but simply one module sends, the second accepts. This example from the very beginning worked much better than others. It is true a little differently on the 5 modules that came. At the receive, they all worked the same way, and the transmite one is the best, then the other two are worse and two more are really bad. In general, the suspicion of improperly working modules remains.

Just in case, I ordered the modules in a different design, and the power adapters for them are also in a different design. To make sure that the modules are manufactured in another place, so they will be different.
I like this construct more, because there everything is shielded, as I think it should be at such frequencies. Range promise 2 km 🙂

Unfulfilled (so far) radio traffic logic

As already mentioned, the “low level” modules allow building a computer network with a star topology.
More down to earth, it is possible to combine 6 modules at a low level. These 6 modules themselves support the ping-pong connection among themselves, switching when necessary to the transmitter or receiver modes, delivering the packets several times, until confirmation is received, etc. Probably further such cells can be networked, but in this direction did not dig. In general, 6 (or less, if desired) modules are “tapped” when they need to. At the next level “up” the roles of the modules are not the same. There is a center (number 0) and a primary assistant (number 1), who easily communicate via two-way communication. The rest of the 4th are as assistants, their purpose is to transfer information “to the center”. In this case, the number zero can hear all the other five simultaneously. Interestingly, as a reverse packet for “tapping”, you can choose what to send (without switching the module at the top level to the transmitter mode).

If to transfere these roles into “timekeeping for skiing”, it turned out something like this. Number zero is the base unit. Number one – Start, number 2 – Finish. Thus, the base unit receives response times from Start and Finish, supports timing of up to 3 participants on the track (for more information, see: Timing system for Alpine ski based on Arduino. Logic), and sends the information “You can start” and “Finish ready” to the Start. As confirmations of receiving information, the base unit sends the time of its internal timer to the Start and Finish. At this time, taking into account the measurement of the delivery time, the Start and Finish constantly synchronizes their watches and transfer to the base unit the fact time of the actuation which is already reduced to the time of the base unit.

Unfortunately, I had to refuse such an approach, but I will leave it here, maybe I will return on new modules. On my current modules, the confirmation usually did not work at all. And when it worked, the time between delivery and receipt of confirmation was “walking”, and the values ​​were 5 times larger than those shown in the examples from AlexGyver. Since this is not a “digits”, but radio engineering, there may be a lot of reasons for this (besides my incompetence), the main reason has not yet been found. But the time allotted for the quest came out 🙂 Yes, and I need the result with reliability, otherwise, instead of skiing, you will become a “slave of omega” 🙂

The logic of the radio channel

While new modules are coming, I work with what is. That is, if the main mode of operation does not go, with the control of the delivery of each packet (ping-pong is organized for this), and the receiver-transmitter mode works, then the radio channel logic will have to be reworked.

The base (main) unit has transfered to the Start. At the Start, the system get the usual (not radio) signals from the starting gate, the logic is processed to measure the results of the participants (again, for more information here: Timing system for Alpine ski based on Arduino. Logic). The radio module of the unit Start is constantly configured as receiver.

The Finish unit is constantly configured to transmit data packets with two fields: the current internal time of the microcomputer (in milliseconds) and the fact that the finishing beam intersects (yes or no).

When crossing the finish line, the time is recorded and, together with the fact “yes”, is transmitted to the Start, say 10 times (adjusted in the program). I hope that at least one such package will come. Since there is no evidence, it’s probably impossible to find out about it 🙁

The time between transmissions of packets of information (yet) set in half a second. That is, if the finish is not crossed, then every half-second Start receive from the Finish package from the current time of the microcomputer’s internal timer and the fact that “no one has passed yet”.

The fact of crossing the finish line is processed through the “interrupt”. On Arduino Nano there are two “legs”, on each of which you can “hang” a button, pressing on which is processed immediately, regardless of the course of the program.

Check the connection “Start – Finish”

The Start unit in its cycle of constantly polling the wicket button and analyzing what is happening on the course, refers to the receiver’s buffer. If nothing in this buffer within choosen timeout, then we can conclude that there is no connection with the finish. This is the first task of the Start unit. If there is no connection, light the corresponding bulb.

Synchronization of clocks in Start and Finish units

The second task is the synchronization of start and finish timers. The Start unit subtracts the incoming current time of the finishing block from its own, and the resulting difference averages, say, from the 10 passed measurements. By the way, the internal timers (two specific Arduinos do not coincide noticeably, the measured (in milliseconds) difference “floats” over time in one direction, that is, the “milliseconds” are different for different Arduinos 🙂 🙂 Just in case, I picked up the rate of change of the timer speed in the Finish unit, so there is no drift within an accuracy of a millisecond.

Finish processing

The third task is when the “finish crossed” fact comes to Start unit (the first of the packages with such identical information), instead of comparing it to current time, Start need to transfer the finish time in the internal time of Start unit, taking into account the average difference that was measure before. And put this result to further processing. Such difficulties are needed because it is not known exactly which package will be received and how much it will be delivered. And indeed, in the “digits” is transmitted not a signal, so it is better to try to minimize the impact of the delivery time.

In the “laboratory” conditions, the first packet stably passes and the time of crossing the finish calculated with such tricks coincides with the fact that the packet was accepted by the starting module to the nearest millisecond. And 10 packets with the same information about the time of crossing the finish line are transmitted to the start in about 45 milliseconds (5 hundredths of a second).

Transfer of the result to the remote time board

Then, the Start unit needs to take a pause, turn off the “You can start” light bulb and do all the necessary actions to switch to the “only transmitter” mode. Then, transmit information about the result of passing the distance to the “Scoreboard” unit, which operates continuously in the receiver mode. And then you need to quietly switch Start unit back to receive mode.

Timing system for Alpine skiing based on Arduino nRF24L01+
Start, Time board, Finish

nRF24L01+ and power supply of 3.3 volts

added later

As mentioned above, in my case, there were problems when switching modules to transmitter mode. According to the datasheet, the microchip itself consumes in the mode of reception and transmission approximately equally and slightly. But this does not apply to our case, since the board contain a powerful antenna amplifier. Apparently due to the fact that the module switches to transmitter mode “in pulse”, a large power drawdown occurs.

This became especially noticeable when new radio modules (in another design) arrived. Judging by the description, we can conclude that the antenna amplifier in these modules is more powerful. When replacing old modules with new ones (the connector and wiring are the same, so the old module is removed from the adapter and the new one is installed) in the transmitter mode the modules did not work at all. But after tune the maximum-to-minimum transmission power parameter in the program, it worked well. In general, the suspicion to the adapters ordered from the “non-recommended” AlexGyver supplier sharply increased.

The network has an impressive video from New Zealand, in which the connection is shown on such modules and with a directional wi-fi antenna at a distance of 31 km (in line of sight). The transmitter was installed on a hill not far from Oakland, and the receiver was moved by car, with stops for measurements.

Here is a screenshot from the video of the same author, in which he talks about the hardware. The radio module was powered without a special adapter, just a “DC-DC” from 5 to 3.3 volts, but with “good” capacitors. Ordered, of course, the same on Ali, but alas, I had to deal with the fact that the consistent solution of problems can stretch for months (long delivery from Ali Express to Russia).

Quite often in the network recommends paralleling the power supply of 3.3 volts on the radio module with a pair of capacitors (0.1 – 0.5 µF ceramic + 10 – 100 µF, for example, electrolytic, the exact value is different in different sources of information, therefore the range is indicated). But at the same time, many sources of information emphasize that if you use a special power adapter for a radio module or a good separate 3.3 V module, then capacitors are not required. I like this approach more because I would like to stay within the framework of the “radio constructor”.

In general, I had to “parallel” orders with Ali to solve the problem of “power 3.3 volts” and arrange a race, which order will come first. Ordered lowering modules as in the screenshot above, and others with large electrolytic capacitors. And before that I ordered the power adapters of the radio module with visually large capacitors (shown above).

Ordered DC-DC step down modules

For a cardinal solution, I ordered the Arduino Nano option from RobotDyn with a powerful 3.3 power supply on board.

Arduino Nano RobotDyn, upper and from down view

Well, and the capacitors, the bag of ceramics and the bag of electrolytic ones, were ordered much earlier, but they still not came. A pair of “Soviet” capacitors, which was found in the house (ceramics at 1 µF and electrolyte at 10 µF) improved something, but not drastically, “on one step”.

The first came Arduino Nano from RobotDyn and closed the problem. About these Arduino there is a separate note. The radio channel works very well. True, I did not return to the starting point (with ping-pong approach). By this time, groundwork was made in the radio settings, how to load the transmitter to a minimum, so that on the previous “regular” Arduino worked at maximum power, but not stable, there were many “missing packets”. These settings and left. Now it works stably, so can test for distance.

Activation of radio channel without ping-pong, library “RF24”. Start Unit at upper picture, Finish at down picture

It remains to deal with another small problem on power supply. It seems that the “loading impulse” of the transmitter extinguish to the “boost” module (from the battery voltage to the “onboard” 5.0 volts). This is expressed in the fact that when powered by USB radio modules work fine, and if the same 5 volts comes from the battery, then they do not work. But if by the adjusting resistor to lower the on-board voltage to 4.7 volts, then everything works fine. Passing power through the Vin Arduino does not change anything. There is a separate note about the Arduino power supply, so here I’ll just note that is also going DC-DC boost with large capacitors.

Here are collected all the notes on the theme “Timing for skiing on Arduino”.

Vadim Nikitin DigInfo.ruVadim Nikitin




to top of page

Leave a Reply

Your email address will not be published. Required fields are marked *