Introduction: How to Make an Office Thermometer With DS18B20?

Picture of How to Make an Office Thermometer With DS18B20?

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

Picture of Parts Diagram

Step 3: Circuit Connection Diagram

Picture of Circuit Connection Diagram

Step 4: Operating Result

Picture of 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

Picture of 3D Assembly Drawing

Step 6: 3D Sketch Design

Picture of 3D Sketch Design

Step 7: Assemble Image

Picture of 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 #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 ( !ds.search(addr)) { //no more sensors on chain, reset search ds.reset_search(); return -1000; }

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

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

for (int i = 0; i < 9; i++) { // we need 9 bytes data[i] = ds.read(); } 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; }

Comments

Droxz (author)2017-08-12

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

About This Instructable

900views

22favorites

License:

Bio: I'm from DFRobot.com, we will often make some interesting applications and share with you all. If you have any questions, welcome to comment.
More by Jaychouu:DIY Deer ClockDIY a Formaldehyde DetectorHow to Make a Small Measuring Wheel
Add instructable to: