Skip to content

Room Temp on Custom Gauge

RoomTempGauge We recently made a product and got it up for sale on Tindie.  This article is a kind of quick start for the ServoGauge Proto.

The general idea here is to monitor the temperature of my home office with high resolution. The temperature here is controlled and is not going to change very much. A typical temperature gauge would cover a large range of values, like 0 to 100C which would not be interesting here.

Enter the ServoGauge Proto.  Now I can easily have a custom range for the temperature gauge.  My gauge is set to work over just 10 degrees, 69 to 79 degrees Fahrenheit

For the project I used the following parts.  Follow the links for more information on each.

Item Info Link Description
Arduino Nano link Should work with any Arduino,
without code changes
ServoGauge Proto link Optional, You can just watch readings
on serial or build your own gauge
Debug Serial link Optional, just use the normal serial
terminal in the IDE if you wish.
DS18B20 link  Dallas Semiconductor temperature sensor
You can substitute any kind of sensor and
create a custom scale for it
Available at Amazon
TO92 package (here)
sealed probe (here)
Servo Library link  Standard library included with the
Arduino IDE
OneWire Library link  Standard library included with the Arduino IDE


Source Code
The Arduino Source and printable Gauge scale for this project are on the uCHobby GITHub.

Making a Scale for the Gauge
The source package includes a PDF of the gauges used on this project. If you print that PDF check the scaling is correct, the outer border is exactly 3×5 inches. You might have to adjust scaling in your printer preferences to get it printed correctly.

Once you have the scale printed, cut it out and slip it into the ServoGauge Proto. It will be a bit tight as we do not want the scale to move once it’s in. There are some cutouts on the back to help you move it with fingertips. I have to wet mine to get them to stick to the paper.

If it’s too tight, you can slip off the stand parts and loosen the servo mounting screws. Just a bit is all you will need.

Making a Custom Scale
The source package includes a Corel Draw and a SVG template file. The SVG file should work fine in the free Inkscape CAD tool.  Let me know if you have trouble as I use Corel for all my work.

Connecting the Gauge
From the perspective of the Arduino the gauge is simply a servo. There are three signals to connect, +5, Ground, and PWM.  The gauge has a three pin servo connector which might mate directly with a connector on your board.

If you are using a standard Arduino or a breadboard as we did here, a great way to make this work is with a long pin header. Push one end into the servo connector then push that into the breadboard.  You can just use the normal jumper wires to push into the servo connector then into the sockets on your Arduino or the breadboard.

Making the code drive the gauge
Code for this project is in the firmware directory and should work with any Arduino board.

The key parts of this example are setting up the sensor, setting up the servo lib, then reading the sensor, converting the values then setting the servo output so the gauge moves into place.

Code for the DS18B20
I created several functions to take care of the temperature sensor each is described below. My code is based on the OneWire example and the part datasheet.

  • DS18B20Find
    Searches the BUS to find any device, then checks that it’s the sensor we need.
  • DS18B20StartConversion
    Triggers a conversion on the device, this takes a while, we wait 1 second before we read.
  • DS18B20ReadData
    Reads the data package from the device. This is a bunch of bites stored in an array to be processed later.
  • DS18B20GetTemperature
    Gets the temperature in degrees C from the device, uses the data read function above to keep it simple.

Code for the Gauge
The gauge is easy to deal with. I prefer to send it microsecond values rather then the 0-255 that an analogWrite function would so I use the Servo Library. The magic bit is the map function around line 45.


This line of code converts the Fahrenheit value into the microseconds to send to the servo to move the needle into place.

The function only works with integers so we have to scale up our floating point value. Notice that we start by multiplying our temp by 100, then we use 6900 and 7900 as the min and max for the input side of the map function.  This gives us a range of 69 to 79F with a 0.01 resolution.

That range is then mapped to the servo’s min and max microseconds. The result is what we need to send to the servo. That’s it.  The gauge will now show the reading.

Posted in Uncategorized.