Jacob26
Posts: 2
Joined: Tue Aug 14, 2018 7:35 am

Reading a few sensors in the same time (Python)

Tue Aug 14, 2018 8:01 am

I have a few sensors connected to RPI 3:
-Adafruit Ultimate GPS (UART->USB)
-Adafruit BNO055 (UART->USB)
- Wind sensor (BLE)
- some sensors connected to ADC (I2C)

I have to read data from all this sensors with specific periods and save data to separate CSV files:
-GPS (2 Hz) [Time, Latitude, Longitude]
-BNO055 (100 or 400 Hz) [Time, Heading, Pitch, Roll]
- Wind sensor (1, 4 or 8 Hz) [Time, Wind speed, Wind direction]
- sensors from ADC (I don't know yet) [Time,........]

What is the best solution for this? New threads for all sensors? Every sensor in separate Python script?
-

hippy
Posts: 3919
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Reading a few sensors in the same time (Python)

Tue Aug 14, 2018 3:40 pm

Jacob26 wrote:
Tue Aug 14, 2018 8:01 am
What is the best solution for this? New threads for all sensors? Every sensor in separate Python script?
I would have thought threads but you could write each as separate programs. Then write another master program which can import those programs and run them as threads of itself. Then you have both, can test to see which works best, which you prefer.

User avatar
mikronauts
Posts: 2643
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Reading a few sensors in the same time (Python)

Tue Aug 14, 2018 4:44 pm

You could connect one f the adafruit uart based sensors to the pi uart

As for the i2c adc you will have to poll its inputs one at a time, and you sample rate will be limited by i2c speeds... so don't expect thousands of samples per second for multiple channels
Jacob26 wrote:
Tue Aug 14, 2018 8:01 am
I have a few sensors connected to RPI 3:
-Adafruit Ultimate GPS (UART->USB)
-Adafruit BNO055 (UART->USB)
- Wind sensor (BLE)
- some sensors connected to ADC (I2C)

I have to read data from all this sensors with specific periods and save data to separate CSV files:
-GPS (2 Hz) [Time, Latitude, Longitude]
-BNO055 (100 or 400 Hz) [Time, Heading, Pitch, Roll]
- Wind sensor (1, 4 or 8 Hz) [Time, Wind speed, Wind direction]
- sensors from ADC (I don't know yet) [Time,........]

What is the best solution for this? New threads for all sensors? Every sensor in separate Python script?
-
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

Jacob26
Posts: 2
Joined: Tue Aug 14, 2018 7:35 am

Re: Reading a few sensors in the same time (Python)

Thu Aug 16, 2018 12:07 pm

hippy wrote: I would have thought threads but you could write each as separate programs. Then write another master program which can import those programs and run them as threads of itself. Then you have both, can test to see which works best, which you prefer.
Thanks for advice. I will get sensors next week, and then i will see what will be better. I think, new threads for all sensors is better than separate files.

Return to “Beginners”