My Raspberry Pi 3 b+ is reading by Modbus the values of an irradiation sensor, processing all the data, showing it in a plot and showing some warnings (if the irradiation ramp is higher than 5%).
I am computing all this in a Python process but it takes too much time between every sample I can read from the sensor. I would like to run every task in a different thread:
Thread 1: Reads the data using Modbus and stores it in a vector/file or whatever
Thread 2: Reads the data from the vector/file and plots it
Thread 3: Reads the data from the vector/file and computes the ramp
I have read about two options:
- using threading library
- using multiprocessing package
First option the threads will use the same memory space, so it's gonna be more easy to share information between them. But I am not sure that every single thread will run in a different core of the Raspberry or they will share the same core and be syncroniced to access the core by the OS.
Second option the process won't share the space memory so the share of the information between process will be harder.I am also not sure that every single process will run in a different core of the Raspberry or they will share the same core and be syncroniced to access the core by the OS.
I also think that maybe Python is not the best option and this should be made with C.
Does anyone can give any clue about what to do? Or give me any literature I can check about it?
asyncio
or processing +asyncio
. I posted an answer with more detailed information.