From e859f2bbf726b4c2bedb65c04c41ebb68e374f31 Mon Sep 17 00:00:00 2001 From: "Alex. Tircovnicu" Date: Sun, 27 Sep 2020 04:03:32 +0200 Subject: [PATCH] hw: add support for Gosund SP111 (hardware version 1.1 16A) (#2369) --- code/espurna/config/arduino.h | 1 + code/espurna/config/hardware.h | 43 ++++++++++++++++++++++++++++++++++ code/platformio.ini | 4 ++++ 3 files changed, 48 insertions(+) diff --git a/code/espurna/config/arduino.h b/code/espurna/config/arduino.h index 3caae5de..7c8b6655 100644 --- a/code/espurna/config/arduino.h +++ b/code/espurna/config/arduino.h @@ -64,6 +64,7 @@ //#define GENERIC_GU10 //#define GENERIC_V9261F //#define GIZWITS_WITTY_CLOUD +//#define GOSUND_SP111 //#define GOSUND_WP3 //#define GOSUND_WS1 //#define GREEN_ESP8266RELAY diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 2ff8b2db..feb9dbb5 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -3421,6 +3421,49 @@ // LED1 is using TX pin #define DEBUG_SERIAL_SUPPORT 0 +// ---------------------------------------------------------------------------------------- +// Power socket 16A similar to BLITZWOLF_BWSHPX but button pin differs +// IMPORTANT, This template is for hardware version SP111_A_Wifi_Ver1.1 (as printed on the PCB) +// hhttps://www.amazon.de/-/en/Smallest-Consumption-Measuring-Function-Compatible/dp/B07PSMF47W +// ---------------------------------------------------------------------------------------- + +#elif defined(GOSUND_SP111) + + // Info + #define MANUFACTURER "GOSUND" + #define DEVICE "SP111" + + // Buttons + #define BUTTON1_PIN 13 + #define BUTTON1_CONFIG BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON1_RELAY 1 + + // Relays + #define RELAY1_PIN 15 + #define RELAY1_TYPE RELAY_TYPE_NORMAL + + // LEDs + #define LED1_PIN 2 + #define LED1_PIN_INVERSE 1 + #define LED2_PIN 0 + #define LED2_PIN_INVERSE 1 + #define LED2_MODE LED_MODE_FINDME + #define LED2_RELAY 1 + + // HJL01 / BL0937 + #ifndef HLW8012_SUPPORT + #define HLW8012_SUPPORT 1 + #endif + #define HLW8012_SEL_PIN 12 + #define HLW8012_CF1_PIN 4 + #define HLW8012_CF_PIN 5 + + #define HLW8012_SEL_CURRENT LOW + #define HLW8012_CURRENT_RATIO 25740 + #define HLW8012_VOLTAGE_RATIO 313400 + #define HLW8012_POWER_RATIO 3414290 + #define HLW8012_INTERRUPT_ON FALLING + // ---------------------------------------------------------------------------------------- // Homecube 16A is similar but some pins differ and it also has RGB LEDs // https://www.amazon.de/gp/product/B07D7RVF56/ref=oh_aui_detailpage_o00_s01?ie=UTF8&psc=1 diff --git a/code/platformio.ini b/code/platformio.ini index 5c1c5ebb..9e1ca4a1 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -869,6 +869,10 @@ src_build_flags = -DGOSUND_WP3 extends = env:esp8266-1m-base src_build_flags = -DGOSUND_WS1 +[env:gosund-sp111] +extends = env:esp8266-1m-base +src_build_flags = -DGOSUND_SP111 + [env:digoo-nx-sp202] extends = env:esp8266-1m-base src_build_flags = -DDIGOO_NX_SP202