Need design ideas for temperature controller

I need to control the temperature on my bbq pit smoker. If it goes too hot, i can use a baffle to close the exhaust vent. The hotter it gets, the more I close the vent. I’ve designed and built an Arduino control that uses a thermocouple to detect the oven temperature and an rc servo to close and open the baffle as needed. I do it in 4 steps. Each time the temperature goes to a higher range, the servo closes the baffle another 25%. This is set up to maintain 225° and the servo control works perfectly.

I won’t always want to maintain 225°. Let’s say that I want to maintain 300°. How would I do that without going in and changing the code? A pot would be nice, but I have no idea how to do that. A push button that would toggle through different temperature selections would be nice too , especially if an led would indicate what range was selected. Please give me some ideas and solutions.

// *****************************************************************************
//      This program works for adjusting Servo based on temperature detected
// *****************************************************************************
#include "max6675.h"

int temp;

int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;

int Servoangle1(0);    // Radial degrees defined position - 85-100
int Servoangle2(45);   // Radial degrees defined position - 101-120
int Servoangle3(90);   // Radial degrees defined position - 121-130
int Servoangle4(135);  // Radial degrees defined position - 134-140
int Servoangle5(180);  // Radial degrees defined position - 141-150

#include <Servo.h>
Servo myservo;  // create servo object to control a servo
int pos = 100;  // variable to store the servo position

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

void setup() {
  Serial.begin(9600);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {

  //temp = (thermocouple.readFahrenheit()-9);
  temp = (thermocouple.readFahrenheit());


  if (temp <= 100) {
    myservo.write(Servoangle1);  //100% Open
    Serial.println("Temp is < 100");
  }
  Serial.println(temp);
  delay(1000);

  if (temp >= 101 & temp <= 120) {
    myservo.write(Servoangle2);  //75% Open
    Serial.println("Temp in 101-120 range");
  }
  Serial.println(temp);
  delay(1000);

  if (temp >= 121 & temp <= 130) {
    myservo.write(Servoangle3);  //50% Open
    Serial.println("Temp in 121-130 range");
  }
  Serial.println(temp);
  delay(1000);

  if (temp >= 131 & temp <= 140) {
    myservo.write(Servoangle4);  //25% Open
    Serial.println("Temp in 101-120 range");
  }
  Serial.println(temp);
  delay(1000);

  if (temp >= 141) {
    myservo.write(Servoangle5);  //0% Open
    Serial.println("Temp is > 141");
  }
  Serial.println(temp);
  delay(1000);
}type or paste code here

How many ranges, preset or continuously adjustable?
You could add an input to choose the preset range, or have a pot to vary the centre point.

For right now, let's assume that I use a pot where I would have marked off settings for 5 temperatures:
225°
250°
275°
300°
325°

How would I use a pot to do that?

Well if you tell us which arduino you are using and a diagram of what is already connected we can give more useful suggestions.
As you dont want "precise" control but rather about 5 pre-set values I'd use a 6 position switch.

Hello hightide

Welcome to the world's best Arduino forum ever.

Consider:

//https://forum.arduino.cc/t/need-design-ideas-for-temperature-controller/1196437
//https://europe1.discourse-cdn.com/arduino/original/4X/7/e/0/7e0ee1e51f1df32e30893550c85f0dd33244fb0e.jpeg
#define ProjectName "Need design ideas for temperature controller"
#define NotesOnRelease "Arduino MEGA tested"
// make names
enum Ranges {Low, LowCentre, Medium, HighCentre, High};
enum MinMax {Min, Max, MaxMin};
// make variables
constexpr uint8_t PotPin {A8};
constexpr uint8_t LedPins[] {8, 9, 10, 11, 12};
// make structures
struct READPOT
{
  const uint8_t LedPin;
  const uint8_t PotPin;
  const uint16_t Range[MaxMin];
  void makeLed()
  {
    uint16_t potIn = analogRead(PotPin);
    digitalWrite(LedPin, ((potIn >= Range[Min]) and (potIn < Range[Max])));
  }
};
READPOT readPots[] {
  {LedPins[Low], PotPin, {0 * 205, 1 * 205}},
  {LedPins[LowCentre], PotPin, {1 * 205, 2 * 205}},
  {LedPins[Medium], PotPin, {2 * 205, 3 * 205}},
  {LedPins[HighCentre], PotPin, {3 * 205, 4 * 205}},
  {LedPins[High], PotPin, {4 * 205, 5 * 205}},
};

// make support
void heartBeat(const uint8_t LedPin, uint32_t currentMillis)
{
  static bool setUp = false;
  if (setUp == false) pinMode (LedPin, OUTPUT), setUp = true;
  digitalWrite(LedPin, (currentMillis / 500) % 2);
}
// make application

void setup()
{
  Serial.begin(115200);
  Serial.print("Source: "), Serial.println(__FILE__);
  Serial.print(ProjectName), Serial.print(" - "), Serial.println(NotesOnRelease);
  for (auto LedPin : LedPins) pinMode(LedPin, OUTPUT);
  Serial.println(" =-> and off we go\n");
}
void loop()
{
  uint32_t currentMillis = millis();
  heartBeat(LED_BUILTIN, currentMillis);
  for (auto &readPot : readPots) readPot.makeLed();
}

Have a nice day and enjoy coding in C++.

Paul Paulson, I see your suggestion. I'll read it this afternoon when I get back on the project. Thank you.

As for additional information requested by others, here it is.

OK as you have plenty of free pins on the MEga, I'd use a 6 way switch. Like this

Suppose you use A0-A5. Set them as input-pullup, connect the common pin of the switch to ground.
The code on A0-A5 will then tell you which temperature has been selected.
For your application a switch is a more robust solution than a pot.

I created the circuitry needed to make the pot and LEDs work. They work as expected.

I added where I thought might be appropriate, the working code that I had for reading temperature. I used an UNO R3 board that only went up to A5, so I changed the code to reflect that. The temp wouldn't work at the serial speed you specified. It worked when I changed it to 9600. The LEDs respond a lot slower now.

When I adjust the pot, it has no effect on the temperature I'm reading. How do I make that link? Here's my code:

HighTide

Combine_programs.ino (2.96 KB)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.