0% found this document useful (0 votes)
45 views6 pages

Arduino Thermostat With 2x DS18b20 I2c 4x16 Display, 2 RGB LED's and 3 Relay's - 4 Steps - Instructables

Uploaded by

dario
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views6 pages

Arduino Thermostat With 2x DS18b20 I2c 4x16 Display, 2 RGB LED's and 3 Relay's - 4 Steps - Instructables

Uploaded by

dario
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

01/12/2024, 19:41 Arduino Thermostat With 2x DS18b20 I2c 4x16 Display, 2 RGB LED's and 3 Relay's : 4 Steps - Instructables

Arduino Thermostat With 2x DS18b20 I2c 4x16 Display, 2


RGB LED's and 3 Relay's
By Guxtdu in CircuitsArduino

Introduction: Arduino Thermostat With 2x DS18b20 I2c 4x16


Display, 2 RGB LED's and 3 Relay's

The Goal of the Project is a Thermostat for my 2 Fish Tank's with LCD Display RGB LED an Relay
to control the Heater in the Tank
an a Cooling Fan for the Big Fishtank

Parts:
Arduino Nano or equal
2x RGB LED's or RGB SMD LED or Single Color LED's
1x 2 Channel 5v Relay Modul -> for the Heater's
1x 1 Channel 5v Relay -> for Cooling Fan
2x DS18B20 1 Wire Sensor
1x 4k7 Ohm Resistor for the 1 Wire Bus
6x 220Ohm Resistor for the LED's
1x 20x4 Display with i2c Interface
Breadboard

https://www.instructables.com/Arduino-Thermostat-with-2x-DS18b20-i2c-4x16-Displa/ 1/6
01/12/2024, 19:41 Arduino Thermostat With 2x DS18b20 I2c 4x16 Display, 2 RGB LED's and 3 Relay's : 4 Steps - Instructables

Step 1: Schematic Without Relay's and Display

This is the Schematic without Display an Relay's

Step 2: Display 20x4 I2c

my Display is equal to this


http://www.sainsmart.com/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-
mega-r3.html

SDA -> Arduino A4


SDL -> Arduino A5
GND -> GND
VCC -> 5V

https://www.instructables.com/Arduino-Thermostat-with-2x-DS18b20-i2c-4x16-Displa/ 2/6
01/12/2024, 19:41 Arduino Thermostat With 2x DS18b20 I2c 4x16 Display, 2 RGB LED's and 3 Relay's : 4 Steps - Instructables

Step 3: Relay

2 Relay Modules are connected

1x Dual Channel Modul equal to this for the Heater


1x Single Channel Modul from HonKong for the Fan in the Big Tank

Rel1 -> Arduino D2


Rel2 -> Arduino D3
Rel3 -> Arduino D8
GND -> Arduino GND
VCC -> Arduino 5V

https://www.instructables.com/Arduino-Thermostat-with-2x-DS18b20-i2c-4x16-Displa/ 3/6
01/12/2024, 19:41 Arduino Thermostat With 2x DS18b20 I2c 4x16 Display, 2 RGB LED's and 3 Relay's : 4 Steps - Instructables

Step 4: The Code


#include <OneWire.h>
#include <Wire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>

//RGBLED
int bluePin1 = 10; //Digital Pin für Blaue LED1 in RGB-LED
int greenPin1 = 11; //Digital Pin für Grüne LED1 in RGB-LED
int redPin1 = 12; //Digital Pin für Rote LED1 in RGB-LED

int redIn1 = 0;
int greenIn1 = 1;
int blueIn1 = 2;

int redVal1;
int greenVal1;
int blueVal1;

int bluePin2 = 4; //Digital Pin für Blaue LED2 in RGB-LED


int greenPin2 = 5; //Digital Pin für Grüne LED2 in RGB-LED
int redPin2 = 6; //Digital Pin für Rote LED2 in RGB-LED

int redIn2 = 3;
int greenIn2 = 4;
int blueIn2 = 5;

int redVal2;
int greenVal2;
int blueVal2;

//Relays
int relPin1 = 2; //Digital Pin für Relay1
int relPin2 = 3; //Digital Pin für Relay2
int relPin3 = 8; //Digital Pin für Relay3

