Programmer needed

I hope this isn't against board policy, but I am looking for someone that has the time and is willing to write a program for a project I am working on. I am not a programming minded person and while I am learning the Arduino syntax I am running short on time to complete this. Payment can be arranged if I can find the right person. Serious inquires only please.

General Scope:
All I need is a program that will compare two temperature sensors and activate 1-3 relays based on the highest temperature of the two sensors.

If you're interested email me @ jdm_usmc@hotmail.com

What kinf of temperature sensors do you have, or have in mind? Do you have all the hardware? What temperature range are you talking about? How long will the relay(s) be open? What kind of Arduino do you have? How is it, and the sensors, powered?

I think that if you post some more information that you will find people willing to provide most, if not all, of the program you need.

Temp Sensors are LM34 the temp range is between 25 to 120 degrees.
Basically the program is this

R1 turns on @25 DEGREES
R3 turns on @75 DEGREES
R2 turns on @65 DEGREES

Relays stay on untill the temp drop below the set points and I would like a 1 min delay added to keep the relays from short cycling. I have all the hardware just need the program written. The board is a arduino duemilanove

Relays stay on untill the temp drop below the set points and I would like a 1 min delay added to keep the relays from short cycling.

Where do you want the 1 minute delay? Does the relay wait to come on until the temp has been above the set point for one minute? Does it wait to go off until the temp has been below the set point for one minute? Or, does it stay on for a minimum of one minute?

What kind of relays do you have? Can they be powered by the Arduino, or do they need transistors and external power supplies?

The code you are looking for is very simple.

An analog read on a pin to get a value (the temperature), a switch statement with three cases, for the value corresponding to 25 degrees, 65 degrees, and 75 degrees, and some calls to millis to determine if the relay has been opened or closed long enough.

There are any number of people here who can do the programming for you, but you'll end up having to help a lot, anyway, to test the application, to sort out proper threshold values to toggle the relays.

We'd be happy to provide suggestions, and to critique the code, if you want to try to write it yourself.

If you don't want to, and don't get any takers, PM me.

Not to be a partypooper, but a thermostat application should be a bit more complex than a switch if it is used in industrial applications. (Or personal project if you want a certain amount of reliability).

Fuzzy logic is a big topic in this area of automation.

One quick question: Those relays, will the activation of those alter the temperature (turn on/off a heater or cooler)

