Temeratures control with outputs

Hi,

Im new here and with arduino to :) I have one question if it is possible to make program for arduino to control 3 temperature sensors on input and 3 loads on output with relays?

I have one project on work and I found arduino and I would like to try this project with him.

A have 8 pieces of heaters for hydraulic oil and all together have ca. 13kW of power. They are in 250l reservoar and will heat the oil. And I have two hydraulic pumps with 0,37kW motors. The first reservoar with heaters need to heat another oil tank throu heat exchanger. Now i have to control temperature in first and second reservoar and I have to turn on and off pumps.... First reservoar have to have 60°C and second 36°C. I would like to control contactors for two motors and one for 8 heaters.

Is this possible?

Thanke you in advance for your answers.

I have one question if it is possible to make program for arduino to control 3 temperature sensors

No. The sensor is going to do what it will. You can read them.

and 3 loads on output with relays?

Yes.

Is this possible?

Yes.

Yes, yes and yes.

The Arduino is a good platform for this if you want to be able to control it yourself. This also makes it possible to connect an LCD display or even a webpage with the temperatures.
Others have made additional libraries, like a PID control.

With such big loads, you have to know about building something like that in a safe and secure way. I hope you are experienced in that.

Sometimes a library contains an error, and with new versions of the Arduino software, something might have been changed. If you are going to build a controller yourself, I suggest to first build a safety circuit that cuts off the power if the oil gets to hot.

Since this project is limited, It is easier to buy controllers for this. Some controllers contain Arduino compatible hardware inside.

Thanke you for the answers. I would like that if temperature in tank 1 is >60°C the it has to turn heaters off and pump 1 must be on. And if the temperature is >36°C in tank 2 then it has to turn heaters off and pump 2 to and so on... And for protection if temperature of oil in tank 1 is higher then 70°C then it have to stop. I thought that i will add on digital output of arduino three relays and that relays will drive three contactors for pump 1, pump 2 and one for heaters.

To connect the heaters and motors in a safe way that wont be a problem, problem is only to program arduino controller 8)

I was looking to buy such controller but I didnt find it :~ And I would like to learn how to program with arduino so i desided to use it.

kikitron: I would like to learn how to program with arduino so i decided to use it.

Good choice. Arduino is used a lot for this sort of stuff. for solar heating and the like, and the application is quite simple. The programme runs runs in a loop checking the temperatures against fixed values.

"if temp>36 do this"

If temps is not >36, the command is ignored.

You might look at the DS18B20 temperature sensor.

http://www.ebay.com.au/itm/280989134906?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

Some versions come with a plug installed.

Yes i would like to use 3 pieces of DS18B20 and yesterday I did the project with one DS18B20 from this page with LCD 1602, and it was working :) http://www.hacktronics.com/Tutorials/arduino-digital-temperature-sensor-tutorial.html

Is there any project with DS18B20 that has in program "if temp>XX do this" ... that I can learn it from there, because I dont know where to start :~

Is it possible to use this project that I past the link and add "if temp>36 do this" or I have to start all from beginning?

You can use the project that you already have working as a basis for what you want to do. The temperature in Centigrade, or at least the non decimal part of it, is in a variable Whole and the Farenheit conversion is in FWhole. Comparing it with another value is easy.

The project reads the temperature using function getTemp and prints it using function printTemp. You could add another function that compares the temperature with set values and makes things happen. As a start try adding a new function, perhaps called tempAction called after printTemp that puts a message on the LCD if the temperature is out of range. Then you can move on to making something happen. Extending the program to read and deal with 3 sensors will be relatively easy once you understand what it is currently doing.

Thanke you for the answer. This is exactly what I need compare the temperature with set values and making things happen. I will need only temperature in centigrade without farenheit. Is there any manual with this functions that i can know how to add it?

You write your own function. Something like this :

void tempAction()
{
  if (Whole > 60)
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("High temp !");
  }
}

Look at the functions already in the program to see where to put it and how to call it. If you don't know how to do this then I seriously suggest that you work through the examples provided with the IDE. Instead of just putting a message on the LCD you will need to turn relays on/off. There are examples of how to turn LEDs on and off which is fundamentally no different than turning relays on and off.

kikitron: Yes i would like to use 3 pieces of DS18B20 and yesterday I did the project with one DS18B20 from this page with LCD 1602, and it was working :) http://www.hacktronics.com/Tutorials/arduino-digital-temperature-sensor-tutorial.html

