B4R Arduino and SHT11 digital humidity sensor example

The SHT1x digital humidity sensor is a reflow solderable sensor. The SHT1x series consists of a low-cost version with the SHT10 humidity sensor, a standard version with the SHT11 humidity sensor, and a high-end version with the SHT15 humidity sensor. As with every other Sensirion sensor type from the SHTxx humidity sensor family, they are fully calibrated and provide a digital output.

The humidity sensors are seamlessly coupled to a 14-bit-analog-to-digital converter and a serial interface circuit. This results in superior signal quality, a fast response time, and insensitivity to external disturbances (EMC).

One thing to note is that these sensors have been effectively replaced by others in sensirion’s range such as the SHT31 but they still work and have good performance for hobbyists




You need to install the library from – https://github.com/practicalarduino/SHT1x

#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Public timer1 As Timer
Public sht11humi As Float
Public sht11tempc As Float
Public sht11tempf As Float
End Sub
Private Sub AppStart
timer1.Enabled = True
End Sub
Private Sub Timer1_Tick
Log("Celsius is: ", sht11tempc, "°C")
Log("Fahrenheit is: ", sht11tempf, "°C")
Log("Humidity is: ", sht11humi, " %")
End Sub
#if C
#include "SHT1x.h"
#define dataPin 10
#define clockPin 11
SHT1x sht1x(dataPin, clockPin);
void setup(B4R::Object* o){
void loop (B4R::Object* o) {
float temp_c;
float temp_f;
float humidity;
b4r_main::_sht11humi =sht1x.readHumidity();
b4r_main::_sht11tempc =sht1x.readTemperatureC();
b4r_main::_sht11tempf =sht1x.readTemperatureF();
#End if



Celsius is: 18.9300°C
Fahrenheit is: 67.2260°C
Humidity is: 42.7808 %
Celsius is: 21.4300°C
Fahrenheit is: 71.6900°C
Humidity is: 43.6952 %
Celsius is: 23.3600°C
Fahrenheit is: 74.8400°C
Humidity is: 47.3777 %
Celsius is: 24.7400°C
Fahrenheit is: 77.1440°C
Humidity is: 51.5196 %
Celsius is: 25.8100°C
Fahrenheit is: 78.9260°C
Humidity is: 54.9967 %
Celsius is: 26.6800°C
Fahrenheit is: 80.3840°C
Humidity is: 57.6510 %



SHT11 Digital Temperature and Humidity Sensor,Single bus output temperature and humidity module