Help with code

Hi,
I’m new to arduino. I have a sketch that reads temp from a one wire DS18D20 Waterproof Temp sensor. (The code is below). I will be monitoring temperature of beer when I brew it. When the beer reaches 160F I want the arduino to start an internal time for 60 minutes. After 60 minutes I want the arduino to turn on a digital out to activate a really that will open a solenoid valve. Hold the DI on for about 5 minutes. That way when the beer reaches temp it will automatically start a timer and then transfer the beer to the next stage automatically. Eventually I want to add more tasks but for now just monitor temp and when it reaches 160F start a timer (wait) 60 minutes then turn on digital out.

#include <OneWire.h>

#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);

 DallasTemperature sensors(&oneWire);

DeviceAddress AddThermometer;

 void setup(void)

{

  Serial.begin(9600);

  Serial.print("Locating devices...");

  sensors.begin();

  Serial.print("Found ");

  Serial.print(sensors.getDeviceCount(), DEC);

  Serial.println(" devices.");

 

  Serial.print("Parasite power is: "); 

  if (sensors.isParasitePowerMode()) Serial.println("ON");

  else Serial.println("OFF");

   

  if (!sensors.getAddress(AddThermometer, 0))   Serial.println("Unable to find address for Device 0"); 

 

  Serial.print("Device 0 Address: ");

  printAddress(AddThermometer);

  Serial.println();

 

  sensors.setResolution(AddThermometer, 9);

  

  Serial.print("Device 0 Resolution: ");

  Serial.print(sensors.getResolution(AddThermometer), DEC); 

  Serial.println();

}

 

void printTemperature(DeviceAddress deviceAddress)

{

 

  float tempC = sensors.getTempC(deviceAddress);

  Serial.print("Temp C: ");

  Serial.print(tempC);

  Serial.print(" Temp F: ");

  Serial.println(DallasTemperature::toFahrenheit(tempC)); 

}

 void loop(void)

{ 

  Serial.print("Requesting temperatures...");

  sensors.requestTemperatures(); 

  Serial.println("DONE");

   

  printTemperature(insideThermometer);

}

 
void printAddress(DeviceAddress deviceAddress)

{

  for (uint8_t i = 0; i < 8; i++)

  {

    if (deviceAddress < 16) Serial.print("0");

    Serial.print(deviceAddress, HEX);

  }

First off, please modify your post and use the code button </>

so your code looks like this

and is easy to copy to a text editor. See How to use the Forum Your code is too long for me to study quickly without copying to a text editor.

Also please use the AutoFormat tool in the IDE to indent the code properly before posting.

And when you have done that please tell us what your program actually does and what you want it to do that is different.

…R

You want the relay to turn on at what temperature ? Rising or falling? How long a time delay? At what temperature should the relay turn back off?

I want to relay to turn on at 160F. I will be monitoring the temp of beer on a stove burner. When it reaches 160F I want to start a timer for 60 minutes then activate a really that will apply power to a solenoid valve and allow the beer to flow to the next stage.

ndralle: I want to relay to turn on at 160F. I will be monitoring the temp of beer on a stove burner. When it reaches 160F I want to start a timer for 60 minutes then activate a really that will apply power to a solenoid valve and allow the beer to flow to the next stage.

So, you heat the beer for 60 minutes, then open a valve and drain the pot. Then, you continue to boil the empty pot until it scorches and is ruined.

Then, what? Burn the house down?

You need to read, and respond to, ALL of the questions.

No I manually turn of the burner.

ndralle: No I manually turn of the burner.

What if you are not there at the end of 60 minutes ?

If you [u]can[/u] guarantee being there at the right time then why do you need an Arduino to empty the container ?