Make a DIY Digital Thermometer With Arduino

2022-05-21 21:19:04 By : Mr. Jacky Su

Use an Arduino, DS18B20 temperature probe, and OLED screen to create your own digital thermometer.

Building your DIY Arduino thermometer is a fun and practical way to expand your tinkering skills, but where should you get started? Join us as we delve into the wiring and coding that goes into turning an Arduino, a DS18B20 temperature probe, and an OLED display into a precise digital thermometer that can work well in rooms, fish tanks, and even outdoors.

All of these components can be found on websites like eBay and Amazon.

You can use just about any Arduino with a 5V output for this project. We're using an Arduino Pro Micro so that our finished thermometer is compact, but you can use a larger board like an Arduino Uno if you would like to avoid soldering for this project.

DS18B20 temperature sensors can be found as small stand-alone sensors, PCBs with sensors attached, or as waterproof probes on long wires. We chose the latter, as this enables us to use our thermometer inside a fish tank, but you can pick any variant of the DS18B20 temperature sensor. Unlike other types of temperature sensors, DS18B20s provide a direct-to-digital signal to your Arduino, rather than the analog signals that come from options like LM35 temperature sensors.

The display you choose for your thermometer will have a big impact on the finished product. We picked a 1.3-inch I2C-compatible monochrome white OLED display for our thermometer, but you can choose whatever you like as long as it supports I2C.

The wiring for this project is far simpler than you might imagine. Using the circuit diagram above, you can create your own DIY digital thermometer with little effort, but we've also broken the diagram down below to make it easier to follow.

Wiring your DS18B20 temperature probe correctly is vital to this project, and you need to make sure that you use the 4.7K resistor we mentioned earlier or your probe isn't going to work properly. The probe comes with three wires: Ground (usually black), VCC (usually red), and Data.

As we are using an I2C connection between our OLED display and our Arduino, we only have to connect four wires before we can start using our display: VCC, Ground, SDA, and SCL. Just about every modern Arduino has SDA and SCL pins built-in, providing the ability to connect up to 128 unique I2C components to a single board.

Our Arduino Pro Micro has SDA on digital pin 2 and SCL on digital pin 3, but you may need to look for a pinout diagram of the specific board you have chosen before you start.

It's crucial that you test the circuit you have made before you start writing the final code for it, but you can use the example projects that come with the libraries discussed below to test the circuit you have made.

Coding your DIY digital thermometer is trickier than wiring it up, but the Arduino IDE can be used for this to make it easier.

Once these libraries have been installed and included in your project, your code should look something like the snippet below. Note that we have also included code to set the pins for our components.

Once complete, this should look like the snippet below.

Before we can add code to our Display function, we need to make sure the OLED panel is initialized in our void setup function. First, we use a display.begin command to get the display started, followed by a display.clearDisplay command to make sure the display is clear.

From here, we can add code to our Display function. This starts with another display.clearDisplay command, before declaring a new integer variable with a value that calls the Temp function (we will cover this later). We are then able to use this variable to display the temperature on the display using the following code.

Like our display, our temperature probe also needs setup code to initialize the component.

Next, it's time to program the probe itself, and we need to add code to our Temp function. First, we will request the temperature from our probe, followed by recording the result as a float variable and converting it into an integer. If this process is successful, the temperature is returned to the Display function.

Finally, we just need to tell our main loop function to call our Display function with each cycle of the code, leaving us with a project that looks like this.

This project should be fun and informative, while also giving you the chance to make a practical item. We have designed this code to be as simple as possible, but you can use it as the foundation for a more complicated project as you learn.

Samuel is a UK-based technology writer with a passion for all things DIY. Having started businesses in the fields of web development and 3D printing, along with working as a writer for many years, Samuel offers a unique insight into the world of technology. Focusing mainly on DIY tech projects, he loves nothing more than sharing fun and exciting ideas that you can try at home. Outside of work, Samuel can usually be found cycling, playing PC video games, or desperately attempting to communicate with his pet crab.

Join our newsletter for tech tips, reviews, free ebooks, and exclusive deals!