Timer

Hi!

Totally new to the Arduiono community and really need help on a project I'm working on.
I'm making a hotbox, which is basically a set of 3 heatlamps, and a fan, which are wired into a 2 way module that regulates the heat. (The link to the original author is in the code!)

I've so far been able to find code online to do what i need to a point. so far the box is able to regulate heat between 80°C and 75°C. Trouble is i need it to reset right down to around 30°C and start again after one hour of regulating, so that would then be one full cycle.

please see the code below!

#include <LCD.h>

#include <OneWire.h>

#include <DallasTemperature.h>
/*
Arduino Temperature Controller

YouTube channel: Ardutronix - YouTube

Made by Daedalus
*/

#include <Wire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#define RELAY1 4 // Relay heating
#define RELAY2 6 // Relay cooling

int red = 8; // red LED heating
int blue = 2; // blue LED cooling

#define BACKLIGHT_PIN 13
#define ONE_WIRE_BUS 7
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup() {
Serial.begin(9600);
sensors.begin();
lcd.begin(20,4);
lcd.backlight();

pinMode(red, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);

}

void loop() {
lcd.setCursor(0, 0);
lcd.print(" TEMP CONTROL");

sensors.requestTemperatures();
float temperature = sensors.getTempCByIndex(0);
lcd.setCursor(0, 2);
lcd.print(" ");
lcd.print(sensors.getTempCByIndex(0));
lcd.print("\337C");

if(temperature < 75)
{
digitalWrite(red,HIGH);
digitalWrite(blue,LOW);

lcd.setCursor(0, 3);
lcd.print(" Heating");

digitalWrite(RELAY1,0);
digitalWrite(RELAY2,1);
}
else if(temperature > 80)
{
digitalWrite(RELAY1,1);
digitalWrite(RELAY2,0);
digitalWrite(red,LOW);
digitalWrite(blue,HIGH);

lcd.setCursor(0, 4);
lcd.print(" Cooling ");
lcd.setCursor(0, 3);

}
}

Thank you and Please help!

Hello barftaid,

Welcome to the Arduino fora. I and the other people here want to help you but to do that we need certain bits of information. Without the correct information it is difficult or impossible to give you the help and advice you need. To help us to help you please read General guidance andHow to use this forum and provide the information asked for. Being new here you might think this is asking too much or having rules for the sake of rules, that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of message while we try to get you to tell us what we need in order to help you, this is frustrating for you and frustrating for us.

Common mistakes for people posting here the first time:
Code problems:
Not posting any code while expecting us to work out what is wrong with your code; we are not telepathic and can only find problems in code we can see.
Posting a snippet of code in the belief that the problem is in the code snippet. It is almost always the case that the problem is not where you think it is but elsewhere in the code, hence we need all the code.
Not correctly formatting code. Before posting code use Tools / auto format at the top of the IDE, or use control T. Once you’ve done that use edit / copy for forum.
Posting code without code tags (</>), these are explained in the instructions linked to above. Using code tags makes the code easier to read. Not using code tags means some of the code gets interpreted as HTML with the result that it is displayed with smiley faces and other stuff that should not be there.
Asking for complete code; we are not here to write code for you, we are here to help you if you get stuck writing code yourself. If you really want someone to write code for you please click on ‘report to moderator’ and ask them to move this to Gigs and Collaborations’ and indicate how much you are willing to pay.

Schematics:
The language of electronics is a schematic or circuit diagram. Long descriptions of what is connected to what are generally useless. A schematic is a drawing of what connects to what, please make one and photograph it. We don’t mind if it’s hand drawn, scruffy and does not use the correct symbols. We do mind if you don’t at least try to post a schematic. Please read How to post an image

Questions:
Not being clear about what is being asked, for example not asking a question at all or asking a vague question like ‘please help’ or some such thing.

About us:
Please also remember we are volunteers doing this for free in our spare time and are more inclined to help people who make it easy for us to provide help by providing the information we ask for.

Thank you.

Please explain the problem in more detail.

You want it to get to a temperature between 75 and 80 and maintain that for an hour? At the end of the hour what happens? It stops maintaining the temp? Does it ever start heating again? If so when?

Steve

There is no timing in your code, how does Arduino know when 1 hour has elapsed?
Code a 1 hour millis() timer, when it expires, set your temperature set point down to say, 28 ON to 32 OFF.

Hi, Sorry if it's a bit vague.

At the moment, all the arduino does is regulate between 75 & 80°C. However I need it to cut the lights, and cool the box down to say ~25°C, then start again.

I can then work out how long this all takes in real time, and calculate a cycle, which can give me reliable testing results against targets.

barftaid:
Hi, Sorry if it's a bit vague.

At the moment, all the arduino does is regulate between 75 & 80°C. However I need it to cut the lights, and cool the box down to say ~25°C, then start again.

I can then work out how long this all takes in real time, and calculate a cycle, which can give me reliable testing results against targets.

Still vague. "start again"... by itself, or by command? Immediately, or after some delay? What is the "this" that takes time?

a cycle is the box reaching between 80°C & 75°C, maintaining the temp for 1 hour, then the fan will cool the box down to ~25°C for 1 hour.

Just some background information, the box's purpose is to bake a sample material, then cool it down, and heat it up, then cool it down, etc, etc. this is so that i can see if severe temperatures have any effect on the sample material that is being tested.

my code at the moment, is only able to heat the box up to 80, and maintain between 75 and 80. however i also need the box to cool down to see what effect being subject do constant temperature changes have on the material.

is this a bit clearer for you all to understand? if not please let me know, I appreciate all your expertise.