Introduction: Turn an Old Thermometer in a New One Using a Temparatur Sensor (DS18B20) and LED Stripe (WS2812B)

I bought a nice old thermometer with an advertising for ice cream. This thermometer used a liquid scale for measuring the temperature. I turned this thermometer in a new one with an electronic temperature sensor (DS18B20) and a LED stripe (WS2812B) to display the temperature.

Supplies

The Thermometer

  • a thermometer
  • the larger the distance between the degrees is the better is the result of displaying the temperature
  • white acrylic glass
  • lenght and high depends on your thermometer, please read the text below

The Circuit

  • 1x arduino ESP32-WROOM-32
  • 1x socket (2 x 19 pins) for the arduino
  • 1x temperature sensor DS18B20
  • i used a sensor with cable
  • 1x LED stripe WS2812B
  • 144 led/m
  • if you want to use the thermometer outside, please use waterproof led stripe
  • lenght: exactly the distance between the lowest temperature and the highest temperature of your thermometer
  • 1x strip grid board
  • grid dimension of 2.54 mm
  • 46mm x 56mm (17dots x 21 dots)
  • stripes arranged parallel to the short side of the board
  • 1x resistor 470 Ohm (1/4 Watt)
  • 1x resistor 4,7 kOhm (1/4 Watt)
  • 2 x terminal with soldering connectors and screws
  • grid dimension of 2.54 mm
  • wire
  • cable with 3 cores
  • only needed if the board wasn´t placed near to the thermometer
  • power supply unit
  • 5V with an usb-connector for the arduino board

Other

  • double-sided adhesive tape
  • cable ties

Tools

  • soldering iron
  • soldering tin
  • drill
  • used for the interruptions of the strip grid of your board
  • depending on your thermometer you will have to need more tools

For the Sketch

Step 1: Preparing the Thermometer

The thermometer I used had a holder for the liquid scale. The scale was broken so you won't see them on the photos. If you have a thermometer with a liquid scale remove the liquid scale. I used this holder to fix my led stripe.

On the holder of the liquid scale you can mark the lowest and highest temperature as you see in the photos.

Remove the holder.

Fix the led stripe on the holder using a double-sided adhesive tape. You can cut the led stripe at the marked positions. The lenght of the led stripe depends on the distance between your highest an lowest temperatur. Be sure that there is a connector at the beginning of the stripe. The little arrows on the stripe show the sirection from inoput to output. Sometimes a stripe has two connectors - one at the beginning and one at the end!

Please count the number of led's your stripe has. In my case there were 68 leds.

I fixed the connector of the stripe additional using cable ties.

For the front I cut a piece of white acrylic glass, which I fixed in front of the LED stripe. 

As a last step the acryl glass and the holder with the led stripe have to be fixed at the thermometer.

Step 2: The Circuit and the Board

The circuit is very easy to understand. There are no special elements except the arduino and two resistor.

