Sometimes, it is necessary to add a temperature indicator into your projects. Therefore, in this tutorial you will learn how to hack your analog Voltmeter and convert into an analog Thermometer using Arduino and a DS18B20 temperature sensor.
In the first place, the Maxim DS18B20 digital thermometer provides 9-bit to 12-bit Celsius temperature measurements and has an alarm function with nonvolatile user-programmable upper and lower trigger points. Also, the DS18B20 communicates over a 1-Wire bus that by definition requires only one data line (and ground) for communication with a central microprocessor. In addition, the DS18B20 can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply.
In fact, each DS18B20 has a unique 64-bit serial code, which allows multiple DS18B20s to function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control many DS18B20s distributed over a large area.
Parts you will need
Fortunately, the circuit is so simple. At the beginning, connect the DS18b20 pin with the (-) sign to Arduino GND, the pin with (+) sign to 5V and the signal pin to digital pin 2, in order to start sensing the temperature.
Secondly, in order to control the voltmeter we connect the positive side to digital pin 9 (one of the PWM pins) and the negative to GND. Afterward, to change the labels of voltmeter to a Celsius thermometer, just download the photo in the attachments and print it out!
Pulse Width Modulation
In a nutshell, Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. Therefore, instead of writing high to the digital pin in PWM, we can send a pulse. Accordingly, some digital pins of Arduino UNO support PWM and you can recognize them by this signal (~) printed beside.