Building a Simple Smart Fan with the SMH-112DM Relay

Building a Simple Smart Fan with the SMH-112DM Relay

·

6 min read

Introduction:

In this project, we will build a simple but useful home automation device—a smart fan controller. The primary function of this system is to automatically control the fan based on the temperature of the room. If the room temperature exceeds a certain threshold, the fan will turn on, and once the temperature cools down, the fan will turn off. This project will utilize the SMH-112DM relay, a solid-state relay, to switch the fan on and off, and a temperature sensor to monitor the room's temperature. The system will be powered by a 12V DC power supply, and it will be easy to adapt for use with various types of fans.

Materials Needed:

SMH-112DM Relay (Solid-State Relay)

DHT22 Temperature and Humidity Sensor

Microcontroller (e.g., Arduino Uno or ESP32)

12V DC Fan

12V DC Power Supply

PCB or Breadboard

Jumper Wires

Resistors, Capacitors (as needed)

Transistor (e.g., 2N2222)

Diode (e.g., 1N4007)

Heat Sink for the Relay (optional)

Step 1: Understanding the SMH-112DM Relay

The SMH-112DM is a solid-state relay (SSR), which means it switches on and off using electronic components instead of mechanical parts. This makes it ideal for controlling AC or DC loads without the wear and tear of traditional mechanical relays. In this project, the relay will serve as a switch to control the fan based on signals from the microcontroller.

The SMH-112DM has a control input that requires a small current (typically from a microcontroller like an Arduino or ESP32) to activate the relay. Once the relay is activated, the fan will be powered on. Since the relay is solid-state, it provides a fast response and a long operational lifespan, which is crucial for reliability in long-term usage.

Step 2: Wiring the Components

  1. Fan and Power Supply:

● The fan operates on a 12V DC power supply, and you will need to connect the positive terminal of the 12V supply to the positive terminal of the fan. The negative terminal of the fan will be connected to the output of the SMH-112DM relay.

  1. SMH-112DM Relay:

● The SMH-112DM has three main connections: Control Input (IN), Output (Load), and Common (COM).

● The IN pin will be connected to the microcontroller's output pin that will control the relay. When this pin goes HIGH, the relay will activate.

● The COM pin will be connected to the negative terminal of the fan, and the Load pin will be connected to the negative terminal of the 12V power supply.

  1. Temperature Sensor (DHT22):

● The DHT22 temperature sensor has three pins: VCC, GND, and DATA.

● The VCC pin will be connected to the 5V pin of the microcontroller, while the GND pin will be connected to the ground. The DATA pin will be connected to a digital input pin of the microcontroller.

  1. Transistor and Diode for Fan Protection:

● Since the fan might create voltage spikes (back EMF) when it turns off, we place a flyback diode (1N4007) in parallel with the fan to protect the relay from these spikes. The cathode of the diode is connected to the positive terminal of the fan, and the anode is connected to the negative terminal of the fan.

● A transistor (such as a 2N2222) may be used to drive the relay if the microcontroller cannot supply enough current directly to the relay's input.

Step 3: Setting up the Microcontroller

  1. Configure the Temperature Sensor:

● In this project, we will use the DHT22 temperature sensor to monitor the room temperature. The DHT22 sensor communicates via a digital pin, and you can use libraries like DHT.h in the Arduino IDE to interface with the sensor. This sensor provides an accurate reading of the ambient temperature and can help control the fan based on the temperature threshold you set.

  1. Control Logic:

● The microcontroller will read the temperature data from the DHT22 sensor. Once the temperature exceeds a certain threshold (e.g., 25°C), the microcontroller will activate the SMH-112DM relay, turning on the fan.

● When the temperature drops below the threshold, the microcontroller will deactivate the relay, turning off the fan. This cycle will repeat automatically.

Step 4: Building the Circuit

  1. SMH-112DM Relay:

● Connect the IN pin of the SMH-112DM to a digital output pin on the microcontroller (e.g., pin 7). You will use this pin to control the relay.

● Connect the COM pin of the relay to the negative terminal of the fan, and the Load pin to the negative terminal of the 12V power supply.

● Ensure proper grounding for all components by connecting the ground pins of the microcontroller and the DHT22 sensor together.

  1. Temperature Sensor (DHT22):

● Connect the VCC pin to the 5V supply from the microcontroller and the GND pin to the ground.

● Connect the DATA pin of the DHT22 to a digital input pin (e.g., pin 2) on the microcontroller.

  1. Power Supply and Fan:

● Connect the positive terminal of the 12V power supply to the positive terminal of the fan. The negative terminal of the fan will be connected to the relay’s COM pin.

  1. Flyback Diode and Transistor:

● Place the diode across the fan to protect the relay from voltage spikes.

● Optionally, use a transistor to drive the relay’s control input pin if the microcontroller cannot supply enough current.

Step 5: Assembling the Components

Once the wiring is completed, ensure that all connections are secure. You can either use a breadboard for initial testing or design a PCB for a more permanent and durable solution. The microcontroller should be powered via the USB port or an external 5V power supply.

Step 6: Testing the System

  1. Upload the Code:

● Write a simple program to read the temperature from the DHT22 sensor and turn on/off the fan using the SMH-112DM relay. The code will include a temperature threshold, such as 25°C, to control the fan.

  1. Monitor the Operation:

● Once the code is uploaded to the microcontroller, monitor the fan's operation. When the temperature exceeds the set threshold, the fan should turn on. As the temperature cools down, the fan should turn off.

Conclusion

This DIY project demonstrates how to use the SMH-112DM solid-state relay in conjunction with a temperature sensor to build an automated fan control system. The system will keep your room cool by automatically turning on the fan when needed and turning it off when the temperature drops.

The use of solid-state relays like the SMH-112DM offers a durable and fast switching solution for controlling AC or DC devices. The project is highly adaptable and can be extended by integrating other sensors, controlling multiple fans, or incorporating more advanced features like Wi-Fi control for remote operation.

By following the steps outlined in this article, you’ll gain hands-on experience with relays, temperature sensors, and basic microcontroller programming. This project is perfect for those looking to create a functional and practical device for everyday use, and it’s a great addition to your growing collection of DIY electronics projects.

www.utsource.net