As far as the thermostat operation it really is that simple. The current setup involves a head pressure variable speed controller that runs a fan based on head pressure (I'll deal with that once I can get this first part done). The parts I want to replace are 3 ambient air bulb sensors running in the following configuration fan 4 turns on @ 25 degrees fan 2 @ 75 degrees and fan 3 @ 85 degrees.
One quick question: Those relays, will the activation of those alter the temperature (turn on/off a heater or cooler) Answer No.
Where do you want the 1 minute delay? Once a new fan turns on it stays on for minimum one min before shutting off, but should not affect adding more fans.
What kind of relays do you have? Relays are 12v coils I have all the hardware setup and working.

Allright, if the operation you want is that simple:

COMPLETELY UNTESTED

//configure for your needs
const byte NUMBER_OF_RELAYS = 3;

typedef struct {
      byte pin;
      const byte targetTemperature;
      const byte onTime;
      unsigned long lastTime;
} TimedRelay;

TimedRelay relays[NUMBER_OF_RELAYS] = {
      /*pin       , target temp      ,      on time      , lastTime*/
      { 10      ,      25                  ,      30            , 0 },
      { 11      ,      75                  ,      30            , 0 },
      { 12      ,      65                  ,      30            , 0 }
};

void setup() {
      //set relays as outputs
      for (byte i=0; i<NUMBER_OF_RELAYS; i++) {
            pinMode( relays[i].pin , OUTPUT );
      }
}

void loop() {
      /*
      R1 turns on @25 DEGREES
      R3 turns on @75 DEGREES
      R2 turns on @65 DEGREES
      */
      byte temp = readTemperature();
      //check and act
      checkRelay( 0, temp );
      checkRelay( 1, temp );
      checkRelay( 2, temp );
      
      //for (byte i=0; i<NUMBER_OF_RELAYS; i++) {}
}

void checkRelay( byte relayIndex , byte temperature ) {
      //is the temperature above what is needed to trigger this relay?
      if ( (relays[relayIndex].targetTemperature <= temperature)) {
            //trigger relay
            digitalWrite(relays[relayIndex].pin,HIGH);
            //store time
            relays[relayIndex].lastTime = millis();
      } 
      //can we shut off the relay?
      else if (millis() > (relays[relayIndex].lastTime + relays[relayIndex].onTime)){
            //disable relay
            digitalWrite(relays[relayIndex].pin,LOW);
      }
}

byte readTemperature() {
      return ((readSensorA()+readSensorB())/2); //or implement your algorithm here
}

byte readSensorA() {
      return 20; //implement your algorithm here
}

byte readSensorB() {
      return 20; //implement your algorithm here
}

I'll look over it tonight and see how it works thanks for the help.

I suspect it does not work, but it might be a starting point.

I'm sure someone will think I over engineered it, and I might have, but I like to keep things easily maintainable and expandable.

I'm sure someone will think I over engineered it

I confess that was my first thought, but I can certainly see how it would be very easy to add another relay with another temperature threshold.

The modularization is nice. Each subroutine has a specific purpose, with no side effects, and its name make it very clear what it is supposed to do.

Only minimal comments are needed to describe what the application does, any how to extend it in the future is pretty easy to see.

this is what I have come up with so far... Only think really let is getting the timer to stage fans down to work.

/*
Controller
 
Arudino Duemilanove port connections:
Digital Inputs
Push button TB2 at port
Push button TEST at port 

Analog Input
LM35 temperature sensors;
TempSens1 at port
TempSens2 at port

Outputs
relay1 at port
relay2 at port
relay3 at port
relay4 at port
*/

// Pin Assignments:
const int TempSens1 = 0;    // pin to which temperature sensor 1 is attached to
const int TempSens2 = 1;    // pin to which temperature sensor 2 is attached to
const int TB2 = 2;          // pin to which TB2 button is conencted
const int TEST = 3;         // pin to which TEST button is conencted
const int Relay1 = 12;        //pin to which relay 1 is conencted
const int Relay2 =11;        //pin to which relay 2 is conencted
const int Relay3 = 10;        //pin to which relay 3 is conencted
const int Relay4 = 9;        //pin to which relay 4 is conencted

const unsigned char temp1=73;  //36 degree*10mV*1024/5V
const unsigned char temp2=82;  //40 degree*10mV*1024/5V
const unsigned char temp3=90;  //44 degree*10mV*1024/5V
const unsigned char temp4=96;  //47 degree*10mV*1024/5V

// Variables:
int TempSens1_Reading= 0;         // temperature sensor 1 reading
int TempSens2_Reading= 0;         // temperature sensor 2 reading
int TB2buttonState;             // the current reading from the input pin
int TB2lastButtonState = LOW;   // the previous reading from the input pin
long TB2lastDebounceTime = 0;  // the last time the output pin was toggled
int TESTbuttonState;             // the current reading from the input pin
int TESTlastButtonState = LOW;   // the previous reading from the input pin
long TESTlastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers
long one_minute_count1=0;
long one_minute_count2=0;
long one_minute_count3=0;

int read_TB2(){
  int reading = digitalRead(TB2);
  if (reading != TB2lastButtonState) {
    TB2lastDebounceTime = millis();
  } 
  if ((millis() - TB2lastDebounceTime) > debounceDelay) {
    TB2buttonState = reading;
  }
  TB2lastButtonState = reading;
  return TB2buttonState;
}
int read_TEST(){
  int reading = digitalRead(TEST);
  if (reading != TESTlastButtonState) {
    TESTlastDebounceTime = millis();
  } 
  if ((millis() - TESTlastDebounceTime) > debounceDelay) {
    TESTbuttonState = reading;
  }
  TESTlastButtonState = reading;
  return TESTbuttonState;
}
void setup() {

// Assign inputs and outputs
  pinMode(TB2 , INPUT);      //set TB2 pin an input pin
  pinMode(TEST , INPUT);    //set TEST pin an input pin
  pinMode(Relay1, OUTPUT);  //set Relay1 pin an ouput pin
  pinMode(Relay2, OUTPUT);  //set Relay1 pin an ouput pin
  pinMode(Relay3, OUTPUT);  //set Relay1 pin an ouput pin
  pinMode(Relay4, OUTPUT);  //set Relay1 pin an ouput pin
  digitalWrite(Relay1, LOW);
  digitalWrite(Relay2, LOW);
  digitalWrite(Relay3, LOW);
  digitalWrite(Relay4, LOW);
}

void loop() {
  while (read_TEST()==true){
  digitalWrite(Relay1, HIGH);
  digitalWrite(Relay2, HIGH);
  digitalWrite(Relay3, HIGH);
  digitalWrite(Relay4, HIGH);
  }
  
  while (read_TEST()==false && read_TB2()==false){
  digitalWrite(Relay1, LOW);
  digitalWrite(Relay2, LOW);
  digitalWrite(Relay3, LOW);
  digitalWrite(Relay4, LOW);
  }
  while (read_TEST()==false && read_TB2()==true){
    TempSens1_Reading = analogRead(TempSens1);
    TempSens2_Reading = analogRead(TempSens2);
        
    digitalWrite(Relay1, LOW);
    digitalWrite(Relay2, LOW);
    digitalWrite(Relay3, LOW);
    digitalWrite(Relay4, LOW);
    
    if (TempSens1_Reading >=temp1 || TempSens2_Reading >=temp1){  
      digitalWrite(Relay1, HIGH);
      digitalWrite(Relay2, LOW);
      digitalWrite(Relay3, LOW);
      digitalWrite(Relay4, LOW);
    }
    if (TempSens1_Reading >=temp2 || TempSens2_Reading >=temp2){  
      one_minute_count2=0;
      digitalWrite(Relay1, HIGH);
      digitalWrite(Relay2, HIGH);
      digitalWrite(Relay3, LOW);
      digitalWrite(Relay4, LOW);
    }
    if (TempSens1_Reading >=temp3 || TempSens2_Reading >=temp3){  
      
      digitalWrite(Relay1, HIGH);
      digitalWrite(Relay2, HIGH);
      digitalWrite(Relay3, HIGH);
      digitalWrite(Relay4, LOW);
      one_minute_count1=0;
    }
    if (TempSens1_Reading >=temp4 || TempSens2_Reading >=temp4){  
      digitalWrite(Relay1, HIGH);
      digitalWrite(Relay2, HIGH);
      digitalWrite(Relay3, HIGH);
      digitalWrite(Relay4, HIGH);
    }
  }
}

Only thing really left is getting the timer to stage fans down to work.

Not quite. You also need to learn the rules about posting code to the forum. There is a button on the top row with a # on it. Select all of your code, and press that button. Or press the button before you paste the code.

You could (and should) go back and modify your previous post to use the # button.

Hi

Maybe I just like to keep it simpel:

const byte relayNumbers = 3;
byte pinList[relayNumbers] = {2, 3, 4};
float tempList[relayNumbers] = {25, 75, 85};

unsigned long value = 0;
unsigned long myTime = 0;
unsigned long delayTime = 5000;          // ms before turning off, change to 60000 for 1 min delay

void setup() {
   for (byte i=0; i<relayNumbers; i++)
     pinMode(pinList[i], OUTPUT);
   Serial.begin(9600);
}

void loop() {
   if (Serial.available()) value = 0;     // This part grab the serial input
                                                      // and turn it into a number
   while (Serial.available()) {           
     char ch = Serial.read();
     if(ch >= '0' and ch <= '9')
       value = value * 10 + (ch - '0');
     delay(50);                               // quite a large part of the program ;-)
   }

   for (byte i=0; i<relayNumbers; i++) {                          //  
Let's check to see if it's turn realy on time
     if (tempList[i] <= value and digitalRead(pinList[i])==LOW)  
{          // Yep, it was
       myTime = millis();
       digitalWrite(pinList[i], HIGH);
     }
     if ((value < tempList[i]) and (millis() - myTime > delayTime))
       digitalWrite(pinList[i], LOW);     // Turn off time
   }
   delay(50);
}

Only downfall compared to the original design. The fan(s) turn off delayTime after the value goes below setpoint.

-Fletcher