Temp control system project

Hi,I have a temperature control system projevt where the temperature should be displayed on the screen when the temp is below 2o the heater is on where I use red led and when the temperature is above 30 the cooler should turn on which is the blue led I did the connection the leds are working correctly acc yo the temp but the lcd is not giving any value snd sometimes it turns off


type or paste code here
#include <LiquidCrystal_I2C.h>

// Initialize the LCD library with the I2C address and the number of columns and rows
LiquidCrystal_I2C lcd(0x27, 16, 2);  // 0x27 is the most common I2C address

// Pin definitions based on your wiring
const int tempSensorPin = A0;     // TMP36 temperature sensor connected to analog pin A0
const int redLedPin = 11;         // Red LED control pin for low temp (heater) indication
const int blueLedPin = 12;        // Blue LED control pin for high temp (cooler) indication

// Temperature limits
const float lowerTempLimit = 20.0; // Lower temperature limit for heater activation
const float upperTempLimit = 30.0; // Upper temperature limit for cooler activation

void setup() {
  lcd.begin(16, 2);               // Set up the LCD's number of columns and rows
  pinMode(redLedPin, OUTPUT);     // Set red LED pin as output (heater)
  pinMode(blueLedPin, OUTPUT);    // Set blue LED pin as output (cooler)
  digitalWrite(redLedPin, LOW);   // Initially turn off red LED
  digitalWrite(blueLedPin, LOW);  // Initially turn off blue LED

  lcd.print("Initializing...");   // Display message during setup
  delay(1000);
  lcd.clear();
}

void loop() {
  // Read the temperature from the TMP36 sensor
  int sensorValue = analogRead(tempSensorPin);
  float voltage = sensorValue * (5.0 / 1023.0);
  float temperatureC = (voltage - 0.5) * 100.0; // Convert voltage to Celsius

  // Display temperature on the LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(temperatureC);
  lcd.print(" C");

  // LED control logic based on temperature limits
  if (temperatureC < lowerTempLimit) {
    digitalWrite(redLedPin, HIGH);  // Turn on red LED (heater)
    digitalWrite(blueLedPin, LOW);  // Turn off blue LED (cooler)
    lcd.setCursor(0, 1);
    lcd.print("Heater: ON     ");
  } else if (temperatureC > upperTempLimit) {
    digitalWrite(blueLedPin, HIGH); // Turn on blue LED (cooler)
    digitalWrite(redLedPin, LOW);   // Turn off red LED (heater)
    lcd.setCursor(0, 1);
    lcd.print("Cooler: ON     ");
  } else {
    digitalWrite(redLedPin, LOW);   // Turn off red LED (heater)
    digitalWrite(blueLedPin, LOW);  // Turn off blue LED (cooler)
    lcd.setCursor(0, 1);
    lcd.print("System: Stable ");
  }

  delay(1000); // Delay for readability
}
  • Always show us a good schematic of your proposed circuit.

  • Show us good images of your ‘actual’ wiring.

  • In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.
    Use the < CODE / > icon from the ‘posting menu’ to attach the copied sketch.

I'm having issues with my crystal ball at the moment. Perhaps it would be a good idea to post your code and a schematic of how you have connected the various parts of your project together...

Ok I add the photos and code

  • Why is there a resistor on the LCD display GND lead. :thinking:

Should I remove it

It is my first time of making arduino circuit

  • Replace it with a wire.

Ok I will do this

Thank u it worked I changed the code

@batoolm Does it work just like it did in TinkerCAD?
Isn't it more fun with real hardware? Satisfying.

Hello batoolm

delete

 lcd.begin(16, 2);  

and insert

  lcd.init();
  lcd.backlight();

hth

Yes of cource on tinkercad it’s more difficult and it need a lot of component and wires

I want to ask if it is ok not to put resistor to the lcd screen?

I tried that also so I add a different code

You should not have any resistors connected to the LCD.
Did you get your LCD working?

Yes it worked when I remove the resistor, Thank u.
I want to ask something also, can I connect this switch to the arduino board


Also I tried to connect my project with 9V battery but it is not working although it is a new full battery

Of course you can. You would need to either solder wires to it or buy something like below. I say it's time to learn to solder.

Measure the battery voltage while connected. My guess is it dropped below 7V.
Do you have a multimeter to measure voltage? I say it's time to get one

A soldering iron, multimeter and a few hand tools are the basic tools necessary for most any project. It's very difficult to do much without them.

Ok thank you so much,unfortunately I don’t have a multimeter but I add the switch by ysing wites and electric tape .
I want to ask you can I use a power supply directly using 12V power charge?

For what you are doing, Yes. That is much better than the battery.

I'll come back and explain more on this later.