|
| 1 | +# SPL07-003 Library Documentation |
| 2 | + |
| 3 | +This file contains documentation on how to use the SPL07-003 library. |
| 4 | + |
| 5 | +## Prelude: Measurement & Oversampling |
| 6 | + |
| 7 | +The SPL07-003 effectively functions as two different sensors (pressure + temperature), both of which can have their measurement rates and accuracy selected independently from each other. |
| 8 | + |
| 9 | +Both the **measurement rate** (how many measurements are initiated per second) and the **oversampling rate** (how many samples are taken & averaged per measurement) can be configured for each element. |
| 10 | + |
| 11 | +Care must be taken when selecting settings so that the total measurement cycle time does not exceed 1 second: |
| 12 | + |
| 13 | +$$Rate_{(pres)} \times Time_{(pres)} + Rate_{(temp)} \times Time_{(temp)} < 1sec$$ |
| 14 | + |
| 15 | +Where the $Rate_{(pres)}$ and $Rate_{(temp)}$ are the measurement rates (`SPL07_Measure_Rates`), and $Time_{(pres)}$ and $Time_{(temp)}$ are how long each measurement takes, which is determined by their respective oversampling rates: |
| 16 | + |
| 17 | +| Oversample Rate | $Time_{(pres)}$ | $Time_{(temp)}$ | |
| 18 | +| --- | --- | --- | |
| 19 | +|`SPL07_1SAMPLE`| 3.6ms | 3.6ms | |
| 20 | +|`SPL07_2SAMPLES`| 5.2ms | 5.2ms* | |
| 21 | +|`SPL07_4SAMPLES`| 8.4ms | 8.4ms* | |
| 22 | +|`SPL07_8SAMPLES`| 14.8ms | 14.8ms* | |
| 23 | +|`SPL07_16SAMPLES`| 27.6ms | 27.6ms* | |
| 24 | +|`SPL07_32SAMPLES`| 53.2ms | 53.2ms* | |
| 25 | +|`SPL07_64SAMPLES`| 104.4ms | 104.4ms* | |
| 26 | +|`SPL07_128SAMPLES`| 206.8ms | 206.8ms* | |
| 27 | + |
| 28 | +<sup>\**Temperature measurement time is only specified for single-sample mode in the datasheet, but is assumed to be similar to that of the pressure sensor for other oversampling rates*</sup> |
| 29 | + |
| 30 | + |
| 31 | +Below are some example settings with their associated cycle times: |
| 32 | + |
| 33 | +| Use Case | Pressure Config | Temperature Config | Cycle Time | |
| 34 | +| --- | --- | --- | --- | |
| 35 | +| Low power | `SPL07_1HZ`, `SPL07_2SAMPLES` | `SPL07_1HZ`, `SPL07_1SAMPLE` | ~8.8ms | |
| 36 | +| Standard precision | `SPL07_2HZ`, `SPL07_16SAMPLES` | `SPL07_1HZ`, `SPL07_1SAMPLE` | ~58.8ms | |
| 37 | +| High precision | `SPL07_4HZ`, `SPL07_64SAMPLES` | `SPL07_4HZ`, `SPL07_1SAMPLE` | ~432ms | |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +## SPL07_003 Class Functions |
| 42 | +Below are functions of the `SPL07_003` class: |
| 43 | + |
| 44 | +🟣 `void reset()` |
| 45 | +- **Purpose:** Performs a software reset of the chip. Blocks until ready. |
| 46 | +- **Param:** None |
| 47 | +- **Returns:** None |
| 48 | + |
| 49 | +--- |
| 50 | +🟣 `bool begin(uint8_t addr, TwoWire *wire, uint8_t id)` |
| 51 | +- **Purpose:** Connects to and initializes the chip. |
| 52 | +- **Params:** |
| 53 | + |
| 54 | +| Parameter | Comment | |
| 55 | +| -------- | -------- | |
| 56 | +| `addr` | Optional; I2C address of sensor. Defaults to `SPL07_ADDR_DEF`. Use `SPL07_ADDR_ALT` if SDO pin is pulled low.| |
| 57 | +| `*wire` | Optional; TwoWire interface to use. Defaults to `&Wire`. |
| 58 | +| `id` | Optional; Expected sensor ID, see SPL07-003 datasheet section 7.10. Defaults to `SPL07_EXPECTED_ID`. | |
| 59 | + |
| 60 | +- **Returns:** `true` if connects to SPL07-003 and the sensor ID is correct, `false` otherwise. |
| 61 | + |
| 62 | + |
| 63 | +--- |
| 64 | +🟣 `void setMode(SPL07_Modes mode)` |
| 65 | +- **Purpose:** Sets the operating mode of the SPL07-003. |
| 66 | +- **Params:** |
| 67 | + |
| 68 | +| Parameter | Comment | |
| 69 | +| -------- | -------- | |
| 70 | +| `mode` | Options: `SPL07_IDLE`, `SPL07_ONE_PRESSURE`, `SPL07_ONE_TEMPERATURE`, `SPL07_CONT_PRESSURE`, `SPL07_CONT_TEMPERATURE`, `SPL07_CONT_PRES_TEMP`. | |
| 71 | + |
| 72 | +- **Returns:** None |
| 73 | + |
| 74 | + |
| 75 | +--- |
| 76 | +🟣 `void setPressureConfig(SPL07_Measure_Rates rate, SPL07_Oversample_Rates oversample)` |
| 77 | +- **Purpose:** Sets the measurement and oversampling rates for the pressure sensor. See note at top of document for selecting values. |
| 78 | +- **Params:** |
| 79 | + |
| 80 | +| Parameter | Comment | |
| 81 | +| -------- | -------- | |
| 82 | +| `rate` | Options: `SPL07_1HZ`, `SPL07_2HZ`, `SPL07_4HZ`, `SPL07_8HZ`, `SPL07_16HZ`, `SPL07_32HZ`, `SPL07_64HZ`, `SPL07_128HZ`, `SPL07_25_16HZ`, `SPL07_25_8HZ`, `SPL07_25_4HZ`, `SPL07_25_2HZ`, `SPL07_25HZ`, `SPL07_50HZ`, `SPL07_100HZ`, `SPL07_200HZ`. | |
| 83 | +| `oversample` | Options: `SPL07_1SAMPLE`, `SPL07_2SAMPLES`, `SPL07_4SAMPLES`, `SPL07_8SAMPLES`, `SPL07_16SAMPLES`, `SPL07_32SAMPLES`, `SPL07_64SAMPLES`, `SPL07_128SAMPLES`. | |
| 84 | + |
| 85 | +- **Returns:** None |
| 86 | + |
| 87 | +--- |
| 88 | +🟣 `void setTemperatureConfig(SPL07_Measure_Rates rate, SPL07_Oversample_Rates oversample)` |
| 89 | +- **Purpose:** Sets the measurement and oversampling rates for the temperature sensor. See note at top of document for selecting values. |
| 90 | +- **Params:** |
| 91 | + |
| 92 | +| Parameter | Comment | |
| 93 | +| -------- | -------- | |
| 94 | +| `rate` | Options: `SPL07_1HZ`, `SPL07_2HZ`, `SPL07_4HZ`, `SPL07_8HZ`, `SPL07_16HZ`, `SPL07_32HZ`, `SPL07_64HZ`, `SPL07_128HZ`, `SPL07_25_16HZ`, `SPL07_25_8HZ`, `SPL07_25_4HZ`, `SPL07_25_2HZ`, `SPL07_25HZ`, `SPL07_50HZ`, `SPL07_100HZ`, `SPL07_200HZ`. | |
| 95 | +| `oversample` | Options: `SPL07_1SAMPLE`, `SPL07_2SAMPLES`, `SPL07_4SAMPLES`, `SPL07_8SAMPLES`, `SPL07_16SAMPLES`, `SPL07_32SAMPLES`, `SPL07_64SAMPLES`, `SPL07_128SAMPLES`. | |
| 96 | + |
| 97 | +- **Returns:** None |
| 98 | + |
| 99 | + |
| 100 | +--- |
| 101 | +🟣 `void setTemperatureSource(SPL07_Temperature_Source src)` |
| 102 | +- **Purpose:** Sets the temperature sensor source. |
| 103 | +- **Params:** |
| 104 | + |
| 105 | +| Parameter | Comment | |
| 106 | +| -------- | -------- | |
| 107 | +| `src` | Options are `SPL07_TSRC_ASIC` for the default internal ASIC, or `SPL07_TSRC_MEMS` to use the temperature sensor on the MEMS unit, if available. | |
| 108 | + |
| 109 | +- **Returns:** None |
| 110 | + |
| 111 | + |
| 112 | +--- |
| 113 | +🟣 `void setInterruptActiveHigh(bool activeHigh)` |
| 114 | +- **Purpose:** Sets the polarity (active level) of the interrupt pin. |
| 115 | +- **Params:** |
| 116 | + |
| 117 | +| Parameter | Comment | |
| 118 | +| -------- | -------- | |
| 119 | +| `activeHigh` | Set to `true` if SDO is pulled low, otherwise set `false`.| |
| 120 | + |
| 121 | +- **Returns:** None |
| 122 | + |
| 123 | + |
| 124 | +--- |
| 125 | +🟣 `void configureInterrupt(SPL07_Interrupt_Options opt)` |
| 126 | +- **Purpose:** Configures which actions/events should trigger and interrupt. |
| 127 | +- **Params:** |
| 128 | + |
| 129 | +| Parameter | Comment | |
| 130 | +| -------- | -------- | |
| 131 | +| `opt` | Options: `SPL07_INT_OFF`, `SPL07_INT_PRES`, `SPL07_INT_TEMP`, `SPL07_INT_PRES_TEMP`, `SPL07_INT_FIFO`, `SPL07_INT_FIFO_PRES`, `SPL07_INT_FIFO_TEMP`, `SPL07_INT_ALL`.| |
| 132 | + |
| 133 | +- **Returns:** None |
| 134 | + |
| 135 | + |
| 136 | +--- |
| 137 | +🟣 `void getInterruptStatus()` |
| 138 | +- **Purpose:** Retrieves the interrupt status from the chip. Calling this will reset the interrupt value register. |
| 139 | +- **Params:** None |
| 140 | +- **Returns:** A `uint8_t` where the 3 least-significant bits represent interrupt flags. Bit 0 is Pressure Ready, Bit 1 is Temperature Ready, Bit 2 is FIFO full. See datasheet 7.7. |
| 141 | + |
| 142 | + |
| 143 | +--- |
| 144 | +🟣 `void setPressureOffset(double offset)` |
| 145 | +- **Purpose:** Sets the linear pressure offset to apply during pressure calculation. By default the offset is 0. |
| 146 | +- **Params:** |
| 147 | + |
| 148 | +| Parameter | Comment | |
| 149 | +| -------- | -------- | |
| 150 | +| `offset` | Offset in Pascals | |
| 151 | + |
| 152 | +- **Returns:** None |
| 153 | + |
| 154 | + |
| 155 | +--- |
| 156 | +🟣 `void setTemperatureOffset(double offset)` |
| 157 | +- **Purpose:** Sets the linear temperature offset to apply during temperature calculation. By default the offset is 0. |
| 158 | +- **Params:** |
| 159 | + |
| 160 | +| Parameter | Comment | |
| 161 | +| -------- | -------- | |
| 162 | +| `offset` | Offset in degrees Celsius | |
| 163 | + |
| 164 | +- **Returns:** None |
| 165 | + |
| 166 | + |
| 167 | +--- |
| 168 | +🟣 `bool pressureAvailable()` |
| 169 | +- **Purpose:** Returns if fresh pressure data is available for reading. |
| 170 | +- **Params:** None |
| 171 | +- **Returns:** `true` if new pressure reading available, `false` otherwise. |
| 172 | + |
| 173 | + |
| 174 | +--- |
| 175 | +🟣 `bool temperatureAvailable()` |
| 176 | +- **Purpose:** Returns if fresh temperature data is available for reading. |
| 177 | +- **Params:** None |
| 178 | +- **Returns:** `true` if new temperature reading available, `false` otherwise. |
| 179 | + |
| 180 | + |
| 181 | +--- |
| 182 | +🟣 `double readPressure()` |
| 183 | +- **Purpose:** Fetches and converts the latest pressure reading from the sensor. |
| 184 | +- **Params:** None |
| 185 | +- **Returns:** Pressure in Pascals |
| 186 | + |
| 187 | + |
| 188 | +--- |
| 189 | +🟣 `double readTemperature()` |
| 190 | +- **Purpose:** Fetches and converts the latest temperature reading from the sensor. |
| 191 | +- **Params:** None |
| 192 | +- **Returns:** Temperature in degrees Celsius |
0 commit comments