How to Make an Office Thermometer With DS18B20?




Introduction: How to Make an Office Thermometer With DS18B20?

About: Empowering Creation for Future Innovators; Our mission is to form a community with easy access to whether hardware, software and ideas that allow makers and younger generation to achieve their goals and realiz…

How could I know environment temperature all the time in such a hot day? I called my absent friend but surprised to find that she got a cold because of cold weather and she had to monitor body temperature with a thermometer. She concerned with my health, advising me to pay attention to room temperature to keep healthy.Thinking about her words, I decide to DIY a small office thermometer with DS18B20 sensor that based on Arduino UNO to know the environment temperature.

Step 1: Hardware in Need

Step 2: Parts Diagram

Step 3: Circuit Connection Diagram

Step 4: Operating Result

When the room temperature is less than 25°C, the screen shows green. Is this temperature comforts people?

When the room temperature is more than 25°C and less than 30°C, the screen shows yellow. The color suggesting increasing temperature, you can use fan now.

When the room temperature is more than 30°C, the screen shows red. A fan means nothing to such a hot warming, only air-conditions can help you survive in the summer. I made a crust by 3D printer to protect and beatify inner parts.

Step 5: 3D Assembly Drawing

Step 6: 3D Sketch Design

Step 7: Assemble Image

If you are interested in this project, you can download 3D printing files in the end page. You can also design your own private crust.Relate to programing, you can also add time display function. So it can be a combination of thermometer and clock. Your ideas will be appreciated.

Step 8: Code


#include #include "DFRobot_RGBLCD.h" int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2 DFRobot_RGBLCD lcd(16,2); //16 characters and 2 lines of show //Temperature chip i/o OneWire ds(DS18S20_Pin); // on digital pin 2 void setup(void) { Serial.begin(9600); lcd.init(); lcd.setRGB(0, 255, 0); lcd.setCursor(1, 0 ); lcd.print("Tep: "); }

void loop(void) { float temperature = getTemp(); delay(1000); lcd.setCursor(5,0); lcd.print(temperature); if(temperature<25) { lcd.setRGB(0, 255, 0); } else if (temperature<30) { lcd.setRGB(255, 215, 0); } else { lcd.setRGB(255, 0, 0); } lcd.setCursor(10, 0 ); lcd.write(0xdf); //display° lcd.print('C'); delay(100); delay(100); //just here to slow down the output so it is easier to read } float getTemp() { //returns the temperature from one DS18S20 in DEG Celsius

byte data[12]; byte addr[8];

if ( ! { //no more sensors on chain, reset search ds.reset_search(); return -1000; }

ds.reset();; ds.write(0x44,1); // start conversion, with parasite power on at the end

byte present = ds.reset();; ds.write(0xBE); // Read Scratchpad

for (int i = 0; i < 9; i++) { // we need 9 bytes data[i] =; } ds.reset_search(); byte MSB = data[1]; byte LSB = data[0];

float tempRead = ((MSB << 8) | LSB); //using two's compliment float TemperatureSum = tempRead / 16; return TemperatureSum; }

Be the First to Share


    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • Make It Bridge

      Make It Bridge
    • For the Home Contest

      For the Home Contest



    5 years ago

    Nice and good looking one. Thanks for sharing and keep up the good work :)