Does the RF24 library (from TMRh20) work on STM32F103?

Can someone help me port this library?
anistor
Posts: 4
Joined: Thu Jun 11, 2015 4:53 pm

Does the RF24 library (from TMRh20) work on STM32F103?

Post by anistor » Sat Jun 13, 2015 2:26 pm

Hi,

Did anyone try using this library https://github.com/TMRh20/RF24 (or its older version https://github.com/maniacbug/RF24) for nRF24L01 devices on the STM32F103?

It seems to compile without errors for this board but I do not have the device yet to actually test it. Also, by looking at the code I could not figure out if this library can work with the secondary SPI.

Thanks!
Adrian

User avatar
ahull
Posts: 1730
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: Does the RF24 library (from TMRh20) work on STM32F103?

Post by ahull » Sat Jun 13, 2015 7:46 pm

Good question, I have a couple of those devices somewhere, I might get a chance to check later in the week. If anybody else feels like beating me to it, feel free to do so.
- Andy Hull -

mrbwa1
Posts: 91
Joined: Mon Apr 27, 2015 3:36 pm
Location: Buhl, ID
Contact:

Re: Does the RF24 library (from TMRh20) work on STM32F103?

Post by mrbwa1 » Wed Jun 17, 2015 4:40 pm

It's on my list to look at as well. I'm actually more used to the RF24Mesh from TMRh20. It's really similar to the mysensors Arduino library. I would love to eventually get that one working, but it will probably take a while.

RF24Mesh and MySensors are nice because they take care of a lot of the setup stuff so you can just add and extend (MySensors is specific to adding sensors to various Home Automation solutions)

User avatar
RogerClark
Posts: 7691
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Does the RF24 library (from TMRh20) work on STM32F103?

Post by RogerClark » Mon Jul 06, 2015 9:46 pm

Do you mean, RF24L01 boards ?

If so, i have a few of these as well, but i never had much success with them, even on AVR.
The range seemed to be quite low, and would not go though many internal plasterboard walls.

pav2000
Posts: 3
Joined: Thu Aug 20, 2015 7:24 am
Location: Moscow, Russia

Re: Does the RF24 library (from TMRh20) work on STM32F103?

Post by pav2000 » Tue Sep 29, 2015 2:06 pm

