https://github.com/y252328/sht1x
Arduino library support for Sensorion SHT1x(SHT10, SHT11, SHT15) all command.
https://github.com/y252328/sht1x
arduino crc8 humidity-sensor sht1x temperature-sensor
Last synced: 8 months ago
JSON representation
Arduino library support for Sensorion SHT1x(SHT10, SHT11, SHT15) all command.
- Host: GitHub
- URL: https://github.com/y252328/sht1x
- Owner: y252328
- License: gpl-3.0
- Created: 2020-01-25T15:45:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-26T12:17:19.000Z (over 5 years ago)
- Last Synced: 2025-01-14T23:40:03.302Z (9 months ago)
- Topics: arduino, crc8, humidity-sensor, sht1x, temperature-sensor
- Language: C++
- Homepage:
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.txt
- License: LICENSE
Awesome Lists containing this project
README
# SHT1x Temperature / Humidity Sensor Library for Arduino
Copyright 2020 Chih-Yu Hsiang \
Copyright 2009 Jonathan Oxer jon@oxer.com.au / http://www.practicalarduino.com \
Copyright 2008 Maurice Ribble ribblem@yahoo.com / http://www.glacialwanderer.comThis repository is based on [practicalarduino/SHT1x](https://github.com/practicalarduino/SHT1x) and fully support all commands of sht1x.
Provides a simple interface to the SHT1x series (SHT10, SHT11, SHT15)
and SHT7x series (SHT71, SHT75) temperature / humidity sensors from
Sensirion, http://www.sensirion.com. These sensors use a "2-wire"
communications buss that is similar to I2C and can co-exist on the same
physical wire as I2C devices.## Installation
Download the directory "SHT1x" and move it into the "libraries"
directory inside your sketchbook directory, then restart the Arduino
IDE. You will then see it listed under File->Examples->SHT1x.## Usage
The library is instantiated as an object with methods.
Include it in your sketch and then create an object, specifying the pins to use for communication with the sensor and initial it:
``` c++
#include
#define dataPin 10
#define clockPin 11
SHT1x sht1x(dataPin, clockPin);
sht1x.init();
```You can then call methods on that object within your program. In this
example we created an object called "sht1x", but it could have been
called whatever you like. A simple example program is included with
the library and can be accessed from the File->Examples->SHT1x menu.### Read Temperature
The `readTemperature()` method returns a float within the valid range of the sensor of -40 to +123.8C (-40 to +254.9F).
A value of -40 is returned in the event of a communication error with
the sensor.Example:
```c++
// read temperature and covert to degree Celsius
float tempC = sht1x.readTemperature(TempUnit::C);// read temperature and covert to degree Fahrenheit
float tempF = sht1x.readTemperature(TempUnit::F);
```### Read Humidity
The `readHumidity()` method returns a float within the valid range of the sensor of 0 to 100%.
A negative value is returned in the event of a communication error with
the sensor.Example:
```c++
float humidity = sht1x.readHumidity();
```### Connection Reset
If communication with the device is lost the `connectionReset()` method
can reset the serial interface.
(interface only)Example:
```c++
sht1x.connectionReset();
```### Soft Reset
The `softReset()` method can
resets the interface, clears the
status register to default values.Example:
```c++
sht1x.softReset();
```### Read Status Register
The `readStatusReg()` method will read status register from sht1x
and return it.Example:
```c++
auto reg_value = sht1x.readStatusReg();
```### Write Status Register
The `writeStatusReg()` method will write value to sht1x status register.Example:
```c++
sht1x.readStatusReg(value);
```### CRC
This library support CRC-8. In default, the CRC is used, but it can be disabled via the argument.Example:
```c++
// read temperature without CRC
float tempC = sht1x.readTemperature(TempUnit::C, false);// read humidity without CRC
float humidity = sht1x.readHumidity(false);// read status register without CRC
float humidity = sht1x.readStatusReg(false);
```