This tutorial was written by Ron as a guest post – check out more of his work on the Visuino website.
In this tutorial we will learn how to Display a temperature using a servo motor as a gauge and a DHT sensor connected to the Arduino board.
Watch the Video!
Table of Contents
Step 1: What You Will Need
- DHT11 sensor or any other DHT sensor
- Arduino UNO (or any other board)
- Servo motor
- Jumper wires
- Printed Gauge image
- Visuino program: Download Visuino
Step 2: The Circuit
You are learning how to use Arduino to build your own projects?
Check out Arduino For Beginners and learn step by step.
- Connect Servo motor “Orange” (signal) pin to Arduino Digital pin[3]
- Connect Servo motor “Red” pin to Arduino positive pin[5V]
- Connect Servo motor “Brown” pin to Arduino negative pin[GND]
- Connect DHT11 positive pin + (VCC) to Arduino pin +5V
- Connect DHT11 negative pin – (GND) to Arduino pin GND
- Connect DHT11 pin (Out) to Arduino digital pin (2)
Step 3: Making of the Servo Motor Gauge
- Print the attached Gauge picture.
- Attach the picture with some glue to the servo motor, to make it stronger you can use some small carton board at the back.
Step 4: Download Visuino Software
Visuino is a Visual programming tool for Arduino and other boards.
You can easily make a project by simply Drag & Drop components and connecting them.
Go to https://www.visuino.eu and Download Free version or register for a Free Trial.
Step 5: Start Visuino, and Select the Arduino UNO Board Type
Start Visuino as shown in the first picture. Click on the “Tools” button on the Arduino component (Picture 1) in Visuino. When the dialog appears, select “Arduino UNO” as shown on Picture 2.
Step 6: In Visuino Add, Set & Connect Components
- Add “DHT11” component
- Add “Map Range Analog” component
- Add “Subtract From Analog Value” component
- Add “Servo” component
If you select “HumidityThermometer1″ component you can select different DHT type sensors in the properties window (see the picture).
“Subtract From Analog Value” component will be used to reverse the direction of the servo rotating, so instead of rotating it from right to left we want to rotate it from left to right like a real gauge meter.
“Map Range Analog” component is used where we want to convert one range of values to another range of values, in our example we get temp values from the DHT11 sensor that can be from -30 to +60 but the servo motor input value can only be between 0 and 1 like (0.1 , 0.345, etc), so the “Map Range Analog” component will adjust this values for us.
- Select “MapRange1” and in the properties window set “Input Range” Max to 40 and Min to 0
This means that we want to display a temperature between 0 and 40 C.
- Connect “HumidityThermometer1” pin [Sensor] to Arduino board digital pin[2]
- Connect “HumidityThermometer1” pin [Temperature] to “MapRange1″pin[In]
- Connect “MapRange1” pin [Out] to “SubtractFromValue1” pin [In]
- Connect “SubtractFromValue1” pin [Out] to “Servo1” pin[In]
- Connect “Servo1” pin [Out] to Arduino board digital pin [3]
Step 7: Generate, Compile, and Upload the Arduino Code
In Visuino, at the bottom click on the “Build” Tab, make sure the correct port is selected, then click on the “Compile/Build and Upload” button.
Step 8: Play
If you power the Arduino module, The servo motor will rotate according to the temperature.
Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this tutorial, you can download it and open it in Visuino: https://www.visuino.eu
Download Visuino File here: servo-temp