MySensors v2: increase the range of the nRF24L01 (hardware, configuration) [Exclusive Guide]
simple appearance on paper (the screen!), the realization of an object connected to database nRF24L01 can quickly be complicated to the point if we want to pass data long distance (several tens of meter, see hundreds). After spending many hours testing different materials to find the right settings, I propose this article that summarizes a few tips for a successful project MySensors-nRF24L01 based.
warning. This article for no claims to meet all configurations. All advice given in this article are from empirical tests carried out with cheap materials from Asia accessible by everyone. The results can vary from one material to another, even if he is from the same manufacturer.
the tutorial for been written with the version 2.0 of the MySensors Bookstore, but it should also work with earlier versions (1.4, 1.5…).
- error of transmission (!) TSM:failure)
- choose which radio nRF24L01 module?
- choose what antenna?
- diet controlled 3V3, easier wiring and less (without) parasites
- Impossible to present a node after a upload
- other issues
when starting with a MySensors project, can quickly be confronted with many difficult to decipher messages. Here are the most common error message. Everything seems fine with begin
- TSM: RADIO: OK, the connection of the radio module is correct.
- TSP:MSG:SEND-255-255-255-255 s = 255, c = 3, t = 7, pt = 0, l = 0, sg = 0, ft = 0, st = bc:, great way to start
- ! TSM:FPAR:fail, and not
- ! TSM:failure, everything is floor!
TSM:INIT TSM:RADIO:OK TSM:FPAR TSP:MSG:SEND 255-255-255-255 s = 255, c = 3, t = 7, pt = 0, l = 0, sg = 0, ft = 0, st is bc: TSM:FPAR TSP:MSG:SEND 255-255-255-255 s = 255, c = 3, t = 7, pt = 0, l = 0, sg = 0, ft = 0, st = bc: TSM:FPAR TSP:MSG:SEND 255-255-255-255 s = 255, c = 3 t = 7, pt = 0, l = 0, sg = 0, ft = 0, st is bc: TSM:FPAR TSP:MSG:SEND 255-255-255-255 s = 255, c = 3, t = 7, pt = 0, l = 0, sg = 0, ft = 0, st = bc:! TSM:FPAR:FAIL! TSM:failure TSM:PDT
with this type of error, do not on the side of the wiring, this side everything is good. You have to look on the side of the transmission of data that can be affected by several factors:
- a bad power supply . NRF24L01 modules must be supplied with 3, 3V. The quality of the controller built into the Arduino Micro clones can be poor. Not only the power supply is unstable but in addition it can be disruptive. In this case, opt for an adapter. Go to the paragraph “use an adapter with regulated power supply.
- supply voltage is too low . This happens often for projects on battery. Increase the number of batteries, or use a more powerful LiPo battery. ‘Use an adapter with regulated power supply’ and mandatory in this case.
- a poor quality antenna. Antenna 2dBi can give disappointing results. Go to the paragraph ‘what antenna choose’
- Bookstore MySensors version 2 is able to assign an identifier when a new node appears. In practice, this mechanism is still problematic. The best is to continue to assign its own identifiers. Go to the paragraph “Connection problems after the update of a node”.
the choice of the module will depend on several criteria which the main:
- brought desired:
- indoors, a few dozen metres
- outdoor. The receiver (the gateway) will be inside the
- Configuration: in a House, outdoor, mixed
- wall: thickness, constitution (reinforced concrete doesn’t really help), number
- flat Terrain or relief
- Vegetation, fence
- electromagnetic disturbance: transformer, pumps…
- statement of data or actuator control simple (relay…). A low data rate will be enough
- Data Acquisition. Little data but a high frequency.
whatever the application, the best is to install a antenna high performance (at least 6dBi) on the gateway to ensure best reception of the data. Equipped with a SMA connector, it will replace the 2dBi antenna that team usually cheap Asian modules.
whatever the radio module employee nRF24L01 (standard or PA + LNA, long distance), it is preferable to use an adapter. Indeed, these modules includes a (step-down) voltage regulator which allows you to supply the radio in stably 3V3 module. The regulator of food is of better quality than those fitted to the Arduino (or Arduino Micro). If the power supply is unstable or creative disruption, the reception or the transmission of data packets can be severely disrupted.
you can easily find the adapters with the main dealers online:
hard to tell if any particular module radio (from Asia) will work. It is unclear by which they are made. Standard modules without external connector nRF24L01 work very well in general. These are rather the nRF24L01 + PA + LNA (long distance) modules which can be a problem, or the less the more often the antenna that does not give full satisfaction. In this case you can replace it with a higher power antenna. Already obtained excellent results with an antenna 6dBi (in indoor, outdoor, mixed).
|2-3 dBi||6 dBi, 75Ω, 28cm antenna, 1.5 m cable||15 dBi|
|uncertain results||advised||not yet tested|
|included with modules to external antenna||Banggood – about € 3.70||Banggood – € 7.35|
connection problems may occur after an update of the Arduino code. Here are some track to solve:
- assign an identifier to each node . Theoretically version 2 incorporates a system of automatic assignment of ID but in many cases, the allocation is very long or does not work. For the moment, I you Council therefore to attribute to each node a ID by adding this line at the beginning of the code (before the setup)
#define MY_NODE_ID xx
- if the problem persists, erase EEPROM in which MySensors stores internal variables. The program is located in the examples
- change antenna . The quality of the antennas of the cheap modules seems very variable. Replace the antenna can solve the problem.
can you mix short antennae and long distances?
YES, it works very well. Use instead an external (of at least 6 dBi) antenna for the gateway.
battery operation, choose what power?
depends on the used Arduino. If it runs from 3.3V, you can use 2 or 3 batteries AA (or AAA). In this case please use an adapter to not to exceed 3.3V and get a power supply. If the power is too low, you will have cuts of transmission or message! Dreaded TSM:failure! In this case choose a more powerful LiPo battery for example.