Closed tobyaharris closed 1 week ago
Most likely, the solution is set up to try sample at a faster rate than the sensor can reliably support. I would guess that changing it to a sample period of 2 seconds would fix.
It may be relevant to note that whilst the config file does have a sample_count
:
https://github.com/DigitalShoestringSolutions/AirParticleMonitoring/blob/7666b5d326224bdb9731c86ff7a1fa0dc7d34001/particle_dc/config/config.toml#L9
...this value is not used at all in the code 🤦. It is loaded from config in: https://github.com/DigitalShoestringSolutions/AirParticleMonitoring/blob/7666b5d326224bdb9731c86ff7a1fa0dc7d34001/particle_dc/code/measure.py#L57
and then nothing is done with self.sample_count
. Clearly copied from PowerBasic without much tidying up.
Hence, what is likely happening is: https://github.com/DigitalShoestringSolutions/AirParticleMonitoring/blob/7666b5d326224bdb9731c86ff7a1fa0dc7d34001/particle_dc/config/config.toml#L10 https://github.com/DigitalShoestringSolutions/AirParticleMonitoring/blob/7666b5d326224bdb9731c86ff7a1fa0dc7d34001/particle_dc/code/measure.py#L56 https://github.com/DigitalShoestringSolutions/AirParticleMonitoring/blob/7666b5d326224bdb9731c86ff7a1fa0dc7d34001/particle_dc/code/measure.py#L79 https://github.com/DigitalShoestringSolutions/AirParticleMonitoring/blob/7666b5d326224bdb9731c86ff7a1fa0dc7d34001/particle_dc/code/measure.py#L96 And finally a mucky compensated sleep https://github.com/DigitalShoestringSolutions/AirParticleMonitoring/blob/7666b5d326224bdb9731c86ff7a1fa0dc7d34001/particle_dc/code/measure.py#L129-L134 ... It's trying to run at 5Hz.
And once I've noticed it, I've got to do the minimum to fix it: see branch hotfix/sample-rate
On every single sample in the logs of the reference setup, this warning is raised. The line completes with a time, usually
by 0.9...s
but occasionally this time is only ~0.4s