mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 09:19:51 +03:00
Merged changes for the new dev
This commit is contained in:
37
src/ds18.cpp
37
src/ds18.cpp
@@ -4,9 +4,6 @@
|
||||
*
|
||||
* Paul Derbyshire - https://github.com/proddy/EMS-ESP
|
||||
*
|
||||
* See ChangeLog.md for history
|
||||
* See README.md for Acknowledgments
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ds18.h"
|
||||
@@ -14,9 +11,10 @@
|
||||
std::vector<ds_device_t> _devices;
|
||||
|
||||
DS18::DS18() {
|
||||
_wire = NULL;
|
||||
_count = 0;
|
||||
_gpio = GPIO_NONE;
|
||||
_wire = NULL;
|
||||
_count = 0;
|
||||
_gpio = GPIO_NONE;
|
||||
_parasite = 0;
|
||||
}
|
||||
|
||||
DS18::~DS18() {
|
||||
@@ -25,10 +23,11 @@ DS18::~DS18() {
|
||||
}
|
||||
|
||||
// init
|
||||
uint8_t DS18::setup(uint8_t gpio) {
|
||||
uint8_t DS18::setup(uint8_t gpio, bool parasite) {
|
||||
uint8_t count;
|
||||
|
||||
_gpio = gpio;
|
||||
_gpio = gpio;
|
||||
_parasite = (parasite ? 1 : 0);
|
||||
|
||||
// OneWire
|
||||
if (_wire)
|
||||
@@ -51,7 +50,7 @@ uint8_t DS18::setup(uint8_t gpio) {
|
||||
|
||||
// scan every 2 seconds
|
||||
void DS18::loop() {
|
||||
static unsigned long last = 0;
|
||||
static uint32_t last = 0;
|
||||
if (millis() - last < DS18_READ_INTERVAL)
|
||||
return;
|
||||
last = millis();
|
||||
@@ -62,8 +61,7 @@ void DS18::loop() {
|
||||
// Start conversion
|
||||
_wire->reset();
|
||||
_wire->skip();
|
||||
_wire->write(DS18_CMD_START_CONVERSION, DS18_PARASITE);
|
||||
|
||||
_wire->write(DS18_CMD_START_CONVERSION, _parasite);
|
||||
} else {
|
||||
// Read scratchpads
|
||||
for (unsigned char index = 0; index < _devices.size(); index++) {
|
||||
@@ -117,7 +115,7 @@ char * DS18::getDeviceString(char * buffer, unsigned char index) {
|
||||
char a[30] = {0};
|
||||
snprintf(a,
|
||||
sizeof(a),
|
||||
"(%02X%02X%02X%02X%02X%02X%02X%02X) @ GPIO%d",
|
||||
" (%02X%02X%02X%02X%02X%02X%02X%02X) @ GPIO%d",
|
||||
address[0],
|
||||
address[1],
|
||||
address[2],
|
||||
@@ -136,7 +134,6 @@ char * DS18::getDeviceString(char * buffer, unsigned char index) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Read sensor values
|
||||
*
|
||||
@@ -154,14 +151,14 @@ char * DS18::getDeviceString(char * buffer, unsigned char index) {
|
||||
DS18B20 & DS1822: store for crc
|
||||
byte 8: SCRATCHPAD_CRC
|
||||
*/
|
||||
double DS18::getValue(unsigned char index) {
|
||||
int16_t DS18::getRawValue(unsigned char index) {
|
||||
if (index >= _count)
|
||||
return 0;
|
||||
|
||||
uint8_t * data = _devices[index].data;
|
||||
|
||||
if (OneWire::crc8(data, DS18_DATA_SIZE - 1) != data[DS18_DATA_SIZE - 1]) {
|
||||
return 0;
|
||||
return DS18_CRC_ERROR;
|
||||
}
|
||||
|
||||
int16_t raw = (data[1] << 8) | data[0];
|
||||
@@ -181,11 +178,13 @@ double DS18::getValue(unsigned char index) {
|
||||
// 12 bit res, 750 ms
|
||||
}
|
||||
|
||||
double value = (float)raw / 16.0;
|
||||
if (value == DS18_DISCONNECTED) {
|
||||
return 0;
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
|
||||
// return real value as a double
|
||||
// The raw temperature data is in units of sixteenths of a degree, so the value must be divided by 16 in order to convert it to degrees.
|
||||
double DS18::getValue(unsigned char index) {
|
||||
double value = (float)getRawValue(index) / 16.0;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
13
src/ds18.h
13
src/ds18.h
@@ -4,9 +4,6 @@
|
||||
*
|
||||
* Paul Derbyshire - https://github.com/proddy/EMS-ESP
|
||||
*
|
||||
* See ChangeLog.md for history
|
||||
* See README.md for Acknowledgments
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -20,8 +17,8 @@
|
||||
#define DS18_CHIP_DS1825 0x3B
|
||||
|
||||
#define DS18_DATA_SIZE 9
|
||||
#define DS18_PARASITE 1
|
||||
#define DS18_DISCONNECTED -127
|
||||
#define DS18_CRC_ERROR -126
|
||||
|
||||
#define GPIO_NONE 0x99
|
||||
#define DS18_READ_INTERVAL 2000 // Force sensor read & cache every 2 seconds
|
||||
@@ -39,10 +36,11 @@ class DS18 {
|
||||
DS18();
|
||||
~DS18();
|
||||
|
||||
uint8_t setup(uint8_t gpio);
|
||||
uint8_t setup(uint8_t gpio, bool parasite);
|
||||
void loop();
|
||||
char * getDeviceString(char * s, unsigned char index);
|
||||
double getValue(unsigned char index);
|
||||
int16_t getRawValue(unsigned char index); // raw values, needs / 16
|
||||
|
||||
protected:
|
||||
bool validateID(unsigned char id);
|
||||
@@ -50,6 +48,7 @@ class DS18 {
|
||||
uint8_t loadDevices();
|
||||
|
||||
OneWire * _wire;
|
||||
uint8_t _count; // # devices
|
||||
uint8_t _gpio; // the sensor pin
|
||||
uint8_t _count; // # devices
|
||||
uint8_t _gpio; // the sensor pin
|
||||
uint8_t _parasite; // parasite mode
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
754
src/ems.cpp
754
src/ems.cpp
File diff suppressed because it is too large
Load Diff
95
src/ems.h
95
src/ems.h
@@ -17,18 +17,19 @@
|
||||
#define EMS_PLUS_ID_NONE 0x01 // Fixed - used as a dest in broadcast messages and empty type IDs
|
||||
#define EMS_ID_ME 0x0B // Fixed - our device, hardcoded as the "Service Key"
|
||||
#define EMS_ID_DEFAULT_BOILER 0x08
|
||||
#define EMS_ID_SM10 0x30 // Solar Module SM10
|
||||
|
||||
#define EMS_MIN_TELEGRAM_LENGTH 6 // minimal length for a validation telegram, including CRC
|
||||
|
||||
// max length of a telegram, including CRC, for Rx and Tx.
|
||||
#define EMS_MAX_TELEGRAM_LENGTH 99
|
||||
#define EMS_MAX_TELEGRAM_LENGTH 32
|
||||
|
||||
// default values
|
||||
#define EMS_VALUE_INT_ON 1 // boolean true
|
||||
#define EMS_VALUE_INT_OFF 0 // boolean false
|
||||
#define EMS_VALUE_INT_NOTSET 0xFF // for 8-bit ints
|
||||
#define EMS_VALUE_SHORT_NOTSET 0x8000 // for 2-byte shorts
|
||||
#define EMS_VALUE_LONG_NOTSET 0xFFFFFF // for 3-byte longs
|
||||
#define EMS_VALUE_FLOAT_NOTSET -255 // float
|
||||
|
||||
#define EMS_THERMOSTAT_READ_YES true
|
||||
#define EMS_THERMOSTAT_READ_NO false
|
||||
@@ -89,9 +90,10 @@ typedef struct {
|
||||
_EMS_SYS_LOGGING emsLogging; // logging
|
||||
bool emsRefreshed; // fresh data, needs to be pushed out to MQTT
|
||||
bool emsBusConnected; // is there an active bus
|
||||
unsigned long emsRxTimestamp; // timestamp of last EMS message received
|
||||
unsigned long emsPollTimestamp; // timestamp of last EMS poll sent to us
|
||||
uint32_t emsRxTimestamp; // timestamp of last EMS message received
|
||||
uint32_t emsPollFrequency; // time between EMS polls
|
||||
bool emsTxCapable; // able to send via Tx
|
||||
bool emsTxDisabled; // true to prevent all Tx
|
||||
uint8_t txRetryCount; // # times the last Tx was re-sent
|
||||
} _EMS_Sys_Status;
|
||||
|
||||
@@ -108,11 +110,16 @@ typedef struct {
|
||||
uint8_t comparisonOffset; // offset of where the byte is we want to compare too later
|
||||
uint8_t comparisonPostRead; // after a successful write call this to read
|
||||
bool forceRefresh; // should we send to MQTT after a successful Tx?
|
||||
unsigned long timestamp; // when created
|
||||
uint32_t timestamp; // when created
|
||||
uint8_t data[EMS_MAX_TELEGRAM_LENGTH];
|
||||
} _EMS_TxTelegram;
|
||||
|
||||
|
||||
// The Rx receive package
|
||||
typedef struct {
|
||||
uint32_t timestamp; // timestamp from millis()
|
||||
uint8_t * telegram; // the full data package
|
||||
uint8_t length; // length in bytes
|
||||
} _EMS_RxTelegram;
|
||||
|
||||
// default empty Tx
|
||||
const _EMS_TxTelegram EMS_TX_TELEGRAM_NEW = {
|
||||
@@ -138,6 +145,13 @@ typedef struct {
|
||||
char model_string[50];
|
||||
} _Boiler_Type;
|
||||
|
||||
typedef struct {
|
||||
uint8_t model_id;
|
||||
uint8_t product_id;
|
||||
uint8_t type_id;
|
||||
char model_string[50];
|
||||
} _Other_Type;
|
||||
|
||||
// Definition for thermostat type
|
||||
typedef struct {
|
||||
uint8_t model_id;
|
||||
@@ -159,31 +173,32 @@ typedef struct { // UBAParameterWW
|
||||
uint8_t wWComfort; // Warm water comfort or ECO mode
|
||||
|
||||
// UBAMonitorFast
|
||||
uint8_t selFlowTemp; // Selected flow temperature
|
||||
float curFlowTemp; // Current flow temperature
|
||||
float retTemp; // Return temperature
|
||||
uint8_t burnGas; // Gas on/off
|
||||
uint8_t fanWork; // Fan on/off
|
||||
uint8_t ignWork; // Ignition on/off
|
||||
uint8_t heatPmp; // Circulating pump on/off
|
||||
uint8_t wWHeat; // 3-way valve on WW
|
||||
uint8_t wWCirc; // Circulation on/off
|
||||
uint8_t selBurnPow; // Burner max power
|
||||
uint8_t curBurnPow; // Burner current power
|
||||
float flameCurr; // Flame current in micro amps
|
||||
float sysPress; // System pressure
|
||||
char serviceCodeChar[2]; // 2 character status/service code
|
||||
uint8_t selFlowTemp; // Selected flow temperature
|
||||
int16_t curFlowTemp; // Current flow temperature
|
||||
int16_t retTemp; // Return temperature
|
||||
uint8_t burnGas; // Gas on/off
|
||||
uint8_t fanWork; // Fan on/off
|
||||
uint8_t ignWork; // Ignition on/off
|
||||
uint8_t heatPmp; // Circulating pump on/off
|
||||
uint8_t wWHeat; // 3-way valve on WW
|
||||
uint8_t wWCirc; // Circulation on/off
|
||||
uint8_t selBurnPow; // Burner max power
|
||||
uint8_t curBurnPow; // Burner current power
|
||||
uint16_t flameCurr; // Flame current in micro amps
|
||||
uint8_t sysPress; // System pressure
|
||||
char serviceCodeChar[3]; // 2 character status/service code
|
||||
uint16_t serviceCode; // error/service code
|
||||
|
||||
// UBAMonitorSlow
|
||||
float extTemp; // Outside temperature
|
||||
float boilTemp; // Boiler temperature
|
||||
int16_t extTemp; // Outside temperature
|
||||
int16_t boilTemp; // Boiler temperature
|
||||
uint8_t pumpMod; // Pump modulation
|
||||
uint32_t burnStarts; // # burner restarts
|
||||
uint32_t burnStarts; // # burner starts
|
||||
uint32_t burnWorkMin; // Total burner operating time
|
||||
uint32_t heatWorkMin; // Total heat operating time
|
||||
|
||||
// UBAMonitorWWMessage
|
||||
float wWCurTmp; // Warm Water current temperature:
|
||||
int16_t wWCurTmp; // Warm Water current temperature:
|
||||
uint32_t wWStarts; // Warm Water # starts
|
||||
uint32_t wWWorkM; // Warm Water # minutes
|
||||
uint8_t wWOneTime; // Warm Water one time function on/off
|
||||
@@ -207,6 +222,18 @@ typedef struct { // UBAParameterWW
|
||||
uint8_t product_id;
|
||||
} _EMS_Boiler;
|
||||
|
||||
/*
|
||||
* Telegram package defintions for Other EMS devices
|
||||
*/
|
||||
typedef struct {
|
||||
// SM10 Solar Module - SM10Monitor
|
||||
bool SM10; // set true if there is a SM10 available
|
||||
int16_t SM10collectorTemp; // collector temp from SM10
|
||||
int16_t SM10bottomTemp; // bottom temp from SM10
|
||||
uint8_t SM10pumpModulation; // modulation solar pump
|
||||
uint8_t SM10pump; // pump active
|
||||
} _EMS_Other;
|
||||
|
||||
// Thermostat data
|
||||
typedef struct {
|
||||
uint8_t type_id; // the type ID of the thermostat
|
||||
@@ -215,8 +242,8 @@ typedef struct {
|
||||
bool read_supported;
|
||||
bool write_supported;
|
||||
char version[10];
|
||||
float setpoint_roomTemp; // current set temp
|
||||
float curr_roomTemp; // current room temp
|
||||
int16_t setpoint_roomTemp; // current set temp
|
||||
int16_t curr_roomTemp; // current room temp
|
||||
uint8_t mode; // 0=low, 1=manual, 2=auto
|
||||
bool day_mode; // 0=night, 1=day
|
||||
uint8_t hour;
|
||||
@@ -228,7 +255,7 @@ typedef struct {
|
||||
} _EMS_Thermostat;
|
||||
|
||||
// call back function signature for processing telegram types
|
||||
typedef void (*EMS_processType_cb)(uint8_t type, uint8_t * data, uint8_t length);
|
||||
typedef void (*EMS_processType_cb)(uint8_t src, uint8_t * data, uint8_t length);
|
||||
|
||||
// Definition for each EMS type, including the relative callback function
|
||||
typedef struct {
|
||||
@@ -251,15 +278,16 @@ void ems_setWarmWaterTemp(uint8_t temperature);
|
||||
void ems_setWarmWaterActivated(bool activated);
|
||||
void ems_setWarmTapWaterActivated(bool activated);
|
||||
void ems_setPoll(bool b);
|
||||
void ems_setTxEnabled(bool b);
|
||||
void ems_setLogging(_EMS_SYS_LOGGING loglevel);
|
||||
void ems_setEmsRefreshed(bool b);
|
||||
void ems_setWarmWaterModeComfort(bool comfort);
|
||||
void ems_setWarmWaterModeComfort(uint8_t comfort);
|
||||
bool ems_checkEMSBUSAlive();
|
||||
void ems_setModels();
|
||||
void ems_setTxDisabled(bool b);
|
||||
|
||||
void ems_getThermostatValues();
|
||||
void ems_getBoilerValues();
|
||||
void ems_getOtherValues();
|
||||
bool ems_getPoll();
|
||||
bool ems_getTxEnabled();
|
||||
bool ems_getThermostatEnabled();
|
||||
@@ -270,6 +298,7 @@ bool ems_getEmsRefreshed();
|
||||
uint8_t ems_getThermostatModel();
|
||||
void ems_discoverModels();
|
||||
bool ems_getTxCapable();
|
||||
uint32_t ems_getPollFrequency();
|
||||
|
||||
void ems_scanDevices();
|
||||
void ems_printAllTypes();
|
||||
@@ -277,17 +306,21 @@ char * ems_getThermostatDescription(char * buffer);
|
||||
void ems_printTxQueue();
|
||||
char * ems_getBoilerDescription(char * buffer);
|
||||
|
||||
void ems_startupTelegrams();
|
||||
|
||||
// private functions
|
||||
uint8_t _crcCalculator(uint8_t * data, uint8_t len);
|
||||
void _processType(uint8_t * telegram, uint8_t length);
|
||||
void _debugPrintPackage(const char * prefix, uint8_t * data, uint8_t len, const char * color);
|
||||
void _processType(_EMS_RxTelegram * EMS_RxTelegram);
|
||||
void _debugPrintPackage(const char * prefix, _EMS_RxTelegram * EMS_RxTelegram, const char * color);
|
||||
void _ems_clearTxData();
|
||||
int _ems_findBoilerModel(uint8_t model_id);
|
||||
bool _ems_setModel(uint8_t model_id);
|
||||
void _ems_setThermostatModel(uint8_t thermostat_modelid);
|
||||
void _removeTxQueue();
|
||||
void _ems_readTelegram(uint8_t * telegram, uint8_t length);
|
||||
|
||||
// global so can referenced in other classes
|
||||
extern _EMS_Sys_Status EMS_Sys_Status;
|
||||
extern _EMS_Boiler EMS_Boiler;
|
||||
extern _EMS_Thermostat EMS_Thermostat;
|
||||
extern _EMS_Other EMS_Other;
|
||||
|
||||
@@ -32,11 +32,15 @@
|
||||
#define EMS_TYPE_UBASetPoints 0x1A
|
||||
#define EMS_TYPE_UBAFunctionTest 0x1D
|
||||
|
||||
#define EMS_OFFSET_UBAParameterWW_wwtemp 2 // WW Temperature
|
||||
#define EMS_OFFSET_UBAParameterWW_wwactivated 1 // WW Activated
|
||||
#define EMS_OFFSET_UBAParameterWW_wwComfort 9 // WW is in comfort or eco mode
|
||||
#define EMS_VALUE_UBAParameterWW_wwComfort_Comfort 0x00 // the value for comfort
|
||||
#define EMS_VALUE_UBAParameterWW_wwComfort_Eco 0xD8 // the value for eco
|
||||
#define EMS_OFFSET_UBAParameterWW_wwtemp 2 // WW Temperature
|
||||
#define EMS_OFFSET_UBAParameterWW_wwactivated 1 // WW Activated
|
||||
#define EMS_OFFSET_UBAParameterWW_wwComfort 9 // WW is in comfort or eco mode
|
||||
#define EMS_VALUE_UBAParameterWW_wwComfort_Hot 0x00 // the value for hot
|
||||
#define EMS_VALUE_UBAParameterWW_wwComfort_Eco 0xD8 // the value for eco
|
||||
#define EMS_VALUE_UBAParameterWW_wwComfort_Intelligent 0xEC // the value for intelligent
|
||||
|
||||
// Other
|
||||
#define EMS_TYPE_SM10Monitor 0x97 // SM10Monitor
|
||||
|
||||
/*
|
||||
* Thermostats...
|
||||
@@ -97,7 +101,10 @@ typedef enum {
|
||||
// generic ID for the boiler
|
||||
EMS_MODEL_UBA,
|
||||
|
||||
// thermostats
|
||||
// generic ID for all the other weird devices
|
||||
EMS_MODEL_OTHER,
|
||||
|
||||
// and finaly the thermostats
|
||||
EMS_MODEL_ES73,
|
||||
EMS_MODEL_RC10,
|
||||
EMS_MODEL_RC20,
|
||||
@@ -117,11 +124,13 @@ typedef enum {
|
||||
// format is MODEL_ID, PRODUCT ID, TYPE_ID, DESCRIPTION
|
||||
const _Boiler_Type Boiler_Types[] = {
|
||||
|
||||
{EMS_MODEL_UBA, 72, 0x08, "MC10"},
|
||||
{EMS_MODEL_UBA, 72, 0x08, "MC10 Module"},
|
||||
{EMS_MODEL_UBA, 123, 0x08, "Buderus GB172/Nefit Trendline"},
|
||||
{EMS_MODEL_UBA, 115, 0x08, "Nefit Topline Compact"},
|
||||
{EMS_MODEL_UBA, 203, 0x08, "Buderus Logamax U122"},
|
||||
{EMS_MODEL_UBA, 208, 0x08, "Buderus Logamax plus"},
|
||||
{EMS_MODEL_UBA, 64, 0x08, "Sieger BK15 Boiler/Nefit Smartline"},
|
||||
<<<<<<< HEAD
|
||||
{EMS_MODEL_UBA, 190, 0x09, "BC10 Base Controller"},
|
||||
{EMS_MODEL_UBA, 114, 0x09, "BC10 Base Controller"},
|
||||
{EMS_MODEL_UBA, 125, 0x09, "BC25 Base Controller"},
|
||||
@@ -130,6 +139,24 @@ const _Boiler_Type Boiler_Types[] = {
|
||||
{EMS_MODEL_UBA, 205, 0x08, "Nefit Moduline Easy Connect"},
|
||||
{EMS_MODEL_UBA, 251, 0x21, "MM10 Mixer Module"}, // warning, fake product id!
|
||||
{EMS_MODEL_UBA, 250, 0x11, "WM10 Switch Module"}, // warning, fake product id!
|
||||
=======
|
||||
{EMS_MODEL_UBA, 95, 0x08, "Bosch Condens 2500"}
|
||||
|
||||
};
|
||||
|
||||
// Other EMS devices which are not considered boilers or thermostats
|
||||
const _Other_Type Other_Types[] = {
|
||||
|
||||
{EMS_MODEL_OTHER, 251, 0x21, "MM10 Mixer Module"}, // warning, fake product id!
|
||||
{EMS_MODEL_OTHER, 250, 0x11, "WM10 Switch Module"}, // warning, fake product id!
|
||||
{EMS_MODEL_OTHER, 68, 0x09, "RFM20 Receiver"},
|
||||
{EMS_MODEL_OTHER, 190, 0x09, "BC10 Base Controller"},
|
||||
{EMS_MODEL_OTHER, 114, 0x09, "BC10 Base Controller"},
|
||||
{EMS_MODEL_OTHER, 125, 0x09, "BC25 Base Controller"},
|
||||
{EMS_MODEL_OTHER, 205, 0x02, "Nefit Moduline Easy Connect"},
|
||||
{EMS_MODEL_OTHER, 73, EMS_ID_SM10, "SM10 Solar Module"}
|
||||
|
||||
>>>>>>> upstream/dev
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -138,15 +165,21 @@ const _Boiler_Type Boiler_Types[] = {
|
||||
const _Thermostat_Type Thermostat_Types[] = {
|
||||
|
||||
{EMS_MODEL_ES73, 76, 0x10, "Sieger ES73", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
|
||||
{EMS_MODEL_RC10, 79, 0x17, "RC10/Nefit Moduline 100)", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
|
||||
{EMS_MODEL_RC20, 77, 0x17, "RC20/Nefit Moduline 300)", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
|
||||
{EMS_MODEL_RC10, 79, 0x17, "RC10/Nefit Moduline 100", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
|
||||
{EMS_MODEL_RC20, 77, 0x17, "RC20/Nefit Moduline 300", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
|
||||
{EMS_MODEL_RC20F, 93, 0x18, "RC20F", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
|
||||
{EMS_MODEL_RC30, 78, 0x10, "RC30/Nefit Moduline 400)", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
|
||||
{EMS_MODEL_RC30, 78, 0x10, "RC30/Nefit Moduline 400", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
|
||||
{EMS_MODEL_RC35, 86, 0x10, "RC35", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
|
||||
{EMS_MODEL_EASY, 202, 0x18, "TC100/Nefit Easy", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_NO},
|
||||
{EMS_MODEL_BOSCHEASY, 206, 0x02, "Bosch Easy", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_NO},
|
||||
{EMS_MODEL_RC310, 158, 0x10, "RC310", EMS_THERMOSTAT_READ_NO, EMS_THERMOSTAT_WRITE_NO},
|
||||
{EMS_MODEL_CW100, 255, 0x18, "Bosch CW100", EMS_THERMOSTAT_READ_NO, EMS_THERMOSTAT_WRITE_NO},
|
||||
<<<<<<< HEAD
|
||||
{EMS_MODEL_RC1010, 165, 0x18, "RC1010/Nefit Moduline 1010)", EMS_THERMOSTAT_READ_NO, EMS_THERMOSTAT_WRITE_NO},
|
||||
{EMS_MODEL_OT, 171, 0x02, "EMS-OT OpenTherm converter", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
|
||||
=======
|
||||
{EMS_MODEL_OT, 171, 0x02, "EMS-OT OpenTherm converter", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
|
||||
{EMS_MODEL_RC10, 165, 0x02, "RC10/Nefit Moduline 1010", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES}
|
||||
|
||||
>>>>>>> upstream/dev
|
||||
};
|
||||
|
||||
@@ -24,8 +24,8 @@ os_event_t recvTaskQueue[EMSUART_recvTaskQueueLen]; // our Rx queue
|
||||
// Important: do not use ICACHE_FLASH_ATTR !
|
||||
//
|
||||
static void emsuart_rx_intr_handler(void * para) {
|
||||
static uint16_t length;
|
||||
static uint8_t uart_buffer[EMS_MAXBUFFERSIZE];
|
||||
static uint8_t length;
|
||||
static uint8_t uart_buffer[EMS_MAXBUFFERSIZE];
|
||||
|
||||
// is a new buffer? if so init the thing for a new telegram
|
||||
if (EMS_Sys_Status.emsRxStatus == EMS_RX_STATUS_IDLE) {
|
||||
@@ -67,18 +67,13 @@ static void emsuart_rx_intr_handler(void * para) {
|
||||
|
||||
/*
|
||||
* system task triggered on BRK interrupt
|
||||
* Read commands are all asynchronous
|
||||
* When a buffer is full it is sent to the ems_parseTelegram() function in ems.cpp. This is the hook
|
||||
* incoming received messages are always asynchronous
|
||||
* The full buffer is sent to the ems_parseTelegram() function in ems.cpp.
|
||||
*/
|
||||
static void ICACHE_FLASH_ATTR emsuart_recvTask(os_event_t * events) {
|
||||
// get next free EMS Receive buffer
|
||||
_EMSRxBuf * pCurrent = pEMSRxBuf;
|
||||
pEMSRxBuf = paEMSRxBuf[++emsRxBufIdx % EMS_MAXBUFFERS];
|
||||
|
||||
// transmit EMS buffer, excluding the BRK
|
||||
if (pCurrent->writePtr > 1) {
|
||||
ems_parseTelegram((uint8_t *)pCurrent->buffer, (pCurrent->writePtr) - 1);
|
||||
}
|
||||
ems_parseTelegram((uint8_t *)pCurrent->buffer, (pCurrent->writePtr) - 1); // transmit EMS buffer, excluding the BRK
|
||||
pEMSRxBuf = paEMSRxBuf[++emsRxBufIdx % EMS_MAXBUFFERS]; // next free EMS Receive buffer
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -97,12 +92,12 @@ void ICACHE_FLASH_ATTR emsuart_init() {
|
||||
|
||||
// pin settings
|
||||
PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0RXD);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD);
|
||||
PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0RXD_U);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD);
|
||||
|
||||
// set 9600, 8 bits, no parity check, 1 stop bit
|
||||
USD(EMSUART_UART) = (ESP8266_CLOCK / EMSUART_BAUD);
|
||||
USD(EMSUART_UART) = (UART_CLK_FREQ / EMSUART_BAUD);
|
||||
USC0(EMSUART_UART) = EMSUART_CONFIG; // 8N1
|
||||
|
||||
// flush everything left over in buffer, this clears both rx and tx FIFOs
|
||||
@@ -129,13 +124,13 @@ void ICACHE_FLASH_ATTR emsuart_init() {
|
||||
system_os_task(emsuart_recvTask, EMSUART_recvTaskPrio, recvTaskQueue, EMSUART_recvTaskQueueLen);
|
||||
|
||||
// disable esp debug which will go to Tx and mess up the line
|
||||
// system_set_os_print(0); // https://github.com/espruino/Espruino/issues/655
|
||||
|
||||
ETS_UART_INTR_ATTACH(emsuart_rx_intr_handler, NULL);
|
||||
ETS_UART_INTR_ENABLE();
|
||||
system_set_os_print(0); // https://github.com/espruino/Espruino/issues/655
|
||||
|
||||
// swap Rx and Tx pins to use GPIO13 (D7) and GPIO15 (D8) respectively
|
||||
system_uart_swap();
|
||||
|
||||
ETS_UART_INTR_ATTACH(emsuart_rx_intr_handler, NULL);
|
||||
ETS_UART_INTR_ENABLE();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -143,7 +138,17 @@ void ICACHE_FLASH_ATTR emsuart_init() {
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR emsuart_stop() {
|
||||
ETS_UART_INTR_DISABLE();
|
||||
ETS_UART_INTR_ATTACH(NULL, NULL);
|
||||
//ETS_UART_INTR_ATTACH(NULL, NULL);
|
||||
//system_uart_swap(); // to be sure, swap Tx/Rx back.
|
||||
//detachInterrupt(digitalPinToInterrupt(D7));
|
||||
//noInterrupts();
|
||||
}
|
||||
|
||||
/*
|
||||
* re-start UART0 driver
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR emsuart_start() {
|
||||
ETS_UART_INTR_ENABLE();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -172,6 +177,7 @@ void ICACHE_FLASH_ATTR emsuart_tx_brk() {
|
||||
void ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
|
||||
for (uint8_t i = 0; i < len; i++) {
|
||||
USF(EMSUART_UART) = buf[i];
|
||||
//delayMicroseconds(EMS_TX_BRK_WAIT);
|
||||
}
|
||||
emsuart_tx_brk();
|
||||
}
|
||||
|
||||
@@ -10,15 +10,15 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#define EMSUART_UART 0 // UART 0
|
||||
#define EMSUART_CONFIG 0x1c // 8N1 (8 bits, no stop bits, 1 parity)
|
||||
#define EMSUART_CONFIG 0x1C // 8N1 (8 bits, no stop bits, 1 parity)
|
||||
#define EMSUART_BAUD 9600 // uart baud rate for the EMS circuit
|
||||
|
||||
#define EMS_MAXBUFFERS 4 // 4 buffers for circular filling to avoid collisions
|
||||
#define EMS_MAXBUFFERSIZE 128 // max size of the buffer. packets are max 32 bytes
|
||||
#define EMS_MAXBUFFERS 10 // 4 buffers for circular filling to avoid collisions
|
||||
#define EMS_MAXBUFFERSIZE 32 // max size of the buffer. packets are max 32 bytes
|
||||
|
||||
// this is how long we drop the Tx signal to create a 11-bit Break of zeros
|
||||
// this is how long we drop the Tx signal to create a 11-bit Break of zeros (BRK)
|
||||
// At 9600 baud, 11 bits will be 1144 microseconds
|
||||
// the BRK from Boiler is roughly 1.039ms, so accounting for hardware lag using around 2078 (for half-duplex) - 8 (lag)
|
||||
// the BRK from Boiler master is roughly 1.039ms, so accounting for hardware lag using around 2078 (for half-duplex) - 8 (lag)
|
||||
#define EMS_TX_BRK_WAIT 2070
|
||||
|
||||
#define EMSUART_recvTaskPrio 1
|
||||
@@ -31,6 +31,7 @@ typedef struct {
|
||||
|
||||
void ICACHE_FLASH_ATTR emsuart_init();
|
||||
void ICACHE_FLASH_ATTR emsuart_stop();
|
||||
void ICACHE_FLASH_ATTR emsuart_start();
|
||||
void ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len);
|
||||
void ICACHE_FLASH_ATTR emsaurt_tx_poll();
|
||||
void ICACHE_FLASH_ATTR emsuart_tx_brk();
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#define MQTT_RETAIN false
|
||||
#define MQTT_KEEPALIVE 120 // 2 minutes
|
||||
#define MQTT_QOS 1
|
||||
#define MQTT_MAX_SIZE 700 // max size of a JSON object. See https://arduinojson.org/v6/assistant/
|
||||
|
||||
// MQTT for thermostat
|
||||
#define TOPIC_THERMOSTAT_DATA "thermostat_data" // for sending thermostat values to MQTT
|
||||
@@ -37,6 +38,14 @@
|
||||
#define TOPIC_BOILER_HEATING_ACTIVE "heating_active" // if heating is on
|
||||
#define TOPIC_BOILER_WWACTIVATED "wwactivated" // for receiving MQTT message to change water on/off
|
||||
#define TOPIC_BOILER_CMD_WWTEMP "boiler_cmd_wwtemp" // for received boiler wwtemp changes via MQTT
|
||||
#define TOPIC_BOILER_CMD_COMFORT "boiler_cmd_comfort" // for received boiler ww comfort setting via MQTT
|
||||
|
||||
// MQTT for SM10 Solar Module
|
||||
#define TOPIC_SM10_DATA "sm10_data" // topic name
|
||||
#define SM10_COLLECTORTEMP "temp" // collector temp
|
||||
#define SM10_BOTTOMTEMP "bottomtemp" // bottom temp
|
||||
#define SM10_PUMPMODULATION "pumpmodulation" // pump modulation
|
||||
#define SM10_PUMP "pump" // pump active
|
||||
|
||||
// shower time
|
||||
#define TOPIC_SHOWERTIME "showertime" // for sending shower time results
|
||||
@@ -44,28 +53,33 @@
|
||||
#define TOPIC_SHOWER_ALERT "shower_alert" // toggle switch for enabling the shower alarm logic
|
||||
#define TOPIC_SHOWER_COLDSHOT "shower_coldshot" // used to trigger a coldshot from an MQTT command
|
||||
|
||||
<<<<<<< HEAD
|
||||
// default values for shower logic on/off
|
||||
#define BOILER_SHOWER_TIMER 0 // enable (1) to monitor shower time
|
||||
#define BOILER_SHOWER_ALERT 0 // enable (1) to send alert of cold water when shower time limit has exceeded
|
||||
#define SHOWER_MAX_DURATION 420000 // in ms. 7 minutes, before trigger a shot of cold water
|
||||
=======
|
||||
// MQTT for EXTERNAL SENSORS
|
||||
#define TOPIC_EXTERNAL_SENSORS "sensors" // for sending sensor values to MQTT
|
||||
#define PAYLOAD_EXTERNAL_SENSORS "temp_%d" // for formatting the payload for each external dallas sensor
|
||||
|
||||
>>>>>>> upstream/dev
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// THESE DEFAULT VALUES CAN ALSO BE SET AND STORED WITHTIN THE APPLICATION (see 'set' command) //
|
||||
// ALTHOUGH YOU MAY ALSO HARDCODE THEM HERE BUT THEY WILL BE OVERWRITTEN WITH NEW RELEASE UPDATES //
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Set LED pin used for showing ems bus connection status. Solid is connected, Flashing is error
|
||||
// can be either the onboard LED on the ESP8266 (LED_BULLETIN) or external via an external pull-up LED
|
||||
// (e.g. D1 on a bbqkees' board
|
||||
// can be enabled and disabled via the 'set led'
|
||||
// pin can be set by 'set led_gpio'
|
||||
// Set LED pin used for showing the EMS bus connection status. Solid means EMS bus working, flashing is an error
|
||||
// can be either the onboard LED on the ESP8266 (LED_BULLETIN) or external via an external pull-up LED (e.g. D1 on a bbqkees' board)
|
||||
// can be enabled and disabled via the 'set led' command and pin set by 'set led_gpio'
|
||||
#define EMSESP_LED_GPIO LED_BUILTIN
|
||||
|
||||
// set this if using an external temperature sensor like a DS18B20
|
||||
// D5 is the default on bbqkees' board
|
||||
// D5 is the default on a bbqkees board
|
||||
#define EMSESP_DALLAS_GPIO D5
|
||||
#define EMSESP_DALLAS_PARASITE false
|
||||
|
||||
// By default the EMS bus will be scanned for known devices based on product ids in ems_devices.h
|
||||
// By default the EMS bus will be scanned for known devices based on the product ids in ems_devices.h
|
||||
// You can override the Thermostat and Boiler types here
|
||||
#define EMSESP_BOILER_TYPE EMS_ID_NONE
|
||||
#define EMSESP_THERMOSTAT_TYPE EMS_ID_NONE
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
<<<<<<< HEAD
|
||||
#define APP_NAME "EMS-HEERENVEEN-1"
|
||||
#define APP_VERSION "1.5.7b"
|
||||
#define APP_HOSTNAME "ems-heerenveen-1"
|
||||
=======
|
||||
#define APP_NAME "EMS-ESP"
|
||||
#define APP_VERSION "1.6.1b1"
|
||||
#define APP_HOSTNAME "ems-esp"
|
||||
>>>>>>> upstream/dev
|
||||
|
||||
Reference in New Issue
Block a user