diff --git a/code/espurna/api.ino b/code/espurna/api.ino index 705fee17..f65f03f9 100644 --- a/code/espurna/api.ino +++ b/code/espurna/api.ino @@ -221,6 +221,7 @@ void apiRegister(const char * key, api_get_callback_f getFn, api_put_callback_f } void apiSetup() { + _apiConfigure(); wsOnSendRegister(_apiWebSocketOnSend); wsOnReceiveRegister(_apiWebSocketOnReceive); webRequestRegister(_apiRequestCallback); diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 2ab3040c..307c6eb7 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -237,6 +237,9 @@ #ifndef BUTTON_LNGLNGCLICK_DELAY #define BUTTON_LNGLNGCLICK_DELAY 10000 // Time in ms holding the button down to get a long-long click +#endif + +#ifndef BUTTON_MQTT_SEND_ALL_EVENTS #define BUTTON_MQTT_SEND_ALL_EVENTS 0 // 0 - to send only events the are bound to actions // 1 - to send all button events to MQTT #endif @@ -435,7 +438,9 @@ // or in the Internet. Since the WebUI is just one compressed file with HTML, CSS and JS // there are no special requirements. Any static web server will do (NGinx, Apache, Lighttpd,...). // The only requirement is that the resource must be available under this domain. +#ifndef WEB_REMOTE_DOMAIN #define WEB_REMOTE_DOMAIN "http://tinkerman.cat" +#endif // ----------------------------------------------------------------------------- // WEBSOCKETS @@ -927,8 +932,13 @@ #define HOMEASSISTANT_SUPPORT MQTT_SUPPORT // Build with home assistant support (if MQTT, 1.64Kb) #endif +#ifndef HOMEASSISTANT_ENABLED #define HOMEASSISTANT_ENABLED 0 // Integration not enabled by default +#endif + +#ifndef HOMEASSISTANT_PREFIX #define HOMEASSISTANT_PREFIX "homeassistant" // Default MQTT prefix +#endif #ifndef HOMEASSISTANT_PAYLOAD_ON #define HOMEASSISTANT_PAYLOAD_ON "1" // Payload for ON and available messages diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index ee048c94..a45237a4 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -2576,6 +2576,47 @@ #define HLW8012_POWER_RATIO 3414290 #define HLW8012_INTERRUPT_ON FALLING +// ----------------------------------------------------------------------------- +// Same as the above but new board version marked V2.3 +// ----------------------------------------------------------------------------- + +#elif defined(BLITZWOLF_BWSHP2_V23) + + // Info + #define MANUFACTURER "BLITZWOLF" + #define DEVICE "BWSHP2V2.3" + + // Buttons + #define BUTTON1_PIN 3 + #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 1 + #define LED1_PIN_INVERSE 1 + #define LED2_PIN 13 + #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 5 + #define HLW8012_CF_PIN 4 + + #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/espurna/sensor.ino b/code/espurna/sensor.ino index f2983eda..b3b0dcff 100644 --- a/code/espurna/sensor.ino +++ b/code/espurna/sensor.ino @@ -282,7 +282,7 @@ void _sensorInitCommands() { DEBUG_MSG_P(PSTR("[SENSOR] PZEM004T\n")); unsigned char dev_count = pzem004t_sensor->getAddressesCount(); for(unsigned char dev = 0; dev < dev_count; dev++) { - DEBUG_MSG_P(PSTR("Device %d Address %s\n"), dev, pzem004t_sensor->getAddress(dev).c_str()); + DEBUG_MSG_P(PSTR("Device %d/%s\n"), dev, pzem004t_sensor->getAddress(dev).c_str()); } DEBUG_MSG_P(PSTR("+OK\n")); } else if(e->argc == 2) { @@ -299,7 +299,7 @@ void _sensorInitCommands() { } }); settingsRegisterCommand(F("PZ.RESET"), [](Embedis* e) { - if(e->argc > 2) { + if(e->argc > 2) { DEBUG_MSG_P(PSTR("-ERROR: Wrong arguments\n")); } else { unsigned char init = e->argc == 2 ? String(e->argv[1]).toInt() : 0; @@ -308,7 +308,7 @@ void _sensorInitCommands() { for(unsigned char dev = init; dev < limit; dev++) { float offset = pzem004t_sensor->resetEnergy(dev); setSetting("pzEneTotal", dev, offset); - DEBUG_MSG_P(PSTR("Device %d Address %s - Offset: %s\n"), dev, pzem004t_sensor->getAddress(dev).c_str(), String(offset).c_str()); + DEBUG_MSG_P(PSTR("Device %d/%s - Offset: %s\n"), dev, pzem004t_sensor->getAddress(dev).c_str(), String(offset).c_str()); } DEBUG_MSG_P(PSTR("+OK\n")); } diff --git a/code/espurna/sensors/PZEM004TSensor.h b/code/espurna/sensors/PZEM004TSensor.h index 5f643ae9..8f5fda3f 100644 --- a/code/espurna/sensors/PZEM004TSensor.h +++ b/code/espurna/sensors/PZEM004TSensor.h @@ -3,6 +3,48 @@ // Copyright (C) 2018 by Xose PĂ©rez // ----------------------------------------------------------------------------- +// Connection Diagram: +// ------------------- +// +// Needed when connecting multiple PZEM004T devices on the same UART +// *You must set the PZEM004T device address prior using this configuration* +// +// +---------+ +// | ESPurna | +VCC +// | Node | ^ +// | G T R | | +// +-+--+--+-+ R (10K) +// | | | | +// | | +-----------------+---------------+---------------+ +// | +-----------------+--|------------+--|------------+ | +// +-----------------+--|--|---------+--|--|---------+ | | +// | | | | | | | | | +// | | V | | V | | V +// | | - | | - | | - +// +-+--+--+-+ +-+--+--+-+ +-+--+--+-+ +// | G R T | | G R T | | G R T | +// |PZEM-004T| |PZEM-004T| |PZEM-004T| +// | Module | | Module | | Module | +// +---------+ +---------+ +---------+ +// +// Where: +// ------ +// G = GND +// R = ESPurna UART RX +// T = ESPurna UART TX +// V = Small Signal Schottky Diode, like BAT43, +// Cathode to PZEM TX, Anode to Espurna RX +// R = Resistor to VCC, 10K +// +// More Info: +// ---------- +// See ESPurna Wiki - https://github.com/xoseperez/espurna/wiki/Sensor-PZEM004T +// +// Reference: +// ---------- +// UART/TTL-Serial network with single master and multiple slaves: +// http://cool-emerald.blogspot.com/2009/10/multidrop-network-for-rs232.html + #if SENSOR_SUPPORT && PZEM004T_SUPPORT #pragma once diff --git a/code/platformio.ini b/code/platformio.ini index 265d4b4e..e5f1fc3a 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -2551,6 +2551,32 @@ upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} extra_scripts = ${common.extra_scripts} +[env:blitzwolf-bwshp2-v23] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board_1m} +board_build.flash_mode = ${common.flash_mode} +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m0m} -DBLITZWOLF_BWSHP2_V23 +upload_speed = ${common.upload_speed} +monitor_speed = ${common.monitor_speed} +extra_scripts = ${common.extra_scripts} + +[env:blitzwolf-bwshp2-v23-ota] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board_1m} +board_build.flash_mode = ${common.flash_mode} +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m0m} -DBLITZWOLF_BWSHP2_V23 +upload_speed = ${common.upload_speed} +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_flags = ${common.upload_flags} +extra_scripts = ${common.extra_scripts} + [env:homecube-16a] platform = ${common.platform} framework = ${common.framework}