Integration of a temperature sensor and automatic fan control.
Project OverviewInput + Control
For this week, I worked with input devices by integrating a temperature sensor into my system.
The goal was to read environmental temperature and use that data to control an output device automatically.
I used the SHT31 temperature sensor as the input device and programmed the system so that when the temperature reaches 30°C, a fan is activated.
The SHT31 is a digital temperature and humidity sensor that communicates using the I2C protocol.
It provides accurate environmental measurements and is widely used in embedded systems.
Key characteristics
Digital communication (I2C)
High accuracy temperature readings
Fast response time
Low power consumption
In this project, only the temperature data was used to trigger the fan.
Parameter
Value
Temperature range
-40°C to 125°C
Accuracy
±0.3°C
Communication
I2C
Supply voltage
2.4V – 5.5V
ConnectionsHardware
The sensor was connected to the same PCB fabricated in Week 8.
The communication was done through the I2C interface.
Component
Connection
SHT31 VCC
3.3V
SHT31 GND
GND
SHT31 SDA
Microcontroller SDA
SHT31 SCL
Microcontroller SCL
Fan
Controlled output (transistor or driver)
The fan cannot be powered directly from the microcontroller, so it is controlled through a transistor or driver circuit.
Working PrincipleLogic
The system continuously reads temperature data from the SHT31 sensor.
Based on this reading, a decision is made:
If temperature is below 30°C → fan OFF
If temperature is 30°C or higher → fan ON
This type of system is an example of a basic control loop using an input device.
CodeEmbedded Programming
The code reads the temperature via I2C and controls a digital output connected to the fan.
The sensor is accessed through I2C using SDA and SCL pins.
The command 0x2400 triggers a temperature measurement.
Temperature Conversion
The raw sensor data is converted into Celsius using the formula:
T = -45 + 175 * (raw / 65535)
Control Logic
The program compares the measured temperature with the threshold (30°C).
If the condition is met, the fan is activated.
Loop Execution
The system runs continuously, updating every second.
ResultSystem Behavior
The final system successfully reads temperature data and controls the fan automatically.
Stable readings from the sensor
Immediate response at 30°C
Reliable switching of the fan
Final system with sensor and fan control.
Reflection
This week demonstrated how input devices can be integrated into embedded systems to create responsive behavior.
The combination of sensor data and control logic is fundamental in automation systems.
This project also shows the continuity of the design process, from PCB design to real-world functionality.
Understanding how to read sensors and react to their data is a key step toward building more complex systems,
such as smart enclosures, environmental monitoring, or automated control systems.