MS5803 Pressure Sensor
Table of Contents
Setup and Usage
In the interest of collecting pressue data for my in-progress, underwater sensor platform, I decided to purchase an pressure sensor1. The decision to use the MS5803 sensor board from SparkFun1 was made after searching around for waterproof sensors that had a wide pressure range, good precision, relatively low cost and little soldering. I stumbled upon a wonderful underwater data logger project2 that used the MS5803 and found that the sensor met my requirements and was already proven by that project to work well in harsh, marine environments.
To test it, I used my Raspberry Pi 3 Model B+ and followed the ms5803py package tutorial3.
In order to test the installed ms5803py package, I initially used the package’s github source code4 and its
example.py has a syntax bug, but otherwise runs OK.
Though, because the package is written for python3 only, I may have to rewrite it for python2 depending on how the
underwater sensor platform progresses in its tech stack.
However, it became apparent after comparing the sensor’s pressure output to local weather stations’ pressure readings, that the ms5803py package has an order-of-magnitude error5 when reporting pressure.
So, I forked6 the source repo and began testing the conversion math used in
After sprinkling some
print() calls at various points in the conversion math and verifying that all intermediate steps matched the expected output from the sensor’s datasheet7, I pushed a simple fix to my fork6 of the ms5803py package.
Consequently, I’ll be using my forked version of the project going forward and not the pypi package, ms5803py (unless this error is fixed in it at some point).
To recap the issues with the ms5803py package:
The ms5803py package is written only for python3. There is a simple, syntax bug in
example.pyin ms5803py’s source code4.
There is a simple, order-of-magnitude math bug in
sensor.pyin ms5803py’s source code5.
- Temperature seems to be off from local stations’ readings. (can be somewhat handled by changing the OverSampling Rates (OSR) of the pressure and temperature sensors as mentioned in the github repository4)
As the underwater sensor platform moves forward and because the sensor board also supplies a temperature reading, I may investigate combining its temperature reading with the IMU’s temperature reading to hopefully gain a more accurate temperature readout.
The package maintainer for
ms5803py3 has corrected the installation issues mentioned above and allowed for variable accuracy of the presure and temperature sensors in both the github repository4 and pypi package 3 for the driver code.