Is it possible to use this project that I past the link and add "if temp>36 do this" or I have to start all from beginning?

I found the Hacktronics tutorial the best, and I am running three DS18B20s based on it. I just slipped the code below into the loop as a test. You can can have a command to start a pump instead of print to LCD

if ( InTemp > 30.00)
{
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("30+");
  lcd.setCursor(0,1);
  lcd.print(InTemp);
  delay(2000);
}

If you want to be fancy you could use the PID library to give this an element of smart control.

Perhaps overkill for relays, but it'll be accurate.

Library: http://playground.arduino.cc//Code/PIDLibrary

Relay implementation: http://playground.arduino.cc//Code/PIDLibraryRelayOutputExample

I found great page with arduino project that Im looking for. I will need to change some lines and add extra sensor but can you please help me to display in Celsius and not in Fahrenheit on LCD?
Is it possible to do that, because i change from: (DallasTemperature::toFahrenheit(tempC)) to (DallasTemperature::toCelsius(tempC)) and the temperature on LCD is not correct :~

A add correct addresses from DS18B20 so that is not a problem and I have pul-up resistor 4,7kohm.

The whole code is:

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int tank1BLED = 37;
int tank1GLED = 39;
int tank1RLED = 41;
int tank2BLED = 43;
int tank2GLED = 45;
int tank2RLED = 47;

// Data wire is plugged into pin 8 on the Arduino
#define ONE_WIRE_BUS 8

// Setup a oneWire instance to 
//communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// Assign the addresses of your 1-Wire temp sensors.

DeviceAddress tank2Thermometer = { 0x28, 0x46, 0x3C, 0x16, 0x03, 0x00, 0x00, 0xA9 };
DeviceAddress tank1Thermometer = { 0x28, 0xDF, 0x21, 0x16, 0x03, 0x00, 0x00, 0x1E };

int tank1 = 31; // heater control pins
int tank2 = 33; // heater control pins

float tank1temp = 0;
float tank2temp = 0;

void setup(void)
{
  // Start up the library
  sensors.begin();
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(tank1Thermometer, 10);
  sensors.setResolution(tank2Thermometer, 10);
  
  
  
  pinMode(tank1BLED, OUTPUT); // Tank LED's
  pinMode(tank1GLED, OUTPUT);
  pinMode(tank1RLED, OUTPUT);
  pinMode(tank2BLED, OUTPUT);
  pinMode(tank2GLED, OUTPUT);
  pinMode(tank2RLED, OUTPUT);
  
  digitalWrite(tank1BLED, HIGH); // set Tank LED's off
  digitalWrite(tank1GLED, HIGH);
  digitalWrite(tank1RLED, HIGH);
  digitalWrite(tank2BLED, HIGH);
  digitalWrite(tank2GLED, HIGH);
  digitalWrite(tank2RLED, HIGH);
  

lcd.begin(20,4); 
// columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.clear(); 
// start with a blank screen

pinMode(tank1, OUTPUT); // Tank heaters
pinMode(tank2, OUTPUT);

}

void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  float t1tempC = sensors.getTempC(tank1Thermometer);
  float t2tempC = sensors.getTempC(tank2Thermometer);
  if (tempC == -127.00) {
lcd.print("Error");
} else {
// lcd.print(tempC);
// lcd.print("/");
tank1temp = (DallasTemperature::toFahrenheit(t1tempC));
tank2temp = (DallasTemperature::toFahrenheit(t2tempC));
lcd.print(DallasTemperature::toFahrenheit(tempC));
  }
}

