Dear friends welcome to another tutorial!
Today we are going to learn how to use this analog voltmeter with Arduino and make it show the temperature instead of the voltage. As you can see, in this modified voltmeter, we can see the temperature in degrees Celsius. The temperature is measured by this digital sensor, a DS18B20 and it is then displayed on the voltmeter. I really like analog dials like this one, because they give a vintage look to the projects.
By building this project you are going to gain a very valuable knowledge and expererience. The knowledge to add analog dials to any Arduino project and you are going to learn how to use the PWM functionality of the Arduino.
Let’s now see how to achieve that result.
Step 1: Get All the Parts
The parts that we are going to need today are the following:
- Arduino Uno ▶ http://educ8s.tv/part/ArduinoUno
- DS18B20 Sensor ▶ http://educ8s.tv/part/DS18B20
- Analog Voltmeter ▶ http://educ8s.tv/part/AnalogVoltmeter
- 3 in 1 wires ▶ http://educ8s.tv/part/Wires
- Power Bank ▶ http://educ8s.tv/part/Powerbank
The cost of the project is around $9.
Step 2: The DS18B20 Temperature Sensor
The DS18B20 is a digital thermometer that accurately measures temperature in the range -10°C to +85°C and also includes alarm functions and trigger points.
It is a very easy sensor to use because it uses the One-Wire interface. So, we only need to connect one wire to make it work! I have used this sensor a lot in the past, and I am going to use it a lot in the future as well because of it's ease of use and accuracy.
The cost of sensor is around $2.
You can get it here ▶ http://educ8s.tv/part/DS18B20
Step 3: DC Analog Voltmeter 0-5V
This is a low cost DC analog voltmeter. It has a range from 0 to 5V DC. It is very easy to use, you simple connect the leads to a voltage source and it will display the voltage.
I find this voltmeter very useful because of its range. We can easily output any voltage from 0 to 5V from a digital pin of the Arduino using the PWM functionality. So, this way we can control the position of the needle at will! This way we can build any analog meter we like! We can build amazing projects using Voltmeters like this one.
The cost of the voltmeter is around $2.5.
You can get it here ▶ http://educ8s.tv/part/AnalogVoltmeter
Step 4: How to Control the Voltmeter With Arduino
At first let’s see how to control the voltmeter with Arduino. We connect the positive side of the Voltmeter to digital pin 9, and the negative one to GND. Since the Arduino Uno does not offer a Digital To Analog converter we have to use one of the PWM pins in order to write an analog value to a digital pin of the Arduino. Pulse Width Modulation, is a technique for getting analog results with digital means. Instead of writing HIGH to the digital pin, with PWM we send a pulse. PWM is attached to certain pins of the Arduino Uno. Those digital pins the support PWM have this symbol next to them ~.
In order to send a value to the voltmeter we use the analogWrite command and we write a value from 0 to 255. So, if we write 0, the voltmeter shows 0V and if we write 255 the voltmeter show 5V. We can write any other value between 0 and 255 the voltmeter will go to the appropriate position. So, If we want the voltmeter to show 2.5V we have to call the command analogWrite(9,128). Great! Now we can control the voltmeter needle at will!
Step 5: Building the Analog Thermometer
Let’s now convert the voltmeter to a thermometer.
First we have to connect the DS18B20 sensor. We connect the pin with the – sign to Arduino GND, the pin with the + sign to 5V and the signal pin to digital pin 2. That’s it.
Now we have to prepare panel meter. I unscrew these screws and I remove this metal plate. We then need to design our own face for it. I designed a simple one using Photoshop. Actually designing the face took me much more time than building the project itself, so in order to save your time I will attach the file in this Instructable. Now all we have to do is to print the face for the panel meter and glue it in place. If we load the code and power up the project we can see that it works fine! If I touch the sensor, the temperature rises quickly. Our analog thermometer is ready!
Step 6: The Code of the Project
Let’s now take a quick look at the code of the project in order to understand how it works.
We need the DallasTemperature library in the code to compile. Get is here: https://github.com/milesburton/Arduino-Temperature-Control-Library
The code is very simple. We first read the temperature from the sensor. Next we pass the temperature value to the temperatureToPWM function. This functions converts the temperature to a PWM value from 0 to 255 using the map function. Next, all we have to do is to write this PWM value out at the voltmeter. You can also define the maximum and the minimum temperatures that your panel meter can display by changing the values of MIN_TEMP and MAX_TEMP global variables. The smaller the gap between these two values, the bigger the resolution the panel meter will offer.
You can find the code of the project attached here. Also you can visit the project's website in order to get the latest version of the code ▶ http://educ8s.tv/arduino-analog-thermometer
Step 7: Testing the Project
As you can see, our Analog thermometer works fine! It is a very easy project to build and it also looks so cool!
I really love the looks of these analog panel meters so I am going to build a lot of projects with them. In a future video I will design and 3d print a vintage enclosure for this analog thermometer we built today. I am going use an Arduino nano to make things more compact and add some yellow diffused LEDS to illuminate the panel at night. I think it will be cool.
I would love to hear your opinion about this? Do you like analog panel meters and if yes, what kind of projects are you going to build using one of these? Please post your comments in the comments section below, and don’t forget to like this Instructable if you find it interesting. Thanks!
Billd39ET made it!