Home » SHT40 Sensor and Arduino Uno

SHT40 Sensor and Arduino Uno

by arduinoguy71

In this article we look at the SHT40 humidity sensor from Sensirion.

Parts Required

You can connect to the sensor using dupont style jumper wire.

This should work with other Arduino boards – I have tried a Mega and Nano for example

Name   Link
Arduino Uno
SHT40
Connecting cables

 

Schematic/Connection

I used 3.3v from the Arduino Uno – 5v should be ok if the module has an onboard regulator. You will need to check.

Code Example

This example uses a couple of libraries, both of which can be installed using the library manager

You need the Adafruit library for the SHT40 – https://github.com/adafruit/Adafruit_SHT4X

You also need an I2C support library from the same folks for the library above to work and that is available from – https://github.com/adafruit/Adafruit_BusIO

 

include "Adafruit_SHT4x.h"

Adafruit_SHT4x sht4 = Adafruit_SHT4x();

void setup() 
{
  Serial.begin(115200);

  while (!Serial)
    delay(10);     // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("Adafruit SHT4x test");
  if (! sht4.begin()) 
  {
    Serial.println("Couldn't find SHT4x");
    while (1) delay(1);
  }
  Serial.println("Found SHT4x sensor");
  Serial.print("Serial number 0x");
  Serial.println(sht4.readSerial(), HEX);

  // You can have 3 different precisions, higher precision takes longer
  sht4.setPrecision(SHT4X_HIGH_PRECISION);

  // You can have 6 different heater settings
  sht4.setHeater(SHT4X_NO_HEATER);
  
}


void loop() 
{
  sensors_event_t humidity, temp;
  
  uint32_t timestamp = millis();
  sht4.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
  timestamp = millis() - timestamp;

  Serial.print("Temperature: "); 
  Serial.print(temp.temperature); 
  Serial.println(" degrees C");
  Serial.print("Humidity: "); 
  Serial.print(humidity.relative_humidity); 
  Serial.println("% rH");

  Serial.print("Read duration (ms): ");
  Serial.println(timestamp);

  delay(1000);
}

 

Serial Monitor Output

Adafruit SHT4x test
Found SHT4x sensor
Serial number 0x1044FA2B
Temperature: 18.84 degrees C
Humidity: 39.21% rH
Read duration (ms): 11

 

Links

https://www.sensirion.com/en/download-center/humidity-sensors/humidity-sensor-sht4x/

 

 

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.