From 22d82013d12df0c42b43b243a3cbb539b8d04585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Mon, 26 Feb 2018 21:02:23 +0100 Subject: [PATCH] Support for KMC 70011 energy monitor (thanks to Wayne Manion, #598) --- code/espurna/config/arduino.h | 1 + code/espurna/config/hardware.h | 32 ++++++++++++++++++++++++++++++++ code/espurna/migrate.ino | 13 +++++++++++++ code/platformio.ini | 25 +++++++++++++++++++++++++ 4 files changed, 71 insertions(+) diff --git a/code/espurna/config/arduino.h b/code/espurna/config/arduino.h index 4cdc35d2..649f2607 100644 --- a/code/espurna/config/arduino.h +++ b/code/espurna/config/arduino.h @@ -54,6 +54,7 @@ //#define ARILUX_E27 //#define XENON_SM_PW702U //#define AUTHOMETION_LYT8266 +//#define KMC_70011 //#define GENERIC_8CH //#define ARILUX_AL_LC01 //#define ARILUX_AL_LC11 diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index fae00f95..96a191bd 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -1364,6 +1364,38 @@ #define LIGHT_ENABLE_PIN 15 +// ----------------------------------------------------------------------------- +// KMC 70011 +// https://www.amazon.com/KMC-Monitoring-Required-Control-Compatible/dp/B07313TH7B +// ----------------------------------------------------------------------------- + +#elif defined(KMC_70011) + + // Info + #define MANUFACTURER "KMC" + #define DEVICE "70011" + + // Buttons + #define BUTTON1_PIN 0 + #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON1_RELAY 1 + + // Relays + #define RELAY1_PIN 14 + #define RELAY1_TYPE RELAY_TYPE_NORMAL + + // LEDs + #define LED1_PIN 13 + #define LED1_PIN_INVERSE 0 + + // HLW8012 + #ifndef HLW8012_SUPPORT + #define HLW8012_SUPPORT 1 + #endif + #define HLW8012_SEL_PIN 12 + #define HLW8012_CF1_PIN 5 + #define HLW8012_CF_PIN 4 + // ----------------------------------------------------------------------------- // Generic 8CH // ----------------------------------------------------------------------------- diff --git a/code/espurna/migrate.ino b/code/espurna/migrate.ino index de7476fb..a55e82bd 100644 --- a/code/espurna/migrate.ino +++ b/code/espurna/migrate.ino @@ -698,6 +698,19 @@ void migrate() { setSetting("chLogic", 3, 0); setSetting("relays", 1); + #elif defined(KMC_70011) + + setSetting("board", 53); + setSetting("ledGPIO", 0, 13); + setSetting("ledLogic", 0, 0); + setSetting("btnGPIO", 0, 0); + setSetting("btnRelay", 0, 0); + setSetting("relayGPIO", 0, 14); + setSetting("relayType", 0, RELAY_TYPE_NORMAL); + setSetting("selGPIO", 12); + setSetting("cf1GPIO", 5); + setSetting("cfGPIO", 4); + #else // Allow users to define new settings without migration config diff --git a/code/platformio.ini b/code/platformio.ini index 407a333b..dff76b69 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -1386,6 +1386,31 @@ upload_flags = --auth=fibonacci --port 8266 monitor_baud = 115200 extra_scripts = ${common.extra_scripts} +[env:kmc-70011] +platform = ${common.platform} +framework = arduino +board = esp01_1m +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m} -DKMC_70011 +monitor_baud = 115200 +extra_scripts = ${common.extra_scripts} + +[env:kmc-70011-ota] +platform = ${common.platform} +framework = arduino +board = esp01_1m +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m} -DKMC_70011 +upload_speed = 115200 +upload_port = "192.168.4.1" +upload_flags = --auth=fibonacci --port 8266 +monitor_baud = 115200 +extra_scripts = ${common.extra_scripts} + [env:yjzk-switch-2ch] platform = ${common.platform} framework = arduino