OpenTherm Library for Arduino, ESP8266, and ESP32

repository·master·Indexed 43 days ago

https://github.com/ihormelnyk/opentherm_library

An implementation of the OpenTherm protocol v2.2 for Arduino, ESP8266, and ESP32 controllers. It enables remote boiler control and custom thermostat development, utilizing interrupts for stability and synchronization. Requires an OpenTherm Adapter to handle 7..15V signal levels.

Tokens
699
Snippets
2
Records
3
Agent score
5%

What's inside OpenTherm

  1. Install and use the OpenTherm library

    master

    The OpenTherm library implements the OpenTherm protocol specification v2.2 for Arduino, ESP8266, and ESP32. It allows you to control OpenTherm-compatible boilers (status, heating/water temperature, etc.) and build custom thermostats.

    To use the library, you must use an OpenTherm Adapter because the protocol uses 7..15V levels, which are higher than standard microcontroller levels. This version of the library uses interrupts to ensure stability and synchronization with the boiler.

    #include <OpenTherm.h>
    
    const int inPin = 2;  // Must support interrupts
    const int outPin = 3;
    
    OpenTherm ot(inPin, outPin);
    
    void handleInterrupt() {
        ot.handleInterrupt();
    }
    
    void setup() {
        ot.begin(handleInterrupt);
    }
    
    void loop() {
        // Example usage
        ot.setBoilerStatus(true, true, false);
        ot.setBoilerTemperature(64);
        float temperature = ot.getBoilerTemperature();
        delay(1000);
    }
  2. Configure OpenTherm pins and interrupts

    master

    To initialize the library, you must define two GPIO pins: one for input and one for output.

    Requirements:

    • The input pin must be connected to the OpenTherm Adapter and must support interrupts.
    • The output pin must be connected to the OpenTherm Adapter.
    • You must provide an interrupt handler function to the ot.begin() method to ensure proper synchronization.

    Workflow:

    1. Define pins: const int inPin = X; const int outPin = Y;
    2. Instantiate the class: OpenTherm ot(inPin, outPin);
    3. Create a handler: void handleInterrupt() { ot.handleInterrupt(); }
    4. Initialize in setup(): ot.begin(handleInterrupt);
  3. Control and monitor boiler status with OpenTherm

    master

    Once initialized, you can use the following methods to interact with the boiler. Note that according to the OpenTherm specification, the master (controller) must communicate at least once every 1 second.

    // Set/Get Boiler Status (Central Heating, Hot Water, Cooling)
    ot.setBoilerStatus(enableCentralHeating, enableHotWater, enableCooling);
    
    // Set Boiler Temperature in degrees C
    ot.setBoilerTemperature(64);
    
    // Get Boiler Temperature
    float temperature = ot.getBoilerTemperature();