Circuit and board were designed with BlackBoard Circuit Designer (http://blackboard.serverpool.org), Version 1.1.3 Build 3.

For more information about the sensor DS18B20 and the led stripe WS2812B take a look at randomnerdtutorials.com

DS18B20: ESP32 DS18B20 Temperature Sensor with Arduino IDE (Single, Multiple, Web Server) | Random Nerd Tutorials

WS2812B: Guide for WS2812B Addressable RGB LED Strip with Arduino | Random Nerd Tutorials


The Circuit

The sensor DS18B20 has three connectors - power, GND and data. Data is connected to Pin GPIO 14 of the arduino. It is important that there is a pull up resistor (R2 = 4,7 kOhm) between power (3,3V) and the input (GPIO 14). Power is connected to 3,3 V and GND to GND.

The LED stripe WS2812B has also three connectors - power, GND and data. Data here is connected to Pin GPIO 13 of the arduino. A resistor has to placed between the output pin (GPIO 13) and the data pin of the stripe. Power is connected to 5 V and GND to GND.

For easier connection I used clamps.


The Board

First of all you have to interrrupt some strips at the bottom of the board. You can use a drill or a cutter. The picture of the botton of the board will show you where interruptions have to be placed.

As the next step you will have to place the wire bridges as you see in the picture. After that the two resistors have to be soldered.

Now you can soldering the clamps and the socket for the ardoino.

Put the arduino to socket and connect the sensor and the led stripe. Be careful of the correct cennection (power, data, GND).



Step 3: The Arduino

Preparing the Arduino IDE

Please look here for downloading and installing the arduino IDE: Software | Arduino

If this is the first time you use an arduino please add following URL to

FILE --> PREFERENCES --> Additional boards manager URLS:

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

Select the correct board (depending on the arduino you use)

TOOLS --> BOARD --> Select your board, e.g. "ESP 32 Dev Module"

Connect the arduino to your computer via USB

Select the correct USB-Port

TOOLS --> PORT: --> Select the port the arduino is connected to

Download the sketch and open the sketch in the arduino IDE:

FILE --> OPEN --> look for the downloaded sketch "Thermometer_LED.ino"

You will find the complete sketch on github: https://github.com/Adosis/Thermometer.git

If you have choosed the correct board and the correct port you can upload the code to the arduino.



Step 4: The Sketch

At first three librarys were included:

#include <OneWire.h>       // using more than one sensor at one port

#include <DallasTemperature.h>  // library for using the DS18B20

#include <Adafruit_NeoPixel.h>  // library for using the WS2812B-stripes

look here for the references:

OneWire - Arduino Reference

DallasTemperature - Arduino Reference

Adafruit NeoPixel - Arduino Reference


The following lines are the parameters of your thermometer

float numLed = 68;   // number of LEDs of your stripe

float lenThermo = 46; // the distance [cm] between lowest and highest temperature of your thermometer and also the lenght of your led stripe

float minTemp =(-10); // the lowest temperatur of your thermometer [°C]

float maxTemp = 40;  // the highest temerature of your thermometer [°C]


The led stripe and also the sensor were initialized

// initialize the led stripe WS2812B

#define NUMPIXELS numLed

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, pinPixel, NEO_GRB + NEO_KHZ800);

// Setup a oneWire instance to communicate with any OneWire devices

OneWire oneWire(pinTempSens);

// Pass our oneWire reference to Dallas Temperature.

DallasTemperature sensors(&oneWire);


In the setup routine the serial monitor will be set to 115200 and the sensor will be started

void setup()

{

 Serial.begin(115200); // Start the Serial Monitor

 sensors.begin();   // Start the DS18B20 sensor

}


In the loop routine the the data of the sensor are queried. I got the temperature in °C. If you want to have the information in F please change "temp = sensors.getTempCByIndex(0);" to "temp = sensors.getTempFByIndex(0)" .

As the next step all leds were turned off. To display the temperature the number of leds were calculated. There are two lines for calculating the correct led - depending where your led stripe starts. That means: shows your first led the highest or the lowest temperature?

The number of calculated leds were turned on. You can change the color of your leds in this line: pixels.setPixelColor(i,pixels.Color(255,0,0)) following the RGB-Code.

The loop starts again after 1000ms.

void loop()

{

 sensors.requestTemperatures();    // preparing the temperature sensor

 temp = sensors.getTempCByIndex(0);  // get the temperature of the sensor in °C; please use sensors.getTempFByIndex(0) for temperature in Fahrenheit


 // output on serial monitor

 Serial.print(temp); 

 Serial.println("ºC"); 


 for (int i =0; i<=numLed;i++) {pixels.setPixelColor(i,pixels.Color(0,0,0));} // turn of all LEDs 


 // example:

 // -10°C is the lowest and 40°C is the highets temperature of the scale of the used thermometer

 // the distance between -10°C and 40°C was 46cm

 // the used WS1820 has 144 LED/m or 1.44 LED/cm

 anzLed = round ((temp-minTemp)*((lenThermo/(maxTemp-minTemp))*1.44)); // calculate the number of LEDs to display the temperature

 //use this line, if led 1 of your stripe shows the highest temperatur

 for (int i = numLed; i>=numLed-anzLed;i--) {pixels.setPixelColor(i,pixels.Color(255,0,0));} // red

 //use this line, if led 1 of your stripe shows the lowest temperatur  

 //for (int i = 0; i<=anzLed;i++) {pixels.setPixelColor(i,pixels.Color(255,0,0));} // red 

 pixels.show();

 delay(1000);

}