GY-63_MS5611/libraries/MSP300/README.md

184 lines
5.0 KiB
Markdown
Raw Normal View History

2022-12-06 14:03:12 -05:00
[![Arduino CI](https://github.com/RobTillaart/MSP300/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/MSP300/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/MSP300/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/MSP300/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/MSP300/actions/workflows/jsoncheck.yml)
2023-09-23 13:11:32 -04:00
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/MSP300.svg)](https://github.com/RobTillaart/MSP300/issues)
2022-12-06 14:03:12 -05:00
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/MSP300/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/MSP300.svg?maxAge=3600)](https://github.com/RobTillaart/MSP300/releases)
2023-09-23 13:11:32 -04:00
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/MSP300.svg)](https://registry.platformio.org/libraries/robtillaart/MSP300)
2022-12-06 14:03:12 -05:00
# MSP300
Arduino library for I2C MSP300 pressure transducer.
The library is experimental and not tested yet (no hardware).
## Description
The MSP300 is an industrial digital pressure transducer.
This library implements the I2C version (J) of the sensor.
It is written based upon the datasheet.
The library does not implement the SPI or analog version.
Note: be aware to buy the right sensor: PSI/BAR, SPI/I2C/analog and I2C address as these are hardcoded.
(OK pressure output can be converted)
As the sensor is industrial quality, many applications can be realized with it.
2023-02-05 04:52:57 -05:00
Issues, remarks, experience and improvements are welcome,
please open an issue on https://github.com/RobTillaart/MSP300.
2022-12-06 14:03:12 -05:00
#### Available pressure ranges
- PSI := 100, 200, 300, 500, 1K, 3K, 5K, 10K, 15K
- BAR := 7, 10, 20, 35, 70, 200, 350, 700, 1000
#### I2C connection
| colour | description |
|:--------:|:-------------:|
2023-09-23 13:11:32 -04:00
| RED | 2.7 5.0V |
2022-12-06 14:03:12 -05:00
| BLACK | GND |
| GREEN | SCL |
| WHITE | SDA |
| YELLOW | NC |
#### Analog version
For Arduino analog output version 3 is also interesting.
It provide 0.5-4.5 volt output which matches many ADC ranges.
White wire is the output (page 4 datasheet).
This version is not supported in the library.
#### Related libraries
This library is related to:
2023-02-05 04:52:57 -05:00
- https://github.com/RobTillaart/I2C_ASDX Honeywell pressure sensors
- https://github.com/RobTillaart/MS5611 (I2C) air pressure & temperature sensor
- https://github.com/RobTillaart/MS5611_SPI air pressure & temperature sensor
- https://github.com/RobTillaart/Pressure to convert PSI to BAR and back.
2022-12-06 14:03:12 -05:00
## I2C
#### Address
The MSP300 has a fixed address, however there a five different supported.
So without a multiplexer you can have up to 5 transducers on one I2C bus.
The address is in the product number of the sensor you buy. (check datasheet Page 7).
2023-02-05 04:52:57 -05:00
| code | address |
|:------:|:---------:|
| 0 | 0x28 |
| 1 | 0x36 |
| 2 | 0x46 |
| 3 | 0x48 |
| 4 | 0x51 |
2022-12-06 14:03:12 -05:00
#### Speed
The sensor should work at 100 - 400 KHz I2C.
## Interface
2023-02-05 04:52:57 -05:00
```cpp
#include "MSP300.h"
```
#### Constructor
2022-12-06 14:03:12 -05:00
The library has a number of functions which are all quite straightforward.
- **MSP300(uint8_t address, TwoWire \*wire = &Wire)** constructor
- **bool begin(uint8_t sda, uint8_t scl, int maxValue)** ESP32 a.o initializing of Wire.
maxValue is the maximum the sensor can read.
This can be either PSI or BAR.
- **bool begin(int maxValue)** for UNO.
maxValue is the maximum the sensor can read.
- **bool isConnected()** See if address set in constructor is on the bus.
- **bool setAddress(const uint8_t deviceAddress)**
- **uint8_t getAddress()**
#### Read
- **uint32_t readPT()** must be called before pressure or temperature can be read.
Returns the raw value which is useful for debugging.
- **float getPressure()** returns the pressure in PSI or BAR (whatever sensor you have).
2023-02-05 04:52:57 -05:00
- **float getTemperature()** returns the temperature in degrees Celsius.
2023-09-23 13:11:32 -04:00
Range 0..55° Celsius
2023-02-05 04:52:57 -05:00
2022-12-06 14:03:12 -05:00
#### Calibration
- **void setPressureCounts(uint16_t Pmin = 1000, uint16_t Pmax = 15000)** set the count rates.
2023-02-05 04:52:57 -05:00
Use with care. Check datasheet for details.
2022-12-06 14:03:12 -05:00
#### Error handling
2023-02-05 04:52:57 -05:00
- **int lastError()** returns the last error set. Note: will reset the error!
2022-12-06 14:03:12 -05:00
## Error codes
| define | value |
|:---------------|:-------:|
| MSP300_OK | 0 |
| MSP300_ERROR | 100 |
## Operation
The examples show the basic working of the functions.
## Future
2023-02-05 04:52:57 -05:00
#### Must
2022-12-06 14:03:12 -05:00
- improve documentation
- get hardware
- test
2023-09-23 13:11:32 -04:00
2023-02-05 04:52:57 -05:00
#### Should
2022-12-06 14:03:12 -05:00
- add examples
- elaborate error handling.
2023-09-23 13:11:32 -04:00
2023-02-05 04:52:57 -05:00
#### Could
- test I2C performance.
- add **setTemperatureOffset(float offset = 0)**
- add **setPressureOffset(float offset = 0)**
2022-12-06 14:03:12 -05:00
- unit tests
- add simple class for the analog version
- MSP300A
2023-09-23 13:11:32 -04:00
#### Wont
## Support
If you appreciate my libraries, you can support the development and maintenance.
Improve the quality of the libraries by providing issues and Pull Requests, or
donate through PayPal or GitHub sponsors.
Thank you,
2022-12-06 14:03:12 -05:00