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.
Hardware in Need:
1. DS18B20 Temperature Sensor
DS18B20 is the most common temperature sensor in the market, small, precise, and convenient to connect. After package, it is applicable to different situations. You can change exterior according to situations, such as plastic films, boilers, engine rooms, clean rooms, and even magazines.
2. Gravity: I2C 16x2 Arduino LCD with RGB Backlight Display
3. DFRduino UNO R3
DERduino UNO R3, a simple microcontroller board fully compatible with Arduino UNO R3, replaces 8U2 with ATmega16U2 as a USB-to-serial converter. The convert speed and memory space of ATmega16U2 is the same as Arduino UNO R3. This master board adopts ENIG (immersion gold), quality, delicate, and cost effective.
4. Gravity: IO Expansion Shield for Arduino V7.1
Parts Diagram
Circuit Connection Diagram
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.3D Assembly Drawing
3D Sketch Design
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.
Program:
#include <OneWire.h>
#include <Wire.h>
#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...
Read more »
Just a note, but colds aren't caused by the temperature being cold (colds are a virus), although when it's cold people tend to spend more time indoors increasing the spread of the cold virus.