C/C++ Code for Pico LTE

Hello all,
I am needing to develop a real-time application on a Raspberry Pi Pico that collects sensor data and sends this data via MQTT to a S3 bucket. I want to do this using the Sixfab Pico LTE. Because of the real-time constraints, it needs to be programmed in the C/C++ language and not micro-python. I am therefore looking for some example code (if anyone has done this before). If not, is there a way to get the micro-python Pico SDK source code of the examples so that I can translate it to C/C++

I’m not sure about calling MicroPython modules using C, but I know that you can call C modules in your MicroPython project. Maybe consider otherwise? Also, note that RP2040 has two CPU core. It would be nice to implement that as well! :slight_smile:

Using C modules in MicroPython project: C extension for MicroPython on Raspberry Pi Pico | PiCockpit | Monitor and Control your Raspberry Pi: free for up to 5 Pis!
Using MicroPython and C with Dual Core Discussion: Possible to run MicroPython on one core and C SDK code on the other? - Raspberry Pi Forums

1 Like

Would you be running into time constraints with a cellular connection that are slower than just a pure MicroPython solution?

No. In this application, I am needing to read A/D converters and serial data from another device at very deterministic times. The pico will consolidate this information and data and condense it down into a much smaller data set before sending out to the cellular network. The send out to the cellular network may be as little as once a day.

electricalgorithm,
Great suggestions. In the past, I have used both cores using C++ and had core1 be responsible for all hardware sensor reading (A/D’s) and serial data from another system. I suppose that I could run MicroPython on core0 and run straight C/C++ code on core 1 where I have hard timing constraints. Do you know of any examples where MicroPython calls a “C/C++” function?

I guess this link would help: MicroPython external C modules — MicroPython latest documentation

What you’d accomplish is to create your second core application, and expose a data streaming channel between the cores via any method you’d like. It can be a memory point, a flag, etc… Then, you need to create a C module/function that will be frozen into MicroPython while you’re re-building it and this module will return the data you want to share over cellular network. After reading the documentation carefully, I guess everything will be clear in your mind. I’m not sure on your implementation details, therefore, it is the only help I can gave.

A quick remainder, there are some tools available to quickly build and upload your MicroPython firmware into the PicoLTE, run some code, etc in here: https://github.com/sixfab/pico_lte_micropython-sdk/tree/pico-w-poc/tools There may be some changes needed since those are developed for another purposes. You can tweak them a bit, and it will save you a lot of time!

Looking forward to hear your experiences :slight_smile:

1 Like