The star of the SHT4x Trinkey is of course the SHT4x sensor. You can read temperature and humidity data from this sensor in Arduino with the Adafruit_SHT4X library. This page has example code that prints humidity and temperature data to the serial monitor and an additional example that calculates vapor-pressure deficit (VPD), which is a helpful data point for growing plants.
The SHT4x sensor is located between the capacitive touch pad and the reset button in a thermal-isolation cutout.
You can install the Adafruit_SHT4X library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit_SHT4x, and select the Adafruit SHT4x library:
If asked about dependencies, click "Install all".
If the "Dependencies" window does not come up, then you already have the dependencies installed.
If the dependencies are already installed, you must make sure you update them through the Arduino Library Manager before loading the example!
// SPDX-FileCopyrightText: 2024 Limor Fried for Adafruit Industries // // SPDX-License-Identifier: MIT #include <Adafruit_SHT4x.h> Adafruit_SHT4x sht4 = Adafruit_SHT4x(); void setup() { Serial.begin(115200); while (!Serial) { delay(10); // will pause until serial console opens } Serial.println("# Adafruit SHT4x Trinkey Temperature and Humidity Demo"); if (! sht4.begin()) { Serial.println("# Couldn't find SHT4x"); while (1) delay(1); } Serial.println("# Found SHT4x sensor."); sht4.setPrecision(SHT4X_HIGH_PRECISION); sht4.setHeater(SHT4X_NO_HEATER); Serial.println("Temperature in *C, Relative Humidity %"); } void loop() { sensors_event_t humidity, temp; sht4.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data Serial.print(temp.temperature); Serial.print(", "); Serial.println(humidity.relative_humidity); // 1 second between readings delay(1000); }
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You'll see the temperature and humidity values printed to the Serial Monitor every second.
// SPDX-FileCopyrightText: 2024 Limor Fried for Adafruit Industries // // SPDX-License-Identifier: MIT #include <Adafruit_SHT4x.h> Adafruit_SHT4x sht4 = Adafruit_SHT4x(); void setup() { Serial.begin(115200); while (!Serial) { delay(10); // will pause until serial console opens } Serial.println("# Adafruit SHT4x Trinkey Vapor-Pressure Deficit Demo"); if (! sht4.begin()) { Serial.println("# Couldn't find SHT4x"); while (1) delay(1); } Serial.println("# Found SHT4x sensor."); sht4.setPrecision(SHT4X_HIGH_PRECISION); sht4.setHeater(SHT4X_NO_HEATER); Serial.println("Vapor-Pressure Deficit (kPa)"); } void loop() { sensors_event_t humidity, temp; sht4.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data // saturation vapor pressure is calculated float svp = 0.6108 * exp(17.27 * temp.temperature / (temp.temperature + 237.3)); // actual vapor pressure float avp = humidity.relative_humidity / 100 * svp; // VPD = saturation vapor pressure - actual vapor pressure float vpd = svp - avp; Serial.println(vpd); // 1 second between readings delay(1000); }
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You'll see the vapor-pressure deficit (VPD) print out to the Serial Monitor every few seconds. The VPD is calculated with the temperature and humidity readings from the SHT4x sensor. First, the saturation vapor pressure is calculated:
float svp = 0.6108 * exp(17.27 * temp.temperature / (temp.temperature + 237.3))
Then, the actual vapor pressure:
float avp = humidity.relative_humidity / 100 * svp
And finally VPD is found by subtracting the actual vapor pressure from the saturation vapor pressure:
float vpd = svp - avp
Page last edited January 22, 2025
Text editor powered by tinymce.