|
| 1 | +# [mpy-lib](https://github.com/micropython-Chinese-Community/mpy-lib) |
| 2 | + |
| 3 | +## SHT3x |
| 4 | + |
| 5 | +Humidity and Temperature Sensor micropython driver, **16bit** I2C address mode. |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +## ESP32 example |
| 12 | + |
| 13 | +```python |
| 14 | +from machine import I2C, Pin |
| 15 | +from time import sleep_ms |
| 16 | +from sht3x_16bit import SHT3x |
| 17 | + |
| 18 | +i2c = I2C(0, sda=Pin(21), scl = Pin(22)) |
| 19 | + |
| 20 | +sht30 = SHT3x(i2c) |
| 21 | + |
| 22 | +while True: |
| 23 | + sht30.measure() |
| 24 | + print(sht30.ht()) |
| 25 | + sleep_ms(1000) |
| 26 | +``` |
| 27 | + |
| 28 | +## API |
| 29 | + |
| 30 | +- SHT3x.**measure()** |
| 31 | +Starting measurement. |
| 32 | + |
| 33 | +- SHT3x.**humidity()** |
| 34 | +get humidity. |
| 35 | + |
| 36 | +- SHT3x.**temperature()** |
| 37 | +get temperature. |
| 38 | + |
| 39 | +- SHT3x.**ht()** |
| 40 | +get humidity and temperature. |
| 41 | + |
| 42 | +- SHT3x.**config(mode = 0x240b, delay = 6, decimal = 1)** |
| 43 | + - mode, measurement command. Please see [mode table](#mode) below. |
| 44 | + - delay, measurement duration time |
| 45 | + - low repeatability, 4ms |
| 46 | + - Medium repeatability, 6ms (default) |
| 47 | + - High repeatability, 15ms |
| 48 | + - decimal, number of digits after decimal point |
| 49 | + |
| 50 | +- SHT3x.**heater(on=0)** |
| 51 | +Turn on/off internal heater. |
| 52 | + - on=1, turn internal heater |
| 53 | + - on=0, turn off internal heater |
| 54 | + |
| 55 | +- SHT3x.**status()** |
| 56 | +Read **Status Register** |
| 57 | + |
| 58 | +- SHT3x.**clear_status()** |
| 59 | +Clear **Status Register** |
| 60 | + |
| 61 | +- SHT3x.**reset()** |
| 62 | +Soft Reset |
| 63 | + |
| 64 | +<a name='mode'>mode table</a> |
| 65 | +| mode | Repeatability | Measurement | mps | |
| 66 | +|-|-|-|-| |
| 67 | +| 0x2c06 | High | Single Shot| - | |
| 68 | +| 0x2c0D | Medium | Single Shot | -| |
| 69 | +| 0x2c10 | Low | Single Shot | -| |
| 70 | +| 0x2400 | High | Single Shot|- | |
| 71 | +| 0x240b (default)| Medium | Single Shot |-| |
| 72 | +| 0x2416 | Low | Single Shot | -| |
| 73 | +| 0x2032 | High | Periodic mode | 0.5| |
| 74 | +| 0x2024 | Medium | Periodic mode | 0.5| |
| 75 | +| 0x202F | Low | Periodic mode | 0.5| |
| 76 | +| 0x2130 | High | Periodic mode | 1| |
| 77 | +| 0x2126 | Medium | Periodic mode | 1| |
| 78 | +| 0x212d | Low | Periodic mode | 1| |
| 79 | +| 0x2236 | High | Periodic mode | 2| |
| 80 | +| 0x2220 | Medium | Periodic mode | 2| |
| 81 | +| 0x222b | Low | Periodic mode | 2| |
| 82 | +| 0x2334 | High | Periodic mode | 4| |
| 83 | +| 0x2322 | Medium | Periodic mode | 4| |
| 84 | +| 0x2329 | Low | Periodic mode | 4| |
| 85 | +| 0x2737 | High | Periodic mode | 10| |
| 86 | +| 0x2721 | Medium | Periodic mode | 10| |
| 87 | +| 0x272a | Low | Periodic mode | 10| |
| 88 | + |
| 89 | + |
| 90 | +please note, In order to simplify the code, crc8 checksum is ignored. |
| 91 | + |
| 92 | +From [microbit/micropython Chinese community](https://www.micropython.org.cn). |
0 commit comments