Hello everyone,
I've recently started using Micropython for a small home project, where I'm using an adafruit esp32 board to record analogue data. Currently, I deployed the code on the board and save the data to a txt file, from which I can import my readings into my main python project. Looking at some pyboard projects I saw that solutions exists (https://github.com/dhylands/json-ipc) to establish communication channels between a micropython board and a python project. However, my board is not a pyboard and so I'm confused whether any of these would be applicable to me. What I would like to understand is whether I can integrate a micropython code within a standard python project? In this case I could call a function on the esp32 board and also receive data real time (the latter through serial communication potentially). This might be a very simple problem for someone with a hardware background, but I believe I lack the relevant experiences.
An additional constraint is that I need to sample in the kHz range, which might be relevant concerning the communication channel used.
I would appreciate your help with this.
Best regards,
L.22
Integrating micropython into python project
Re: Integrating micropython into python project
Hi,
Yes, you should definitely be able to use dhylands' json-ipc library for this. I'm not sure if you can use the same UART as the REPL though on ESP32?
But ESP32 has WiFi, so perhaps that's a better option? In which case you can adapt the socket example (echo_server.py) to run on the ESP32.
However, it would be worth looking at https://github.com/peterhinch/micropython-iot - which provides a reliable way to send and receive messages to/from your MicroPython device over WiFi. It's not quite function calls, but it's conceptually the same thing - when you receive a certain message, your firmware can start/stop sampling etc.
Yes, you should definitely be able to use dhylands' json-ipc library for this. I'm not sure if you can use the same UART as the REPL though on ESP32?
But ESP32 has WiFi, so perhaps that's a better option? In which case you can adapt the socket example (echo_server.py) to run on the ESP32.
However, it would be worth looking at https://github.com/peterhinch/micropython-iot - which provides a reliable way to send and receive messages to/from your MicroPython device over WiFi. It's not quite function calls, but it's conceptually the same thing - when you receive a certain message, your firmware can start/stop sampling etc.
Re: Integrating micropython into python project
Thanks Jimmo. For now I've managed to grab the txt file using rshell. However, this process is very slow. Using your suggestion, what sampling speeds do you think I could achieve? Could I theoretically achieve real time communication over wifi without losing too many data points?
Thanks in advance.
L.22
Thanks in advance.
L.22