How To Control Your Actuator Using an Arduino With a Digital Temperature and Humidity Sensor

How To Control Your Actuator Using an Arduino With a Digital Temperature and Humidity Sensor

Guest Writer
Guest Writer
PA Engineer

A linear actuator that is controlled with a temperature and humidity sensor has many prime applications. For example, one practical application would be to set up aquaponics and hydroponics where the humidity needs to be controlled – the sensor would detect when the temperature and humidity reach a certain threshold and automatically open/close a door using a linear actuator. This project is a fun activity for novice programmers or hobbyists who would like to learn the basics of Arduino coding to control a linear actuator.

Browse our range of linear actuators to find your perfect application match!

This article is part of a series by Progressive Automations, which focuses on equipping you with the knowledge needed to use linear actuators, microcontrollers, and sensors in your next automation project. Would you like to control a linear actuator using a simple keypad or something more advanced like multiple ultra-sonic sensors to detect nearby movement? We have got you covered! This articles takes you through how to pair the right temperature sensor with an actuator, and how this sensor operates. Lets get started!

Using linear actuators with microcontrollers, and sensors

 

What Is a Digital Temperature and Humidity Sensor?

A digital temperature and humidity sensor is a basic, ultra-low-cost sensor, which can be used to sense temperature and humidity in the surrounding air. The LC-226 temperature and humidity sensor from Progressive Automations uses a capacitive humidity sensor and a thermistor to output signals which a microcontroller can read.

The humidity sensing component is a moisture-holding substrate with electrodes applied to the surface. When water vapor is absorbed by the substrate from the surrounding air, ions are released by the substrate, which increases the conductivity between the electrodes. The change in resistance between the two electrodes is proportional to the relative humidity. Thus, a higher relative humidity decreases the resistance between the electrodes, while lowering the relative humidity increases the resistance.

Digital Temperature & Humidity Sensor for Arduino

 

The LC-226 can be powered with a 5 VDC source and has the following temperature and humidity specifications:

  • Humidity measurement range: 20% - 90% (relative humidity)
  • Humidity measurement error: +5% (relative humidity)
  • Temperature measurement range: 0 – 50°C
  • Temperature measurement error: +2°C

Learn More About Our Digital Temperature and Humidity Sensor!

What You Will Need

Let us go over how you can link a temperature sensor with an actuator for any application you choose. Here is a list of what you will need: 

Any linear actuator can be used, but be sure the power supply is rated for the voltage and current draw of the linear actuator and can handle the power requirements when under load.

 

Wiring

Wiring a linear actuator to a relay is simple. In this case, we have used a 2-channel relay board. The wiring consists of four steps: actuator to relay, sensor to Arduino, relay to power supply, and actuator to relay.

Be aware that a remote temperature and humidity sensor with an actuator set up in a humid environment should have its controller adequately protected or installed outside the setup. The sensor is designed to handle humidity, but your Arduino controller is not. IP-rated casings are available for the Arduino for these applications. Alternatively, run cables from your outside controller to the humidity sensor located inside, where the temperature and humidity are read.

 

Arduino Uno

 

Step 1: Arduino to Relay

  • Arduino (Pin 7) to Relay (IN1)
  • Arduino (Pin 8) to Relay (IN2)
  • Arduino (5V) to Relay (VCC)
  • Arduino (GND) to Relay (GND)

 

Step 2: Temperature and Humidity Sensor to Arduino

  • Sensor (+) to Arduino (5V)
  • Sensor (-) to Arduino (GND)
  • Sensor (OUT) to Arduino (Pin 2)

 

Step 3: Relay to Power Supply

  • Relay (NO2) to Power Supply (-12VDC/GND)
  • Relay (NC2) to Power Supply (+12VDC)
  • Relay (NC1) to Relay (NC2)
  • Relay (NO1) to Relay (NO2)

 

Step 4: Actuator to Relay

  • Actuator (Positive) to Relay (COM1)
  • Actuator (Negative) to Relay (COM2)
Actuator to relay and microcontroller wiring diagram

 

Check out our range of Arduino microcontrollers for ultimate actuator control!

Programming the Arduino

To use the temperature sensor with an actuator, download the DHT library from within the Arduino IDE. This library will enable the use of short commands to retrieve a reading for the humidity or temperature. Once the DHT library has been downloaded, add the following code to a new project: Temperature and Humidity Controlled Linear Actuator Code.

All code before the void setup() loop sets up the pin configuration based on your wiring and includes the DHT library setup. If you decide to use a different Arduino model, match the pin numbers with the code. Moreover, you can set the temperature values for when the actuator should open or close (open_door_temp and close_door_temp). Initially, set the values closer to room temperature so that you can test if the code works by simply using a hairdryer or other heat source to reach the activation temperature.

The void setup() code loop sets the relay configuration as outputs and ensures they are deactivated when first powered up. The serial monitor is also initialised, assuming you have the Arduino connected via USB to a laptop/desktop for initial testing.

The main code loop takes readings from the sensor using the commands dht.readHumidity(), dht.readTemperature(), and dht.readTemperature(true) and stores those values in a float variable to be used for some conversions. The values are converted to Celsius and Fahrenheit and are printed to the Arduino’s Serial Monitor.

Lastly, these readings are compared with the threshold temperature values to determine if the linear actuator should open or close. The relays are set to high accordingly, else, the actuator remains stationary, and the Arduino continues to monitor the temperature and humidity readings.

 

Conclusion

Using a temperature sensor with an actuator is a great way to learn how to program an Arduino, and has proven to be a very useful application addition. You may also find various other applications besides aquaponics and hydroponics to add this sensor to! Although we showed you how to control a 12VDC linear actuator, nothing is stopping you from using an industrial, high-powered linear actuator for more demanding applications – just be sure to match the power supply with the linear actuator.

If you have any queries or comments regarding this article, or any of our products, don’t hesitate in contacting us!

Please wait...

...