hpbare/sht3x

2.0.0

Latest
uploaded 2 hours ago
Bare-metal C driver for Sensirion SHT3x-DIS temperature and humidity sensors.

Readme

# SHT3x
Bare-metal C driver for Sensirion SHT3x-DIS temperature and humidity sensors over I2C.

## Directory Layout

```text
sht3x/
├── CMakeLists.txt
├── CHANGELOG.md
├── README.md
├── docs/
│   ├── API.md
│   └── RELEASE_NOTE.md
├── examples/
│   └── simple_espidf.c
├── include/
│   ├── sht3x.h
│   ├── sht3x_defs.h
│   ├── sht3x_priv.h
│   └── sht3x_types.h
├── port/
│   └── ESP/
│       ├── include/
│       │   └── sht3x_esp.h
│       └── sht3x_esp.c
└── sht3x.c
```

## CMake

```cmake
add_subdirectory(sht3x)
target_link_libraries(your_app PRIVATE sht3x)
```

## Quick Start

```c
#include <stdio.h>
#include "sht3x.h"

/* Implement these platform-specific HAL callbacks for your target MCU/OS */
static int hal_i2c_write(SHT3x_Handle s, const uint8_t *data, size_t len) { return 0; }
static int hal_i2c_read(SHT3x_Handle s, uint8_t *data, size_t len) { return 0; }
static void hal_delay_ms(uint32_t ms) { }

int main(void)
{
    SHT3x_Config cfg = {
        .mode                 = SHT3X_MODE_SINGLE_SHOT,
        .address              = SHT3X_I2C_ADDR_VSS,
        .repeatability        = SHT3X_REPEAT_HIGH,
        .mps                  = SHT3X_MPS_1,
        .enable_art           = false,
        .enable_clock_stretch = false,
        .i2c_read             = hal_i2c_read,
        .i2c_write            = hal_i2c_write,
        .delay_ms             = hal_delay_ms,
        .user_ctx             = NULL,
    };

    SHT3x_Handle dev = SHT3x_Init(&cfg);
    if (!dev) {
        return -1;
    }

    SHT3x_MeasurementData data;
    if (SHT3x_ReadMeasurement(dev, &data) == SHT3X_OK) {
        printf("Temp: %.2f C | Humidity: %.2f %%RH\n", data.temperature_c, data.humidity_rh);
    }

    SHT3x_Destroy(dev);
    return 0;
}
```

## Documentation
- [API Reference](docs/API.md)
- [Release Note](docs/RELEASE_NOTE.md)
- [Changelog](CHANGELOG.md)

Links

Supports all targets

To add this component to your project, run:

idf.py add-dependency "hpbare/sht3x^2.0.0"

download archive

Stats

  • Archive size
    Archive size ~ 16.05 KB
  • Downloaded in total
    Downloaded in total 0 times
  • Downloaded this version
    This version: 0 times

Badge

hpbare/sht3x version: 2.0.0
|