Adafruit MPRLS Arduino Library
Adafruit_MPRLS.h
Go to the documentation of this file.
1 
20 #if (ARDUINO >= 100)
21 #include "Arduino.h"
22 #else
23 #include "WProgram.h"
24 #endif
25 
26 #include <Adafruit_I2CDevice.h>
27 
28 #define MPRLS_DEFAULT_ADDR (0x18)
29 #define MPRLS_READ_TIMEOUT (20)
30 #define MPRLS_STATUS_POWERED (0x40)
31 #define MPRLS_STATUS_BUSY (0x20)
32 #define MPRLS_STATUS_FAILED (0x04)
33 #define MPRLS_STATUS_MATHSAT (0x01)
34 #define COUNTS_224 (16777216L)
35 #define PSI_to_HPA (68.947572932)
36 #define MPRLS_STATUS_MASK \
37  (0b01100101)
38 
39 /**************************************************************************/
44 /**************************************************************************/
46 public:
47  Adafruit_MPRLS(int8_t reset_pin = -1, int8_t EOC_pin = -1,
48  uint16_t PSI_min = 0, uint16_t PSI_max = 25,
49  float OUTPUT_min = 10, float OUTPUT_max = 90,
50  float K = PSI_to_HPA);
51 
52  bool begin(uint8_t i2c_addr = MPRLS_DEFAULT_ADDR, TwoWire *twoWire = &Wire);
53 
54  uint8_t readStatus(void);
55  float readPressure(void);
56 
57  uint8_t lastStatus;
59 private:
60  Adafruit_I2CDevice *i2c_dev = NULL;
61  uint32_t readData(void);
62 
63  int8_t _reset, _eoc;
64  uint16_t _PSI_min, _PSI_max;
65  uint32_t _OUTPUT_min, _OUTPUT_max;
66  float _K;
67 };
float readPressure(void)
Read and calculate the pressure.
Definition: Adafruit_MPRLS.cpp:126
Adafruit_MPRLS(int8_t reset_pin=-1, int8_t EOC_pin=-1, uint16_t PSI_min=0, uint16_t PSI_max=25, float OUTPUT_min=10, float OUTPUT_max=90, float K=PSI_to_HPA)
constructor initializes default configuration value
Definition: Adafruit_MPRLS.cpp:72
Class that stores state and functions for interacting with MPRLS sensor IC.
Definition: Adafruit_MPRLS.h:45
uint8_t readStatus(void)
Read just the status byte, see datasheet for bit definitions.
Definition: Adafruit_MPRLS.cpp:192
uint8_t lastStatus
Definition: Adafruit_MPRLS.h:57
bool begin(uint8_t i2c_addr=MPRLS_DEFAULT_ADDR, TwoWire *twoWire=&Wire)
setup and initialize communication with the hardware
Definition: Adafruit_MPRLS.cpp:94
#define PSI_to_HPA
Constant: PSI to HPA conversion factor.
Definition: Adafruit_MPRLS.h:35
#define MPRLS_DEFAULT_ADDR
Most common I2C address.
Definition: Adafruit_MPRLS.h:28