Using the SHTC3 with Arduino is a simple matter of wiring up the sensor to your Arduino-compatible microcontroller, installing the Adafruit SHTC3 library we've written, and running the provided example code.
I2C Wiring
Use this wiring if you want to connect via I2C interface. The I2C address for the SHTC3 is 0x70.
Here is how to wire up the sensor using one of the STEMMA QT connectors. The examples show a Metro but wiring will work the same for an Arduino or other compatible board.
- Connect board VIN (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
- Connect board GND (black wire) to Arduino GND
- Connect board SCL (yellow wire) to Arduino SCL
- Connect board SDA (blue wire) to Arduino SDA
Here is how to wire the sensor to a board using a solderless breadboard:
- Connect board VIN (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
- Connect board GND (black wire) to Arduino GND
- Connect board SCL (yellow wire) to Arduino SCL
- Connect board SDA (blue wire) to Arduino SDA
Library Installation
You can install the Adafruit SHTC3 library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit SHTC3, and select the Adafruit SHTC3 library:
Then follow the same process for the Adafruit BusIO library.
Finally follow the same process for the Adafruit Unified Sensor library:
After opening the demo file, upload to your Arduino wired up to the sensor. Once you upload the code, you will see the Temperature and Humidity values being printed when you open the Serial Monitor (Tools->Serial Monitor) at 115200 baud, similar to this:
/*************************************************** This is an example for the SHTC3 Humidity & Temp Sensor Designed specifically to work with the SHTC3 sensor from Adafruit ----> https://www.adafruit.com/products/4636 These sensors use I2C to communicate, 2 pins are required to interface ****************************************************/ #include "Adafruit_SHTC3.h" Adafruit_SHTC3 shtc3 = Adafruit_SHTC3(); void setup() { Serial.begin(115200); while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens Serial.println("SHTC3 test"); if (! shtc3.begin()) { Serial.println("Couldn't find SHTC3"); while (1) delay(1); } Serial.println("Found SHTC3 sensor"); } void loop() { sensors_event_t humidity, temp; shtc3.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data Serial.print("Temperature: "); Serial.print(temp.temperature); Serial.println(" degrees C"); Serial.print("Humidity: "); Serial.print(humidity.relative_humidity); Serial.println("% rH"); delay(1000); }
Text editor powered by tinymce.