A temperature controller can be found anywhere in the market at low cost. However we can create it one using an analog circuit, or even a programmable device. Here I create an Arduino-based temperature controller using some components:
- An Arduino Uno board
- A DS18B20 temperature sensor
- A 5V relay module
- A character LCD with some other components and accessary.
Circuit prototyping on breadboard |
The controller request and get temperature data from DS18B20 in degree Celsius. The display show either Celsius and degree Fahrenheit. It updates the data for every 5 seconds. I set in program for a condition for the temperature above 30 degree Celsius. Whenever it's true an output relay connects to pin 13 will turn on.
Schematic Diagram |
I use DallasTemperature.h file due to its simplicity.
#include <OneWire.h> #include <DallasTemperature.h> #include <LiquidCrystal.h> //LCD Connection RS EN D4...D7 LiquidCrystal lcd(7,8,9,10,11,12); OneWire oneWire(4); DallasTemperature sensors(&oneWire); //Relay Output Pin const int relay=13; void setup(){ pinMode(relay,OUTPUT); //Start up the 1-Wire Library sensors.begin(); lcd.begin(16,2); lcd.print("ds18B20 Example"); delay(3000); lcd.clear(); } float getC,getF; void loop(){ //Send the command to get Temperature sensors.requestTemperatures(); getC=sensors.getTempCByIndex(0); getF=DallasTemperature::toFahrenheit(getC); if(int(getC)>=30) digitalWrite(relay,HIGH); else digitalWrite(relay,LOW); lcd.home(); lcd.print("Temperature: "); lcd.setCursor(0,1); lcd.print(String(getC,1)+char(223)+"C"+" "+String(getF,1)+char(223)+"F"); delay(5000); }
Click here to download its source file.
No comments:
Post a Comment