I worked with this library (TMRh20s links: http://tmrh20.blogspot.ru/ and https://github.com/TMRh20). Using maple mini. At the same time, I made a small change in the code:

1. Fixes module RF24.cpp for maple mini was in the function void RF24 :: csn (bool mode)

Code: Select all

  #if! defined (SOFTSPI)
        _SPI.setBitOrder (MSBFIRST);
        _SPI.setDataMode (SPI_MODE0);
        _SPI.setClockDivider (SPI_CLOCK_DIV2); // Lower frequency !!!!!
    #endif
Replace the

Code: Select all

  #if! defined (SOFTSPI)
        _SPI.setBitOrder (MSBFIRST);
        _SPI.setDataMode (SPI_MODE0);
        _SPI.setClockDivider (SPI_CLOCK_DIV4); // Chip did not have time lowered the frequency doubled
      #endif

2. RF24_config.h insert rows that what is missing in stm32

Code: Select all

// --- STM32 ------
#define _BV (x) (1 & lt; & lt; (x))
#define printf_P printf
After that I was able to link the maple mini and arduino pro mini

stevech
Posts: 441
Joined: Thu Aug 27, 2015 6:32 am

Re: Does the RF24 library (from TMRh20) work on STM32F103?

Post by stevech » Wed Sep 30, 2015 12:13 am

Much better to use sub-GHz radios, narrowband, than 2.4GHz. Laws of physics plus the Nordic NRf based boards are, well, too cheap (low power, etc.)

Here's some links that might be new to you.

Radios - in the US, this is the main distributor - they do accommodate low quantity orders as a rule. HopeRF is a decent Asian board maker; they use radio chips from two US manufacturers.
http://anarduino.com/

This open source Arduino-compatible protocol stack is in C++. I and others have made a few simple changes to run it on STM32's.
At the bottom of this protocol stack are drivers for most of HopeRF's boards, and radio boards from other vendors too.
http://www.airspayce.com/mikem/arduino/RadioHead/

The RFM69HW module placed on an MCU board (H for high power) - I've used lots of these. No. America, use 902-928MHz band; in the EU and some other places, 868MHz. The 433MHz band exists in the US and elsewhere but the regulatory limits on transmitter duty cycle are severe.

As in any data radio, the range is governed by:
  • Channel width (narrow = better range)
  • Modulation rate (lower = better range, i.e., don't try 50-100Kbps and expect longest range)
  • FM Modulation index (for these mostly FM/GFSK radios)
  • Transmitter power
  • Antenna gain(s) from choice of antennas - omni-directional or directional depending on topology of the network.
  • Terrain and other non-line-of-sight impairments.
For a line of sight path, we can easily calculate the achievable range (as a link budget). I have a spreadsheet I use do to that,.
For non-line of sight, experience tells one what to expect. As well as trials.

A pair of RFM69HWs (100mW) with say 30Kbps or so, conservative modulation index, dangling-wire antennas, elevated to about 6 ft., line of sight, will give a reasonable error rate at 100m. In any link design, you want 10+ dB of fade margin (excess received signal strength).

Radiohead's stack includes an option for "reliable datagram" mode.. meaning there are CRC checks and retransmissions for error correction.
Other protocols include unreliable datagrams (like UDP), fixed routed network, and mesh-routed network.

User avatar
zoomx
Posts: 567
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: Does the RF24 library (from TMRh20) work on STM32F103?

Post by zoomx » Wed Sep 30, 2015 1:05 pm

RF24L01 cheap modules can be powered from the 3.3V Arduino line, but I read that it is better to add a cap for better performance.

There are models with more transmit power and external antenna, you need separate power like an ESP8266. They claim to have a long range, but not long as an xbee. If you use directive antennas you can reach a very long range.

I have RF24L01 cheap modules and subGHz radio modules but never tested them for long distance.

User avatar
mrburnette
Posts: 2226
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Does the RF24 library (from TMRh20) work on STM32F103?

Post by mrburnette » Wed Sep 30, 2015 1:23 pm

zoomx wrote: <...>
I have RF24L01 cheap modules and subGHz radio modules but never tested them for long distance.
I have never messed (although I have some in the parts bin) with the RF24L01, but I did do an article on the 12B and was pleasantly surprised.
https://www.hackster.io/rayburne/hoperf-springs-eternal
With a 1/4 wave antenna on the remote and a full-wave whip on the receiver, I can take the remote anywhere in my house and have great signal on the PC tied to the base unit.
Just as a note: I'm getting pretty good all-house signal with the ESP8266 transmitting the GPS time stream, so my guess is that the RF24L01 would work acceptably, too: https://www.hackster.io/rayburne/tardis ... server-gps

Note: I just returned from a week stay with my daughter, grandson, and son-in-law in Alexandria, VA. They own an old home from the 1860's and the 2.4G/5G WiFi is in the central part of the house, in the basement. Both signals are available directly above in the dining room, but the 5GHz is completely attenuated upstairs due to the metal lath in the plaster walls... like a Faraday shield. The 2.4GHz is significantly degraded. My guess is that most older homes that have not had the walls remodeled and replaced with gypsum board will suffer similar fate.


Ray

mrbwa1
Posts: 91
Joined: Mon Apr 27, 2015 3:36 pm
Location: Buhl, ID
Contact:

Re: Does the RF24 library (from TMRh20) work on STM32F103?

Post by mrbwa1 » Wed Sep 30, 2015 4:37 pm

Ray,

thanks for the painful flashback...

when we remodeled last year, we found the bathroom was Drywall over plaster over metal lathe over more plaster (almost 1" thick). It took a sawzall with a Diablo blade to get most of it out and many of the corners I had to attack with an angle grander because they used extra metal lathe as reinforcement.

As for the RF-24 library, I'm still working on getting my STM32s sorted and need to look at the library. I'm sure it'll work with a few changes as others have gotten the NRF24's working. I really want the mesh mode going because it's the easiest for my to work with.

I haven't really had distance issues within the house with the on-PCB antennal. There is a p version wit PA+LNA and an external antenna (http://www.elecfreaks.com/wiki/index.ph ... PA_and_LNA). They are rated at 1000m @ 250 kbps in open air with a 2db antenna.

User avatar
primateio
Posts: 61
Joined: Sun Sep 20, 2015 11:17 pm
Location: Midland, Tx
Contact:

Re: Does the RF24 library (from TMRh20) work on STM32F103?

Post by primateio » Fri Nov 13, 2015 2:49 pm

I ported over the RF24 library from https://github.com/maniacbug/RF24 and got it working for the most part. I had to make some crude hacks in it for the print functions because I couldn't get them to actually work otherwise. I have it talking to an ATmega328p using the same library. I initially tried the TMRh20 library, but couldn't get it working with my old code, it has some breaking changes from the maniacbug one.

The ping pair sketches work great. The only thing that is weird is, on the AVR chips, you can leave the sender on and it works fine. On my port, you have to call stopListening() before sending a packet and call startListening() after sending, even if you are not listening for anything. This may not always be required, but in my program, I am receiving an acknowledgement packet with data, and that is all I have tested other than the examples which do this anyway. I think it is something with the SPI ending a transaction or something, but I have not looked into it much. Otherwise, it hang up. It does not do this behavior on AVR.

I can post my modified version on github if you want. I am not planning on fixing the bug soon because I decided to go with a different sub ghz radio from hope RF because I need greater distance and more wall penetration for my project.

Post Reply