Week 9: Input Devices
Date: March 19 - 25, 2026
What I Did This Week
I connected two SHT31 temperature and humidity sensors to my Reptile Monitor board. I used I2C to read both sensors at the same time. This was my first time changing an I2C address to connect two sensors on one bus.
Group Assignment
We measured analog levels and digital signals from input devices using an oscilloscope and a multimeter.
Tools We Used
| Tool | Model | Purpose |
|---|---|---|
| Oscilloscope | Keysight DSOX2002A (70 MHz, 2 ch) | Signal visualization |
| Digital multimeter | Sanwa PM3 | Voltage measurement |
What We Measured
Analog signal — Linear potentiometer
We measured the output voltage of a potentiometer as we turned the knob. We used both the oscilloscope and the multimeter to check the voltage at different positions. The oscilloscope screenshot function helped us record how the voltage changed with knob position.
Digital signal — I2C between MCU and text LCD
We probed the I2C bus between a microcontroller and a text LCD on a breadboard. The measurement conditions were not ideal, so the waveform quality was not perfect. But we could still see the SDA and SCL signals switching.
What I Learned
- An oscilloscope can show both analog and digital signals. A multimeter only shows a single value — the oscilloscope shows how it changes over time.
- I2C signals look like a series of pulses. The SCL line is the clock, and SDA carries the data. You can see the start condition (SDA goes LOW while SCL is HIGH) in the waveform.
- Probe placement and grounding matter. Bad probe connection causes noisy waveforms.
- The Keysight DSOX2002A has a screenshot function. This is very useful for recording results quickly.
Individual Assignment: Dual SHT31 Sensor
About the SHT31 Sensor
The SHT31 is a digital temperature and humidity sensor made by Sensirion.
| Spec | Value |
|---|---|
| Communication | I2C |
| Temperature accuracy | ±0.3°C |
| Humidity accuracy | ±2% RH |
| Voltage | 2.15 – 5.5V |
| I2C address | 0x44 (default) / 0x45 (ADDR = HIGH) |
Changing the I2C Address
The Grove SHT31 module has a solder jumper on the back. I shorted it to change the address to 0x45. This lets me use two sensors on the same I2C bus.
- 0x44 (bottom sensor): default, jumper open
- 0x45 (top sensor): jumper soldered
SHT31 sensor module. The ADDR jumper is visible on the top right.
I soldered the ADDR jumper on the back to change the address to 0x45.
Wiring
I connected both sensors to the J3 connector (I2C Grove) on my Reptile Monitor board.
| Grove Pin | Signal | XIAO ESP32C6 |
|---|---|---|
| Pin 1 | GND | GND |
| Pin 2 | VCC | 3.3V |
| Pin 3 | SDA | GPIO22 (D4) |
| Pin 4 | SCL | GPIO23 (D5) |
Both sensors share the same I2C bus. They have different addresses, so I can read them one by one.
Reptile Monitor board with two SHT31 sensors connected.
Note: My board has a wiring error in the Grove connector. I used a conversion cable to fix the pin order for this test. I will redesign and remake the board later.
Code
Libraries used: Adafruit SHT31 Library + Adafruit BusIO
#include <Wire.h>
#include <Adafruit_SHT31.h>
Adafruit_SHT31 sht31_bottom; // 0x44 — bottom
Adafruit_SHT31 sht31_top; // 0x45 — top
void setup() {
Serial.begin(115200);
delay(1000);
Wire.setPins(22, 23); // SDA = GPIO22, SCL = GPIO23
Wire.begin();
if (!sht31_bottom.begin(0x44)) {
Serial.println("SHT31 #1 (0x44) not found!");
while (1);
}
if (!sht31_top.begin(0x45)) {
Serial.println("SHT31 #2 (0x45) not found!");
while (1);
}
Serial.println("Reptile Monitor - Dual SHT31 Test");
}
void loop() {
float temp1 = sht31_bottom.readTemperature();
float hum1 = sht31_bottom.readHumidity();
float temp2 = sht31_top.readTemperature();
float hum2 = sht31_top.readHumidity();
Serial.println("--- Bottom (0x44) ---");
Serial.print("Temp: "); Serial.print(temp1); Serial.println(" C");
Serial.print("Hum: "); Serial.print(hum1); Serial.println(" %");
Serial.println("--- Top (0x45) ---");
Serial.print("Temp: "); Serial.print(temp2); Serial.println(" C");
Serial.print("Hum: "); Serial.print(hum2); Serial.println(" %");
Serial.println();
delay(2000);
}
Important: Wire.begin(D4, D5) does not work on the XIAO ESP32C6. I had to use Wire.setPins(22, 23) with the GPIO numbers instead.
Writing the code in Arduino IDE with XIAO_ESP32C6 selected.
Results
Normal reading
Both sensors read at the same time in room temperature:
--- Bottom (0x44) ---
Temp: 24.21 C
Hum: 32.66 %
--- Top (0x45) ---
Temp: 23.38 C
Hum: 38.42 %
The two sensors show slightly different values. This is because they are in different positions.
Both sensors output data every 2 seconds.
Touch test
I touched the bottom sensor (0x44) with my finger to check if it reacts correctly.
--- Bottom (0x44) ---
Temp: 31.46 C ← body heat
Hum: 86.47 % ← moisture from finger
--- Top (0x45) ---
Temp: 22.75 C ← no change
Hum: 39.23 % ← no change
Only the bottom sensor changed. The top sensor stayed the same. This shows that the two sensors work independently.
Touching the sensor to test its response.
Temperature and humidity jumped on the bottom sensor when I touched it.
What I Learned
- I2C lets me connect many sensors on one bus by using different addresses.
- On XIAO ESP32C6, I must use
Wire.setPins(22, 23)— notWire.begin(D4, D5). - The Grove connector on my board has a pin order error. I need to fix this in the next board revision.
Connection to Final Project
These two sensors are the core of my Smart Reptile Habitat System:
- Bottom sensor (0x44): monitors the cage temperature and humidity
- Top sensor (0x45): monitors the basking spot temperature
- I can compare both values to check the temperature gradient in the cage
- This data will control the heater and humidifier automatically
Design Files
| File | Description |
|---|---|
| sketch_mar18a.ino | Arduino sketch |