I am trying to develop a system that will transmit data using an nrf24l01 module. There are modules available for Arduino for this (in C of course), and I found a couple of modules in Python but I couldn’t get them to compile in Zerynth because other libraries were missing.
Does anybody out there have a Python library for this device? Or should I be using the C language interface and use an Arduino Library? Some other way?..
In the Arduino library there is a folder called pyRF24 which I looked at but I couldn’t understand how to use it or if it could be imported into Zerynth somehow.
Is there a (preferably easy) way to use nrf24l01 chip from within zerynth?
the Nrf24l01 chip is not officially supported yet, anyway you could proceed following two paths depending on your level of expertise:
- develop a Python library from scratch taking the C ones and the component datasheet as reference. Here an example of a Zerynth Python library for a SPI component. This is the easiest way if you know Python;
- develop a Python wrapper of an existing C library (C, not C++). I would choose this one https://github.com/kehribar/nrf24L01_plus which has a few notes on porting.
Regarding the second path (probably the fastest and least error prone if you know what to do):
- the C API would be exposed in Python following our docs: https://docs.zerynth.com/latest/official/core.zerynth.stdlib/docs/clang.html;
- the porting layer would be completed using the Zerynth HAL. In this case you should take a look at vhalSpi and vhalPin (GPIO) functions;
- you can refer to this library as Zerynth porting example.
Let me know
Thanks for the reply Lorenzo. I’m pretty new to Python and I don’t really understand what happens under the hood in Zerynth, so making a C wrapper or using HAL all looks a bit scary for me. And anyway it’s just a personal project I’m doing for my own fun and amusement, so the KISS principle applies in spades. The first option, converting a C lib to Python sounds like it might be something I could have a look at. An awful lot of the work has already been done by this guy but there are lots of imports that don’t work in Zerynth, like spidev. but maybe the Zerynth spi library (i’m assuming there is one…) could be shoehorned in.