OpenTherm Arduino Library

OpenTherm Library is based on OpenTherm protocol specification v2.2 and works with all OpenTherm compatible boilers. Library can be easily installed into Arduino IDE and compiled for Arduino, ESP8266 and other similar controllers. OpenTherm protocol requires simple low voltage twowire connection to boiler, but voltage levels (7..15V) still much higher than Arduino/ESP8266 levels, which requires OpenTherm Adapter.

This version of library uses interrupts to achieve better stability and synchronization with boiler. For educational puprouses and to get better undestanding of OpenTherm protocol there is OpenTherm Controller based on simple sketch implemented using delays. So if you want control and integrate your boiler into home automation system, without proprietary thermostats, this library for you.

Installation:

Also you can find souce code of Arduino OpenTherm Library on GitHub

Configuration and Usage:

Full Sample:

#include <Arduino.h>
#include <OpenTherm.h>
const int inPin = 2; //4
const int outPin = 3; //5
OpenTherm ot(inPin, outPin);
void ICACHE_RAM_ATTR handleInterrupt() {
	ot.handleInterrupt();
}
void setup()
{
	Serial.begin(115200);
	Serial.println("Start");
	
	ot.begin(handleInterrupt);
}
void loop()
{	
	//Set/Get Boiler Status
	bool enableCentralHeating = true;
	bool enableHotWater = true;
	bool enableCooling = false;
	unsigned long response = ot.setBoilerStatus(enableCentralHeating, enableHotWater, enableCooling);
	OpenThermResponseStatus responseStatus = ot.getLastResponseStatus();
	if (responseStatus == OpenThermResponseStatus::SUCCESS) {		
		Serial.println("Central Heating: " + 
            String(ot.isCentralHeatingActive(response) ? "on" : "off"));
		Serial.println("Hot Water: " + 
            String(ot.isHotWaterActive(response) ? "on" : "off"));
		Serial.println("Flame: " + 
            String(ot.isFlameOn(response) ? "on" : "off"));
	}
	if (responseStatus == OpenThermResponseStatus::NONE) {
		Serial.println("Error: OpenTherm is not initialized");
	}
	else if (responseStatus == OpenThermResponseStatus::INVALID) {
		Serial.println("Error: Invalid response " + String(response, HEX));
	}
	else if (responseStatus == OpenThermResponseStatus::TIMEOUT) {
		Serial.println("Error: Response timeout");
	}
	//Set Boiler Temperature to 64 degrees C
	ot.setBoilerTemperature(64);
	//Get Boiler Temperature
	float temperature = ot.getBoilerTemperature();
	Serial.println("Boiler temperature is " + String(temperature) + " degrees C");	
	Serial.println();
	delay(1000);
}

Serial port output:

Start
Central Heating: on
Hot Water: on
Flame: on
Boiler temperature is 64 degrees C

Advanced Requests:

To send advanced request you have to:

Advanced Request Sample:

//Read Relative Modulation Level:
unsigned int data = 0xFFFF;
unsigned long request = ot.buildRequest(
    OpenThermRequestType::READ,
    OpenThermMessageID::RelModLevel,
    data);
unsigned long response = ot.sendRequest(request);

Asynchronous Requests:

To send requests asynchronously you have to: