|
| 1 | +# WSEN-PADS MicroPython Driver |
| 2 | + |
| 3 | +MicroPython driver for the **Würth Elektronik WSEN-PADS** absolute pressure sensor. |
| 4 | + |
| 5 | +This driver provides an easy-to-use API to read **pressure** and **temperature** using the I²C interface. |
| 6 | + |
| 7 | +The WSEN-PADS is a high-resolution digital pressure sensor with integrated temperature measurement, designed for applications such as weather monitoring, altimetry, and environmental sensing. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +# Features |
| 12 | + |
| 13 | +* I²C communication |
| 14 | +* Pressure measurement |
| 15 | +* Temperature measurement |
| 16 | +* One-shot acquisition |
| 17 | +* Continuous measurement mode |
| 18 | +* Configurable Output Data Rate (ODR) |
| 19 | +* Low-noise mode support |
| 20 | +* Optional low-pass filter |
| 21 | +* Soft reset and device reboot |
| 22 | +* Raw data access |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +# Sensor Overview |
| 27 | + |
| 28 | +| Feature | Value | |
| 29 | +| ----------------------- | ---------------------- | |
| 30 | +| Pressure range | 26 kPa – 126 kPa | |
| 31 | +| Pressure resolution | 24-bit | |
| 32 | +| Temperature resolution | 16-bit | |
| 33 | +| Pressure sensitivity | 1 / 4096 hPa per digit | |
| 34 | +| Temperature sensitivity | 0.01 °C per digit | |
| 35 | +| Interface | I²C / SPI | |
| 36 | +| Maximum ODR | 200 Hz | |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +# Hardware Connection |
| 41 | + |
| 42 | +The driver currently supports **I²C mode**. |
| 43 | + |
| 44 | +## Pins |
| 45 | + |
| 46 | +| Sensor Pin | Description | |
| 47 | +| ---------- | -------------------- | |
| 48 | +| VDD | Power supply | |
| 49 | +| VDD_IO | Interface supply | |
| 50 | +| GND | Ground | |
| 51 | +| SDA | I²C data | |
| 52 | +| SCL | I²C clock | |
| 53 | +| CS | Must be HIGH for I²C | |
| 54 | +| SAO | Selects I²C address | |
| 55 | + |
| 56 | +## I²C Address |
| 57 | + |
| 58 | +| SAO | Address | |
| 59 | +| ---- | ------- | |
| 60 | +| LOW | `0x5C` | |
| 61 | +| HIGH | `0x5D` | |
| 62 | + |
| 63 | +Recommended configuration for a single device on the bus: |
| 64 | + |
| 65 | +``` |
| 66 | +SAO = HIGH |
| 67 | +I2C address = 0x5D |
| 68 | +``` |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +# Installation |
| 73 | + |
| 74 | +Clone the repository and copy the driver to your MicroPython device. |
| 75 | + |
| 76 | +Example using **mpremote**: |
| 77 | + |
| 78 | +```bash |
| 79 | +mpremote mount lib/wsen-pads |
| 80 | +``` |
| 81 | + |
| 82 | +The driver will then be available as: |
| 83 | + |
| 84 | +```python |
| 85 | +from wsen_pads import WSEN_PADS |
| 86 | +``` |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +# Basic Usage |
| 91 | + |
| 92 | +```python |
| 93 | +from machine import I2C, Pin |
| 94 | +from time import sleep |
| 95 | +from wsen_pads import WSEN_PADS |
| 96 | + |
| 97 | +i2c = I2C( |
| 98 | + 1, |
| 99 | + scl=Pin(7), |
| 100 | + sda=Pin(6), |
| 101 | +) |
| 102 | + |
| 103 | +sensor = WSEN_PADS(i2c) |
| 104 | + |
| 105 | +while True: |
| 106 | + pressure, temperature = sensor.read() |
| 107 | + |
| 108 | + print("Pressure:", pressure, "hPa") |
| 109 | + print("Temperature:", temperature, "°C") |
| 110 | + print() |
| 111 | + |
| 112 | + sleep(1) |
| 113 | +``` |
| 114 | + |
| 115 | +--- |
| 116 | + |
| 117 | +# One-shot Measurement |
| 118 | + |
| 119 | +```python |
| 120 | +pressure, temperature = sensor.read_one_shot() |
| 121 | +``` |
| 122 | + |
| 123 | +This triggers a single conversion and returns the measurement. |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +# Continuous Mode |
| 128 | + |
| 129 | +```python |
| 130 | +from wsen_pads.const import ODR_10_HZ |
| 131 | + |
| 132 | +sensor.set_continuous(odr=ODR_10_HZ) |
| 133 | + |
| 134 | +pressure = sensor.pressure() |
| 135 | +temperature = sensor.temperature() |
| 136 | +``` |
| 137 | + |
| 138 | +Available ODR values: |
| 139 | + |
| 140 | +``` |
| 141 | +ODR_1_HZ |
| 142 | +ODR_10_HZ |
| 143 | +ODR_25_HZ |
| 144 | +ODR_50_HZ |
| 145 | +ODR_75_HZ |
| 146 | +ODR_100_HZ |
| 147 | +ODR_200_HZ |
| 148 | +``` |
| 149 | + |
| 150 | +--- |
| 151 | + |
| 152 | +# Raw Data Access |
| 153 | + |
| 154 | +Raw values from the sensor can also be read: |
| 155 | + |
| 156 | +```python |
| 157 | +raw_pressure = sensor.pressure_raw() |
| 158 | +raw_temperature = sensor.temperature_raw() |
| 159 | +``` |
| 160 | + |
| 161 | +Conversions: |
| 162 | + |
| 163 | +``` |
| 164 | +pressure_hpa = raw_pressure / 4096 |
| 165 | +temperature_c = raw_temperature * 0.01 |
| 166 | +``` |
| 167 | + |
| 168 | +--- |
| 169 | + |
| 170 | +# Status Helpers |
| 171 | + |
| 172 | +The driver provides helper functions for checking data availability. |
| 173 | + |
| 174 | +```python |
| 175 | +sensor.pressure_available() |
| 176 | +sensor.temperature_available() |
| 177 | +sensor.is_ready() |
| 178 | +``` |
| 179 | + |
| 180 | +--- |
| 181 | + |
| 182 | +# Device Control |
| 183 | + |
| 184 | +## Soft Reset |
| 185 | + |
| 186 | +```python |
| 187 | +sensor.soft_reset() |
| 188 | +``` |
| 189 | + |
| 190 | +## Reboot Sensor |
| 191 | + |
| 192 | +```python |
| 193 | +sensor.reboot() |
| 194 | +``` |
| 195 | + |
| 196 | +--- |
| 197 | + |
| 198 | +# Examples |
| 199 | + |
| 200 | +Examples are available in the `examples` directory. |
| 201 | + |
| 202 | +``` |
| 203 | +examples/ |
| 204 | + example_basic.py |
| 205 | + example_oneshot.py |
| 206 | + test.py |
| 207 | +``` |
| 208 | + |
| 209 | +--- |
| 210 | + |
| 211 | +# Driver Structure |
| 212 | + |
| 213 | +``` |
| 214 | +wsen-pads/ |
| 215 | +│ |
| 216 | +├── README.md |
| 217 | +├── manifest.py |
| 218 | +├── examples/ |
| 219 | +│ |
| 220 | +└── wsen_pads/ |
| 221 | + ├── __init__.py |
| 222 | + ├── const.py |
| 223 | + ├── device.py |
| 224 | + └── exceptions.py |
| 225 | +``` |
| 226 | + |
| 227 | +--- |
0 commit comments