Arduino TKJHAT
Arduino library for Pico HAT extension board
Loading...
Searching...
No Matches
Hdc2021.ino
1/*
2 HDC2021 Example
3
4 This example demonstrates how to use the HDC2021 temperature and humidity sensor with the TKJHAT library.
5 It initializes the sensor, reads temperature and humidity values, and prints them to the Serial Monitor every second.
6
7 Circuit:
8 - HDC2021 sensor integrated in Pico HAT
9
10 created 2026
11 */
12
13#include "TKJHAT.h"
14
15// Create an instance of the TKJHAT class
16TKJHAT hat;
17
18// Initializes serial communication and the HDC2021 sensor
19void setup() {
20 Serial.begin(9600); // Start serial communication at 9600 baud rate
21 hat.hdc2021.begin();
22}
23
24// Reads temperature and humidity from the sensor and prints the values to the serial monitor every second
25void loop() {
26 Serial.print("Temperature: ");
27 Serial.println(hat.hdc2021.readTemperature()); // Read and print the temperature value
28 Serial.print("Humidity: ");
29 Serial.println(hat.hdc2021.readHumidity()); // Read and print the humidity value
30 delay(1000); // Wait for 1 second before the next reading
31}
Main interface for accessing TKJHAT board features.
Definition TKJHAT.h:35
void begin()
Initialize all peripherals on the HAT Also initializes the default I2C bus for sensors and display.