void loop(void)
{ 
  delay(2000);

  sensors.requestTemperatures();
  
lcd.setCursor(0,0);
lcd.print("Tank 1: ");

printTemperature(tank1Thermometer);

lcd.setCursor(0,1);
lcd.print("Tank 2: ");

printTemperature(tank2Thermometer);



if (tank1temp <=178.9)
{
  digitalWrite(tank1, HIGH);
  digitalWrite(tank1BLED, LOW);
  digitalWrite(tank1GLED, HIGH);
  digitalWrite(tank1RLED, HIGH);
}

if (tank1temp >= 179 && tank1temp <= 181.9)

{
  digitalWrite(tank1GLED, LOW);
  digitalWrite(tank1RLED, HIGH);
  digitalWrite(tank1BLED, HIGH);
}

if (tank1temp >= 182)
{
  digitalWrite(tank1, LOW);
  digitalWrite(tank1RLED, LOW);
  digitalWrite(tank1GLED, HIGH);
  digitalWrite(tank1BLED, HIGH);
}




if (tank2temp <=178.9)
{
  digitalWrite(tank2, HIGH);
  digitalWrite(tank2BLED, LOW);
  digitalWrite(tank2GLED, HIGH);
  digitalWrite(tank2RLED, HIGH);
}

if (tank2temp >= 179 && tank2temp <= 181.9)

{
  digitalWrite(tank2GLED, LOW);
  digitalWrite(tank2RLED, HIGH);
  digitalWrite(tank2BLED, HIGH);
}

if (tank2temp >= 182)
{
  digitalWrite(tank2, LOW);
  digitalWrite(tank2RLED, LOW);
  digitalWrite(tank2GLED, HIGH);
  digitalWrite(tank2BLED, HIGH);
}




}

Original author: http://arduinotronics.blogspot.com/2011_05_01_archive.html

Since you called getTempC() to get the temperature, you don't need to convert it to C-- you already have it!

tank1temp = t1tempC; tank2temp = t2tempC; lcd.print(tempC);

Of course it was convert option :) Thanke you @johncc

I have another question about LCD that I have it 1602. The text on it is realy hard to see (very dark), I can see it only from upper angle and on the front you cant see it. Backlight is working ok but text is realy bad. Do I have to change something in the program that the text will be lighter?

I have QUAPASS 1602A bluescreen and I think that text should be white.

Look up arduino reflow oven. there are loads of people building PID controlled ovens for SMD electronics soldering and other are using the arduino to control cooking. the same principle can be adopted for heating liquids. you will need to download the PID library, but any of the available sketches will provide what you desire.

im currently working on a test oven at work which is using a sketch i found through adafruits site.

you will need heavy relays/SCRs or even contactors to control your heating elements, look at connecting relays to arduinos. you might want to consider stirring the liquid to get an even heat, this is normal in industrial applications

the rest should be childs play

I add another ds18B20 and I can display temperature correctly, but the output “tank3” is not working with tank3temp. He is only reacting if tank2temp reaches that temperature.
What I did wrong in the code?

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int tank1BLED = 37;
int tank1GLED = 39;
int tank1RLED = 41;
int tank2BLED = 43;
int tank2GLED = 45;
int tank2RLED = 47;

// Data wire is plugged into pin 8 on the Arduino
#define ONE_WIRE_BUS 8

// Setup a oneWire instance to 
//communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// Assign the addresses of your 1-Wire temp sensors.

DeviceAddress tank1Thermometer = { 0x28, 0x87, 0x57, 0xDB, 0x02, 0x00, 0x00, 0x6F };
DeviceAddress tank2Thermometer = { 0x28, 0x12, 0xB8, 0x5F, 0x04, 0x00, 0x00, 0x86 };
DeviceAddress tank3Thermometer = { 0x28, 0x6A, 0xBD, 0x60, 0x03, 0x00, 0x00, 0xC5 };

int tank1 = 31; // pump control pins
int tank2 = 33; // pump control pins
int tank3 = 35; // pump control pins

float tank1temp = 0;
float tank2temp = 0;
float tank3temp = 0;

void setup(void)
{
  // Start up the library
  sensors.begin();
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(tank1Thermometer, 10);
  sensors.setResolution(tank2Thermometer, 10);
  sensors.setResolution(tank3Thermometer, 10);
  
  
  pinMode(tank1BLED, OUTPUT); // Tank LED's
  pinMode(tank1GLED, OUTPUT);
  pinMode(tank1RLED, OUTPUT);
  pinMode(tank2BLED, OUTPUT);
  pinMode(tank2GLED, OUTPUT);
  pinMode(tank2RLED, OUTPUT);
    
  digitalWrite(tank1BLED, HIGH); // set Tank LED's off
  digitalWrite(tank1GLED, HIGH);
  digitalWrite(tank1RLED, HIGH);
  digitalWrite(tank2BLED, HIGH);
  digitalWrite(tank2GLED, HIGH);
  digitalWrite(tank2RLED, HIGH);
  

lcd.begin(20,4); 
// columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.clear(); 
// start with a blank screen

pinMode(tank1, OUTPUT); // Tank heaters
pinMode(tank2, OUTPUT);
pinMode(tank3, OUTPUT);

}

