Climate Control with Arduino Nano for a Peugeot 406 !
My friend's car had a cabin air temperature sensor malfunction and the A/C unit kept the compressor on all the time ! That is bad for fuel economy and freezes everything in the car when outside temperature is not that high , so this is a quick 1-day project we did to control the A/C compressor according to the cabin temperature.
Simply put , a sensor reads the air temperature and turns off the A/C compressor when a set temperature("Set Temp") is reached , it turns the compressor back on if the sensor reads a temperature that is more than two degrees higher than the "Set Temp" . The set temperature is set using two push buttons (Up/Down) . At the heart of the system is an Arduino Nano which controls a relay which in turn controls the A/C compressor.
![]() |
| Welcome message on the LCD display ! |
![]() |
| Loads of hot glue of course ! :D |
![]() |
| Quick and dirty circuit ! |
![]() |
| No custom PCBs for 1-day projects xD |
![]() |
| Up/Down Buttons |
![]() |
| Hides nicely in a comfy spot :P |
Watch the video to see it in action !
Below is the electronic diagram of this system. You can download it here as a PDF
The arduino nano receives power from an L7805 linear voltage regulator which regulates the 14V from the car to 5V .The regulator is not on a heatsink because the whole thing uses less than 150mA. The TIP120 darlington transistor controls the 12V relay which controls the A/C compressor. A diode is used to protect the transistor from back EMF. Three digital pins are pulled down to GND by 680 Ohm resistors , they are used as buttons for Up Down and Menu. When any button pin is connected to 3.3V, the pin reads a logical high, and the arduino senses a button press.
That's basically it for the electronics !
Down below is the code that controls the whole thing. Download the code here
// By Kushantha Weragama
// License Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
#include <dht.h> // DHT11 Temperature and Humidity Sensor Library
dht DHT;
#include <LiquidCrystal_I2C.h> // LCD Library (Using 16x2 Dot-Matrix LCD)
#include <Wire.h> //I2C Library
const int up = 3; // Set temp UP (D3)
const int down = 4; //Set temp DOWN (D4)
int upbtn; // Button for Temp Up
int downbtn; // Button for Temp Down
int settemp = 24; // Pre-Set Starting temperature , system starts with this value
int setdiff = 1; // Pre-Set difference , in this case 1 degrees celcius
int difference; // Difference the temperature should have to trigger the Relay
#define DHT11_PIN 7 // DHT11 Sensor is connected to D7
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C LCD Address
void setup(){
lcd.init(); //Initialize the LCD
lcd.backlight(); //Turn on Backlight
pinMode(LED_BUILTIN, OUTPUT); // On-Board LED shows the A/C relay status
pinMode(2, OUTPUT); // This pin is connected to the base of the relay driving transistor
lcd.setCursor(0, 0); // Cursor is now at the start of row 1
lcd.print(" <<PEUGEOT 406>>"); // Prints Welcome Message
lcd.setCursor(0, 1); // Cursor is now at the start of row 2
lcd.print(" CLIMATE CONTROL");// Prints Welcome Message
delay(2000); // Show Welcome Message for 2 Seconds
lcd.clear(); //Clear everything on the LCD
}
void loop(){
int chk = DHT.read11(DHT11_PIN); //Read DHT11 Sensor Value
lcd.setCursor(0, 0); //Cursor is now at the start of row 1
lcd.print("Temp = "); //Prints "Temp = " on LCD
lcd.print(DHT.temperature); // Prints the current temperature reading from sensor
lcd.print("C"); //Prints "C" on LCD
lcd.setCursor(0, 1); //Cursor is now at the start of row 2
lcd.print("Set="); //Prints "Set=" on LCD
lcd.print(settemp); //Prints the current set temperature on LCD
lcd.print("C"); //Prints "C" on LCD
difference = (settemp+setdiff);
if (DHT.temperature > difference){ //If sensor detects higher temp than set temp , A/C is ON
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(2 , HIGH); // Transistor base gets 3.3V , activates the A/C relay
lcd.print(" AC ON");
}
else if (DHT.temperature <= settemp){ //If sensor detects lower temp than or equal reading to set temp , A/C is OFF
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(2 , LOW); // Transistor base gets 0V , de-activates the A/C relay
lcd.print(" AC OFF");
}
upbtn = digitalRead(up); // Read logic level of Up button pin D3
if (upbtn == HIGH){
settemp=(settemp+1); // Adds 1 to set temperature
}
downbtn = digitalRead(down); // Read logic level of Down button pin D3
if (downbtn == HIGH){
settemp=(settemp-1); // Substract 1 from set temperature
}
delay(1000); // Arduino reads the sensor, updates the display and looks for button presses every second
}






Comments
Post a Comment