Control a Relay with Arduino according to the Temperature

Temperature sensor + Relay

Control a Relay with Arduino according to the Temperature

Sometimes it is necessary to check high voltage equipment (such as appliances, lights, etc.) based on values.
Today we will see how to control a Relay, which can turn on other high voltage equipment, via an Arduino card according to the temperature values.
For my tutorial I will use a Dallas Ds18b20 temperature sensor but any sensor will be fine by changing the code appropriately.

What is needed:

  •  x 1 Ds18b20 temperature sensor.
  •  x 1 Relay Module.
  •  x 1 Arduino Card whatever it is.
  •  Cables for connection.

Arduino + Temperature sensor + Relay


We connect components in this way:

  • Temp Vcc Sensor --- Arduino 5V
  • Temp GND Sensor --- Arduino GND
  • Temp Data Sensor --- Arduino Pin 2
  • Relay Vcc --- Arduino 5V
  • GND Relay --- Arduino GND
  • Signal Relay --- Arduino Pin

Arduino + Temperature sensor + Relay wiring

 Source code


The circuit and the program is very simple, hence it is possible to connect any sensor to control any equipment via the relay, such as a real time clock, you could power of a coffee machine at a specific times etc. Imagination is the limit!

If you have any questions do not hesitate to leave a comment!

And do not forget to sign up! 😇

A noob like me


Potrebbe interessarti anche:

Use a Telegram Bot to receive data from a Thingspeak channel

Show Temperate and Humidity on an OLED screen 128x64 pi