void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  float t1tempC = sensors.getTempC(tank1Thermometer);
  float t2tempC = sensors.getTempC(tank2Thermometer);
  float t3tempC = sensors.getTempC(tank2Thermometer);
  if (tempC == -127.00) {
lcd.print("Err");
} else {
// lcd.print(tempC);
// lcd.print("/");
tank1temp = t1tempC;
tank2temp = t2tempC;
tank3temp = t3tempC;
lcd.print(tempC);
  }
}

void loop(void)
{ 
  delay(2000);

  sensors.requestTemperatures();
  
lcd.setCursor(0,0);
lcd.print("T1:");

printTemperature(tank1Thermometer);

lcd.setCursor(8,0);
lcd.print("T2:");

printTemperature(tank2Thermometer);

lcd.setCursor(0,1);
lcd.print("T3:");

printTemperature(tank3Thermometer);


if (tank1temp <= 25)
{
  digitalWrite(tank1, LOW); // pump1 ON
  digitalWrite(tank1RLED, HIGH); // read led OFF
  digitalWrite(tank1GLED, HIGH); // green led OFF
  digitalWrite(tank1BLED, HIGH); // blue led ON
}

if (tank1temp >= 26.5 && tank1temp <= 28)

{
  digitalWrite(tank1, HIGH);
  digitalWrite(tank1RLED, HIGH);
  digitalWrite(tank1GLED, HIGH);
  digitalWrite(tank1BLED, HIGH);
}

if (tank1temp >= 28)
{
  digitalWrite(tank1, LOW);
  digitalWrite(tank1RLED, HIGH);
  digitalWrite(tank1GLED, HIGH);
  digitalWrite(tank1BLED, HIGH);
}


if (tank2temp <= 25)
{
  digitalWrite(tank1, HIGH);
  digitalWrite(tank2BLED, HIGH);
  digitalWrite(tank2GLED, HIGH);
  digitalWrite(tank2RLED, HIGH);
}

if (tank2temp >= 24 && tank2temp <= 26)

{
  digitalWrite(tank2GLED, HIGH);
  digitalWrite(tank2RLED, HIGH);
  digitalWrite(tank2BLED, HIGH);
}

if (tank2temp >= 25)
{
  digitalWrite(tank1, LOW);
  digitalWrite(tank2, LOW);
  digitalWrite(tank1RLED, HIGH);
  digitalWrite(tank1GLED, HIGH);
  digitalWrite(tank1BLED, HIGH);
  digitalWrite(tank2RLED, HIGH);
  digitalWrite(tank2GLED, HIGH);
  digitalWrite(tank2BLED, HIGH);
}


if (tank3temp >= 26 && tank3temp <= 28)
{
  digitalWrite(tank3, HIGH);
}


}

The printTemperature() function is passed an address. Why is it reading that address and all 3 global addresses?

if (tank1temp <= 25)
if (tank1temp >= 26.5 && tank1temp <= 28)
if (tank1temp >= 28)

if (tank2temp <= 25)
if (tank2temp >= 24 && tank2temp <= 26)
if (tank2temp >= 25)

if (tank3temp >= 26 && tank3temp <= 28)

Your ranges are not exclusive. Is that intentional?

I dont understand what you mean. I need 3 DS18B20 sensors to control three outputs tank1,2 and 3 and leds to.
On outputs I add 5V relays with transistors BC547 and diodes 1N4007. That three relays with switch my contactors for pumps and heaters.

This is working OK:

if (tank1temp <= 25)
if (tank1temp >= 26.5 && tank1temp <= 28)
if (tank1temp >= 28)

if (tank2temp <= 25)
if (tank2temp >= 24 && tank2temp <= 26)
if (tank2temp >= 25)

But his is not working:

if (tank3temp >= 26 && tank3temp <= 28)

I dont understand what you mean. I need 3 DS18B20 sensors to control three outputs tank1,2 and 3 and leds to.

Yes, but each time you call printTemperature() for a specific address, you do not need to read all three sensors. If you are going to read all three each time, then calling the function three times does not make sense.

The function should return a value that the caller stores. There should be no references to global variables in the function.