https://github.com/pilotak/shtc3
Mbed library for SHTC3 humidity & temperature sensor
https://github.com/pilotak/shtc3
humidity mbed-os sensor shtc3 temperature
Last synced: about 2 months ago
JSON representation
Mbed library for SHTC3 humidity & temperature sensor
- Host: GitHub
- URL: https://github.com/pilotak/shtc3
- Owner: pilotak
- License: mit
- Created: 2020-08-26T15:27:46.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-08T13:15:35.000Z (over 4 years ago)
- Last Synced: 2025-01-16T19:37:22.251Z (3 months ago)
- Topics: humidity, mbed-os, sensor, shtc3, temperature
- Language: C++
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SHTC3
[](https://os.mbed.com/)Mbed library for SHTC3 humidity & temperature sensor
## Example
```cpp
#include "mbed.h"
#include "SHTC3.h"SHTC3 sht(PB_9, PB_8);
int main() {
if (!sht.init()) {
printf("Init failed\n");
return 0;
}while (1) {
uint16_t raw_temp, raw_humidity;if (sht.read(&raw_temp, &raw_humidity)) {
printf("Temperature: %f*C (%u), humidity: %f%% (%u)\n", sht.toCelsius(raw_temp), raw_temp,
sht.toPercentage(raw_humidity), raw_humidity);} else {
printf("Read failed\n");
}ThisThread::sleep_for(2s);
}
}```
> If you don't see float numbers in the console output, you need to turn on the support of float for printf
> ```json
> {
> "target_overrides": {
> "*": {
> "platform.minimal-printf-enable-floating-point": true,
> "platform.minimal-printf-set-floating-point-max-decimals": 6
> }
> }
> }
> ```## Example passing I2C object
```cpp
#include "mbed.h"
#include "SHTC3.h"I2C i2c(PB_9, PB_8);
SHTC3 sht;int main() {
if (!sht.init(&i2c)) {
printf("Init failed\n");
return 0;
}while (1) {
uint16_t raw_temp, raw_humidity;if (sht.read(&raw_temp, &raw_humidity)) {
printf("Temperature: %f*C (%u), humidity: %f%% (%u)\n", sht.toCelsius(raw_temp), raw_temp,
sht.toPercentage(raw_humidity), raw_humidity);} else {
printf("Read failed\n");
}ThisThread::sleep_for(2s);
}
}
```