Skip to main content

Arduino Thermostat Code Explanation:

Arduino Thermostat Code Explanation

Arduino Thermostat Code Explanation

Libraries:

  • Adafruit_LiquidCrystal: A library that extends the functionality of the standard LiquidCrystal library for LCD displays.
  • Wire: Enables communication with I2C devices.
  • Adafruit_Sensor and DHT_U: Libraries for working with the DHT temperature and humidity sensor.
  • DHT.h: Includes the main DHT library.

Pin Definitions:

  • DHTPIN: Pin to which the DHT sensor is connected (Pin 2).
  • RELAY_PIN_5 and RELAY_PIN_6: Pins to which the relays controlling the heater are connected (Pins 4 and 6, respectively).
  • DHTTYPE: Specifies the DHT sensor type (DHT11).

Variable Declarations:

  • DHT_Unified dht(DHTPIN, DHTTYPE): Creates an instance of the DHT sensor.
  • Adafruit_LiquidCrystal lcd(12, 11, 10, 9, 8, 7): Creates an instance of the LCD display.

Setup Function:

  • Initializes serial communication.
  • Sets the relay control pins as outputs.
  • Initializes the DHT sensor.
  • Initializes the LCD display with a welcome message.

Loop Function:

  • Reads the temperature from the DHT sensor.
  • Displays the temperature on the LCD.
  • Controls the relays based on temperature conditions:
    • If the temperature is below 69.8°F and relay 5 is not active, it turns on relay 5 for 4 seconds and sets relay5Active to true.
    • If the temperature is above 73°F, it turns off relay 5 after a delay.
    • If the temperature is between 73°F and 90°F and relay 6 is not active, it turns on relay 6 for 4 seconds and sets relay6Active to true.
    • If the temperature is above 73°F, it turns off relay 6 after a delay.

Wiring Instructions:

  • DHT Sensor: Connect the DHT sensor to Pin 2 on the Arduino.
  • Remote Connections:
    • Solder one wire to the on button positive terminal of the wireless remote controller circuit, and wire it to Pin 4 on the Arduino (RELAY_PIN_5).
    • Solder another wire to the off button of the wireless remote circuit, and connect it to Pin 6 on the Arduino (RELAY_PIN_6).
    • Solder one black wire to the ground of the wireless remote controller and connect it to the ground of the Arduino board.

    (IMPORTANT! The controller must have the little 12v battery inside it to operate; if the battery dies, the thermostat turns nothing on since the remote cannot send enough signal to the diesel heater wired controller unit.) (these batteries can be ordered)

    (side note: I understand this is probably not the proper way to wire this circuit, but I assure you I am no expert on doing circuitry; I am just a lowly tinkerer who needed heat to survive a freezing Michigan winter! the most affordable way possible)

  • LCD Display: Connect the LCD display to the corresponding pins on the Arduino (12, 11, 10, 9, 8, 7).
  • Power Supply: Power the Arduino using an external power supply.
  • Heater Connections: Connect the relays to the corresponding control points on your diesel heater, ensuring proper isolation and safety measures.

Remember to double-check the specifications of your relays and diesel heater to ensure compatibility with the Arduino. Additionally, take appropriate safety precautions when working with electrical components. This code is a foundation, and you might need to tweak it based on your specific hardware and usage requirements.

Comments

Popular posts from this blog

Easy Automation: DIY Diesel Heater Thermostat Free Arduino Code.

Unlocking Automation: DIY Diesel Heater Thermostat Code Revealed Welcome back to the second part of our DIY Diesel Heater Thermostat series! In this installment, we'll dive into the heart of the project—the Arduino code that transforms your heater into a smart, automated system. Feel free to explore, learn, and adapt this code to suit your needs. However, before we proceed, a stark reminder: use the code at your own risk, and I assume no responsibility for any consequences that may arise. #include < Adafruit_LiquidCrystal.h > #include < Wire.h > #include < Adafruit_Sensor.h > #include < DHT.h > #include < DHT_U.h > #define DHTPIN 2 #define RELAY_PIN_5 4 #define RELAY_PIN_6 6 #define DHTTYPE DHT11 DHT_Unified dht(DHTPIN, DHTTYPE); Adafruit_LiquidCrystal lcd(12, 11, 10, 9, 8, 7); uint32_t delayMS; bool relay5Active = false; bool relay6Active = false; void setup() { Serial.begin...

DIY Diesel Heater Thermostat: My Journey from Frustration to Arduino Innovation

DIY Diesel Heater Thermostat Solution DIY Diesel Heater Thermostat Solution Have you ever found yourself endlessly searching for a thermostat solution for your diesel heater , only to discover that the manual power button requires a prolonged press before the heater responds? I certainly did, and after hours of futile attempts and exhaustive Google and YouTube searches, I stumbled upon a single video featuring a brilliant mind who ingeniously used 12v relays and a house thermostat to automate the process. Despite the ingenuity, I craved more versatility and options for my diesel heater 's control. That's when I decided to take matters into my own hands and explore the world of Arduino . Armed with determination and a cheap Arduino kit sourced from the most budget-friendly corner of the internet, I embarked on a journey to create a thermostat solution that met my specific needs. I attempted the method showcased in...