Install and use the OpenTherm library
masterThe 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);
}