diff --git a/README.md b/README.md index d903ab2e..4732fbda 100644 --- a/README.md +++ b/README.md @@ -243,10 +243,15 @@ Here is the list of supported hardware. For more information please refer to the |**Heltec Touch Relay**|**Generic Relay v4.0**|**Generic RGBLed v1.0**| |![Generic DHT11 v1.0](images/devices/generic-dht11-10.jpg)|![Generic DS18B20 v1.0](images/devices/generic-ds18b20-10.jpg)|| |**Generic DHT11 v1.0**|**Generic DS18B20 v1.0**|| +|![Tonbux Mosquito Killer](images/devices/tonbux-mosquito-killer.jpg)||| +|**Tonbux Mosquito Killer**||| **Other supported boards:** IteadStudio Sonoff S31, IteadStudio Sonoff POW R2, Zhilde ZLD-EU55-W, Luani HVIO +**Other supported boards (beta):** +KMC 4 Outlet, Gosund WS1, Smart Dual Plug, MakerFocus Intelligent Module LM33 for Lamps + ## License Copyright (C) 2016-2018 by Xose PĂ©rez (@xoseperez) diff --git a/code/espurna/config/arduino.h b/code/espurna/config/arduino.h index 4a5cf455..cc41efd9 100644 --- a/code/espurna/config/arduino.h +++ b/code/espurna/config/arduino.h @@ -81,6 +81,7 @@ //#define ZHILDE_EU44_W //#define LUANI_HVIO //#define ALLNET_4DUINO_IOT_WLAN_RELAIS +//#define TONBUX_MOSQUITO_KILLER //#define PILOTAK_ESP_DIN_V1 //-------------------------------------------------------------------------------- diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 9a53400b..5069215c 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -2112,6 +2112,41 @@ #define LED1_PIN 15 #define LED1_PIN_INVERSE 0 +// ----------------------------------------------------------------------------- +// Tonbux 50-100M Smart Mosquito Killer USB +// https://www.aliexpress.com/item/Original-Tonbux-50-100M-Smart-Mosquito-Killer-USB-Plug-No-Noise-Repellent-App-Smart-Module/32859330820.html +// ----------------------------------------------------------------------------- + +#elif defined(TONBUX_MOSQUITO_KILLER) + + // Info + #define MANUFACTURER "TONBUX" + #define DEVICE "MOSQUITO_KILLER" + + // Buttons + #define BUTTON1_PIN 2 + #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON1_RELAY 1 + + // Relays + #define RELAY1_PIN 5 // not a relay, fan + #define RELAY1_TYPE RELAY_TYPE_NORMAL + + // LEDs + #define LED1_PIN 15 // blue led + #define LED1_PIN_INVERSE 1 + #define LED1_MODE LED_MODE_WIFI + #define LED2_PIN 14 // red led + #define LED2_PIN_INVERSE 1 + #define LED2_MODE LED_MODE_RELAY + + #define LED3_PIN 12 // UV leds (1-2-3-4-5-6-7-8) + #define LED3_PIN_INVERSE 0 + #define LED3_RELAY 1 + #define LED4_PIN 16 // UV leds (9-10-11) + #define LED4_PIN_INVERSE 0 + #define LED4_RELAY 1 + // ----------------------------------------------------------------------------- // TEST boards (do not use!!) // ----------------------------------------------------------------------------- diff --git a/code/espurna/migrate.ino b/code/espurna/migrate.ino index b50cbd5e..44123421 100644 --- a/code/espurna/migrate.ino +++ b/code/espurna/migrate.ino @@ -937,9 +937,25 @@ void migrate() { setSetting("relayResetGPIO", 0, 12); setSetting("relayType", 0, RELAY_TYPE_LATCHED); - #elif defined(PILOTAK_ESP_DIN_V1) + #elif defined(TONBUX_MOSQUITO_KILLER) - setSetting("board", 70); + setSetting("board", 74); + setSetting("ledGPIO", 0, 15); + setSetting("ledLogic", 0, 1); + setSetting("ledGPIO", 1, 14); + setSetting("ledLogic", 1, 1); + setSetting("ledGPIO", 2, 12); + setSetting("ledLogic", 2, 0); + setSetting("ledGPIO", 3, 16); + setSetting("ledLogic", 3, 0); + setSetting("btnGPIO", 0, 2); + setSetting("btnRelay", 0, 0); + setSetting("relayGPIO", 0, 5); + setSetting("relayType", 0, RELAY_TYPE_NORMAL); + + #elif defined(PILOTAK_ESP_DIN_V1) + + setSetting("board", 75); setSetting("ledGPIO", 0, 16); setSetting("ledLogic", 0, 0); setSetting("btnGPIO", 0, 0); diff --git a/code/espurna/sensors/PZEM004TSensor.h b/code/espurna/sensors/PZEM004TSensor.h index 2adc71e9..29635fd6 100644 --- a/code/espurna/sensors/PZEM004TSensor.h +++ b/code/espurna/sensors/PZEM004TSensor.h @@ -20,9 +20,10 @@ class PZEM004TSensor : public BaseSensor { // Public // --------------------------------------------------------------------- - PZEM004TSensor(): BaseSensor(), _data() { + PZEM004TSensor(): BaseSensor() { _count = 4; _sensor_id = SENSOR_PZEM004T_ID; + _ip = IPAddress(192,168,1,1); } ~PZEM004TSensor() { @@ -43,7 +44,7 @@ class PZEM004TSensor : public BaseSensor { _dirty = true; } - void setSerial(Stream & serial) { + void setSerial(HardwareSerial * serial) { _serial = serial; _dirty = true; } @@ -58,10 +59,6 @@ class PZEM004TSensor : public BaseSensor { return _pin_tx; } - Stream & getSerial() { - return _serial; - } - // --------------------------------------------------------------------- // Sensor API // --------------------------------------------------------------------- @@ -72,10 +69,10 @@ class PZEM004TSensor : public BaseSensor { if (!_dirty) return; if (_pzem) delete _pzem; - if (_serial == NULL) { - _pzem = PZEM004T(_pin_rx, _pin_tx); + if (_serial) { + _pzem = new PZEM004T(_serial); } else { - _pzem = PZEM004T(_serial); + _pzem = new PZEM004T(_pin_rx, _pin_tx); } _pzem->setAddress(_ip); @@ -127,8 +124,8 @@ class PZEM004TSensor : public BaseSensor { unsigned int _pin_rx = PZEM004T_RX_PIN; unsigned int _pin_tx = PZEM004T_TX_PIN; - Stream & _serial = NULL; - IPAddress _ip(192,168,1,1); + IPAddress _ip; + HardwareSerial * _serial = NULL; PZEM004T * _pzem = NULL; }; diff --git a/code/espurna/wifi.ino b/code/espurna/wifi.ino index 554730a7..8fc2e23f 100644 --- a/code/espurna/wifi.ino +++ b/code/espurna/wifi.ino @@ -198,6 +198,8 @@ void _wifiInject() { #if WIFI_AP_CAPTIVE +#include "DNSServer.h" + DNSServer _wifi_dnsServer; void _wifiCaptivePortal(justwifi_messages_t code, char * parameter) { diff --git a/code/platformio.ini b/code/platformio.ini index b68443e6..016347fb 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -64,7 +64,7 @@ lib_deps = https://bitbucket.org/xoseperez/fauxmoesp.git#2.4.2 https://github.com/xoseperez/hlw8012.git#1.1.0 https://github.com/markszabo/IRremoteESP8266#v2.2.0 - https://bitbucket.org/xoseperez/justwifi.git#1.1.8 + https://bitbucket.org/xoseperez/justwifi.git#1.1.9 https://github.com/madpilot/mDNSResolver#4cfcda1 https://github.com/xoseperez/my92xx#3.0.1 https://bitbucket.org/xoseperez/nofuss.git#0.2.5 @@ -2129,6 +2129,30 @@ upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 extra_scripts = ${common.extra_scripts} +[env:tonbux-mosquito-killer] +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} -DTONBUX_MOSQUITO_KILLER +monitor_baud = 115200 +extra_scripts = ${common.extra_scripts} + +[env:tonbux-mosquito-killer-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} -DTONBUX_MOSQUITO_KILLER +upload_speed = 115200 +upload_port = "${env.ESPURNA_IP}" +upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 +extra_scripts = ${common.extra_scripts} + [env:pilotak-esp-din-v1] platform = ${common.platform} framework = arduino diff --git a/images/devices/tonbux-mosquito-killer.jpg b/images/devices/tonbux-mosquito-killer.jpg new file mode 100644 index 00000000..dfed5f3c Binary files /dev/null and b/images/devices/tonbux-mosquito-killer.jpg differ