File Exchange

image thumbnail

RF24 Simulink Library for Arduino and Raspberry Pi

version 1.0.3.0 (617 KB) by Anders Sollander
A Simulink library for communicating via the RF24 Mesh library

7 Downloads

Updated 14 Apr 2017

View License

This is a small library that lets users communicate with RF24 chips on Raspberry Pi and Arduino boards.
This library relies on the RF24Mesh library, and has S-functions that interact with the classes there.
Install it by running the function rf24libs_installer, optionally with the argument true if you don't want to save the path.
The library contains blocks for configuring a network node, and for sending and receiving data. The RF24 Mesh library is built to have one master node, and a self-organizing mesh of slave nodes communicating with the master node (and potentially each other).
There are also two example files, one for a Raspberry Pi and one for an Arduino. In this example, the Arduino read measurement data from a temperature sensor and sends it to the master (RPi). This in turn, receives the data and posts it to ThingSpeak (https://thingspeak.com/).
Users will have to use support packages for Arduino and Raspberry Pi, and also configure the models to comply with their hardware and ThingSpeak settings.
This work was only possible thanks to the great work of https://github.com/TMRh20, providing the libraries needed to work with the RF24 chips.
There is also an article about using this on the ThingSpeak blog: http://community.thingspeak.com/tutorials/matlab/building-a-dynamic-and-self-organizing-network-of-devices/.

Cite As

Anders Sollander (2021). RF24 Simulink Library for Arduino and Raspberry Pi (https://www.mathworks.com/matlabcentral/fileexchange/59127-rf24-simulink-library-for-arduino-and-raspberry-pi), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (18)

I have the same problem as SRance. I cannot make it work since it always shows this error "fatal error: RF24Mesh/RF24Mesh.h: No such file or directory #include "RF24Mesh/RF24Mesh.h". I have tried every of the alternatives you commented but I guess I will give up on this too for the time being. If you update it, then I would gladly try it again.

SRance

I've come to the conclusion that there is something fundamentally wrong with the #include when building (at least with my PC). By defining the full path to the files the compiler can find the .h files however this has required me to modify every #include to define a full directory even with the TMRh20 libraries, however, there are still issues errors that prevent the build associated with the code itself so I have therefore given up with this toolbox for the time being.

SRance

Hi Anders,
I think I've now found the issue referenced in the "docs" folder - "Using-C++-On-Arduino.pdf". In this you reference setting up the model for C++ code generation but needing the Embedded Coder license, as a Home license user, I cannot gain access to this.
Are there any work arounds that will allow the model to be set-up for C++ code generation without the licence (using <token Name="_SUPPORTS_CPP_CODEGEN_" Value="true"/> in the target requires coder products) or intergrate C++ libraries when generating a build in C?
Thanks, Shaun

SRance

Hi Anders,

They were libraries installed from the Arduino IDE directly, rather than fro Git and placed in the library folder so function in Arduino. I put this library path in the "getArduinoLibraryDir", or rather it points at the preferences file that has the sketchbook root folder with the path "C:\Users\Shaun\AppData\Local\Arduino15" to seek the preferences file, which has "sketchbook.path=C:\Users\Shaun\Documents\Arduino" which then has the usual three folders such as "libraries", and running alone gives the output "C:\Users\Shaun\Documents\Arduino\libraries" below which I have all the require RF24 folders.

Shaun

Anders Sollander

Hi Shaun,

do you have the RF24 libraries installed in Arduino too, i.e. did you choose them there as libraries/plugins? The getArduinoLibraryDir is handling exactly this, so that may fix your build issues.

Anders

SRance

Hi Anders,

Understand the issue/lack of time to dedicate to it. I've given some time to have a look at the source code files and did notice some issues.

I've found in the folder, under "tools" then "+rf24" there is a file called "getArduinoLibraryDir.m" and in "+rf24" and "+patch" there is a file called "fixRTOneStep.m" with paths explicitly typed.
For these I updated the paths noted for the arduino library (from the preferences file) and schedulers to allow the Arduino libraries to be correctly referenced and schedulers copied.

However despite this I still have the same issue - I have run the installer a few times since, restarted my computer to make sure changes have taken effect and run the indiviudual tool functions to check their outputs (which seem correct now). I do also have all the libraries you've mentioned below in my Arduino library directory with the right naming conversion, i.e. libraries\RF24Mesh\RF24Mesh.h.

Do you recall any other files I need to have a look at besides these two?
You've also mentioned the linker which I'm not sure I've looked at yet but unsure where this might be.

Thanks,

Shaun

Anders Sollander

Hi Shaun,

I realize the documentation is really lacking in this post, and I currently don't have the bandwidth to work on that. Apologies for that.

You will need to have the RF24 files installed on your computer, and they can be retrieved from the github account mentioned above, https://github.com/TMRh20. You will need, if memory serves me right, RF24, RF24Network and RF24Mesh. They have to be put where they can be found by the compiler, using the relative paths referred to in the source code. E.g., if /usr/local/include is on your normal search path, you could put them in /usr/local/include/RF24Mesh/RF24Mesh.h, etc. The files for the linker will have to be handled similarly.

I hope this helps,
Anders

SRance

Hi Anders,

That was the issue - I forgot to run the installer.

However I now have a fatal error in compilation: fatal error: RF24Mesh/RF24Mesh.h: No such file or directory #include "RF24Mesh/RF24Mesh.h"

I have the additional hardware support packages though cannot find as of yet the RF24Mesh files - is this needed to be downloaded from the referenced link and put in a specific folder?
This is similar to some of the earlier issues mentioned in the comments - I won't put the entire model error output as it is far to long however the key is the missing reference when building the model .c file.

Thanks,

Shaun

Anders Sollander

Hi SRance,
did you run the rf24libs_installer first? That function should build the S-functions, after which they will exist. The functions with the _cb suffix are not S-functions, but CallbackHandlers for the Simulink blocks, i.e. they are helper functions for the masks there.

Hope this helps, best regards,
Anders

SRance

Hi,

I am having issues in the build phase noting and "Error in S-Function" for Arduino mesh init and read.
Looking through the download the S-Function code names have "_cb" at the end whilst the src (.cpp) and tlc_c (.tlc) files do not.

- S-Function 'sf_rf24mesh_init' does not exist
- S-Function 'sf_rf24mesh_read' does not exist

I suspect a naming issue though as this is direct from the download I am a little concerned.

mario gamal

Can I use this library to make Arduino Uno a master and Arduino Megas as nodes? or One Arduino Mega master and other Arduino Megas as nodes?

ABDEL-RAHMAN MRYYAN

Hi
is try all solutions to solve this err
'Failed to generate all binary outputs'.
i rename the path without spaces and still the same err
i hope if there is any solution .

Mohamed Benhammou

Hello,

Could you provide examples?
As a very simple example which allows you to light an LED (receiver side) if you press a button (transmitter side) or even control a servomotor or a motor from a potentiometer.

thank you so much

amina EL ATTAOUI

amina EL ATTAOUI

hi, tkank you for this library. my problem i use this one with arduino support package, i wanna implement the programme in the node, but the diagnostic wiewer give thie err
C:\Users\ATTAOUI\Downloads\RF24SLLib_1.0.3\SendDHT_ert_rtw>echo The make command returned an error of 2
The make command returned an error of 2

C:\Users\ATTAOUI\Downloads\RF24SLLib_1.0.3\SendDHT_ert_rtw>An_error_occurred_during_the_call_to_make
'An_error_occurred_during_the_call_to_make' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
### Creating HTML report file SendDHT_codegen_rpt.html
### Build procedure for model: 'SendDHT' aborted due to an error.
Error(s) encountered while building "SendDHT":
### Failed to generate all binary outputs.
thank you for help

Anders Sollander

Could you please add the output of your compiler to this thread, as well as a hint to where you've put your RF24Mesh libraries. Just one compiler call (not for whole make process) with the error message should suffice.

Tobias Buchberger

I have the same problem. Do you already have the solution?

Elishah Jordan

Looks promising. Unfortunately, I'm getting the following error: "fatal error: RF24Mesh/RF24Mesh.h: No such file or directory
#include "RF24Mesh/RF24Mesh.h" "

Downloaded the git repository as well, and added the .h file mentioned above to my path, still no luck. Any advice?

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Communities
More Files in the  ThingSpeak Community

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

RF24SLLib_1.0.3/blocks/

RF24SLLib_1.0.3/demos/