-
|
Hi there, Admittedly somewhat of a novice to Python here, so please forgive me for missing anything obvious! I'm trying to use Telemetrix to read data from a sensor (MS5837-30BA) via an Arduino UNO using I2C for a project. I'd like the Is there any way I can get the data out more easily? And is there a way to speed up the I2C reading of the data (in either package; here would be avoiding the 200ms delay) – I've verified with an oscilloscope that the sensor responds very quickly, so I imagine the holdup is in the Arduino-Python interface? Thanks in advance for any help :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hi, thanks for the question. I have no experience with this sensor. However, have you tried using an example from an Arduino sketch library such as the BlueRobotics MS5837 Library? When confronted with having to deal with globals, I typically restructure my code as a class to avoid the whole global mess. You may still choose to use a procedural model with the global, but what I would do is remove the 200 ms. delay. Create D1 as a global value, initialize its value to zero, and set its value in the callback function. You would then poll the value of D1 to see if it is non-zero, and if it is, retrieve its value and reset D1 to zero for the next read. If you need to run in a non-blocking mode, you could create a separate thread to do the polling of D1. Or, if you are adventurous, you can use asyncio instead of threading. Please let me know if you have any other questions. Thanks again for the question. |
Beta Was this translation helpful? Give feedback.
Hi, thanks for the question. I have no experience with this sensor. However, have you tried using an example from an Arduino sketch library such as the BlueRobotics MS5837 Library?
This example contains a 1-second delay between reads, so I suggest trying to shorten this delay and see the fastest response you can get. This will eliminate Telemetrix from the equation and provide a good baseline for the speed of a read.
When confronted with having to deal with globals, I typically restructure my code as a class to avoid the whole global mess. You may still choose to use a procedural model with the global, but what I would do is remove the 200 ms. delay. Create D1 as a global value, initializ…