Tips thermostat project

“Hello everyone, I just wanted to ask you for advice on how you would carry out this project taken from the Internet, since I tried to make it work but I found both problems in the code and in the hardware (I also have problems with the connections because looking at this site where this project is present, it is not very clear). What I want to tell you: if you could make me understand how you would carry out the project, and if you could perhaps give some examples. Also because the logical functions of this project don't make much sense. The temperatures aren't right. I don't want there to be any problems with the calculations. On the other hand, I can't understand if all the components within the project are indispensable and on the other hand I prefer to use a LED. Sorry for my difficult request, It is difficult to bring such a project to Tinkercad also because not all the components of the project are there. Try to explain everything very easily, also because I don't have good skills, do the project as if it were your own.

#include <LiquidCrystal.h>

#define LM35pin A0
#define LM35ref A1
#define thermistor_pin A3

#define btnPin1 11
#define btnPin2 12

#define relayPin 8

#define LCD_RS 2
#define LCD_EN 3
#define LCD_D4 4
#define LCD_D5 5
#define LCD_D6 6
#define LCD_D7 7

LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);

float myTemp = 26.0;

int btnState1 = 0;
int lastBtnState1 = 0;
int btnState2 = 0;
int lastBtnState2 = 0;

void setup()
{
  lcd.begin(16, 2);

  pinMode(btnPin1, INPUT);
  pinMode(btnPin2, INPUT);
  pinMode(relayPin, OUTPUT);
}

void loop()
{
  float temp2 = readLM35(true);

  lcd.setCursor(16, 0);
  lcd.print(temp2, 1);

  lcd.print("    ");

  int sensorValue = analogRead(thermistor_pin);
  float temp3  = Thermistor(sensorValue)/2;
  float temp4 = round(temp3 * 2.0) / 2.0;

  lcd.print(temp4, 1);

  btnState1 = digitalRead(btnPin1);

  if (btnState1 != lastBtnState1)
  {
    if (btnState1 == HIGH)
    {
      myTemp++;
    }
  }
  lastBtnState1 = btnState1;

  btnState2 = digitalRead(btnPin2);

  if (btnState2 != lastBtnState2)
  {
    if (btnState2 == HIGH)
    {
      myTemp--;
    }
  }
  lastBtnState2 = btnState2;

  lcd.setCursor(16,1);
  lcd.print(myTemp,1);

  lcd.print("       ");

  if(myTemp<temp2)
  {
    lcd.print("ON ");
    digitalWrite(relayPin, LOW);
  }
  else
  {
    lcd.print("OFF");
    digitalWrite(relayPin, HIGH);
  }
}

float readLM35(boolean celsius)
{
  int analogVal = 0;
  for(int j = 0; j < 10; j++)
  {
    analogVal += (analogRead(LM35pin) - analogRead(LM35ref));
    delay(10);
  }

  float tempC = (5 * analogVal * 10) / 1023;

  if (celsius)
  {
    return tempC;
  }
  else
  {
    return (tempC * 9 / 5) + 32;
  }
}

double Thermistor(int RawADC)
{
  double Temp;
  Temp = log(((10240000/RawADC) - 10000));
  Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
  Temp = Temp - 273.15;
  return Temp;
}

Welcome to the forum.

Do you want to make the project in real life or only in Tinkercad or Wokwi simulation ?
Which parts do you already have ?
Where is the origin of this project ?

Tips:

The usual advice is to do a project ONE component at a time! Then you can learn how something works and reacts. That means writing your own code, not taking a completed project and when it doesn't work as the original internet says it should, you have no where to go.
Did you ask the author of the project where the problem might be?

2 Likes

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