int relPin1In = 3;
int relPin2In = 4;
int relPin3In = 5;

int relPin1Val;
int relPin2Val;
int relPin3Val;

//Heizungs Status
int heiz1Val;
int heiz2Val;
#define BACKLIGHT_PIN 13
#define ONE_WIRE_BUS 7
LiquidCrystal_I2C lcd(0x20,20,4); // set the LCD address to 0x20 for a 20 chars and 4 line display
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup() {
Serial.begin(9600);
sensors.begin();
https://www.instructables.com/Arduino-Thermostat-with-2x-DS18b20-i2c-4x16-Displa/ 4/6
01/12/2024, 19:41 Arduino Thermostat With 2x DS18b20 I2c 4x16 Display, 2 RGB LED's and 3 Relay's : 4 Steps - Instructables

lcd.init(); // initialize the lcd


lcd.backlight();
pinMode(relPin1, OUTPUT); //Output Mode for Relay1
pinMode(relPin2, OUTPUT); //Output Mode for Relay2
pinMode(relPin3, OUTPUT); //Output Mode for Relay3
}

void loop() {
sensors.requestTemperatures();
float temperature1 = sensors.getTempCByIndex(0);
lcd.setCursor(0, 0);
lcd.print("Aquarium: ");
lcd.print(sensors.getTempCByIndex(0));
lcd.print("C");

float temperature2 = sensors.getTempCByIndex(1);


lcd.setCursor(0, 2);
lcd.print("Becken: ");
lcd.print(sensors.getTempCByIndex(1));
lcd.print("C");

//Je nach Temperatur Farbe der RGB-LED anpassen und Rel 1 schalten
if(temperature1 <= 27)
{
redVal1 = 0;
greenVal1 = 0;
blueVal1 = 150;
relPin1Val = LOW;
relPin3Val = LOW;
lcd.setCursor(0, 1);
lcd.print("Heizung ist: Ein ");
}
else if(temperature1 > 27 && temperature1 < 29)
{
redVal1 = 0;
greenVal1 = 150;
blueVal1 = 0;
relPin1Val = HIGH;
relPin3Val = LOW;
lcd.setCursor(0, 1);
lcd.print("Heizung ist: Aus ");
}
else if(temperature1 > 29)
{
redVal1 = 150;
greenVal1 = 0;
blueVal1 = 0;
relPin1Val = HIGH;
relPin3Val = HIGH;
lcd.setCursor(0, 1);
lcd.print("Lueftung ist: Ein ");
}

//Je nach Temperatur Farbe der RGB-LED anpassen und Rel 2 schalten
if(temperature2 <= 27)
{
redVal2 = 0;
greenVal2 = 0;
https://www.instructables.com/Arduino-Thermostat-with-2x-DS18b20-i2c-4x16-Displa/ 5/6
01/12/2024, 19:41 Arduino Thermostat With 2x DS18b20 I2c 4x16 Display, 2 RGB LED's and 3 Relay's : 4 Steps - Instructables

blueVal2 = 255;
relPin2Val = LOW;
lcd.setCursor(0, 3);
lcd.print("Heizung ist: Ein ");
}
else if(temperature2 > 27 && temperature2 < 29)
{
redVal2 = 0;
greenVal2 = 255;
blueVal2 = 0;
relPin2Val = HIGH;
lcd.setCursor(0, 3);
lcd.print("Heizung ist: Aus ");
}
else if(temperature2 > 29)
{
redVal2 = 255;
greenVal2 = 0;
blueVal2 = 0;
relPin2Val = HIGH;
lcd.setCursor(0, 3);
lcd.print("Lueftung ist: Ein ");
}
{
analogWrite(redPin1, redVal1);
analogWrite(greenPin1, greenVal1);
analogWrite(bluePin1, blueVal1);
analogWrite(redPin2, redVal2);
analogWrite(greenPin2, greenVal2);
analogWrite(bluePin2, blueVal2);
digitalWrite(relPin1, relPin1Val);
digitalWrite(relPin2, relPin2Val);
digitalWrite(relPin3, relPin3Val);
}
}

https://www.instructables.com/Arduino-Thermostat-with-2x-DS18b20-i2c-4x16-Displa/ 6/6

You might also like