Browse Source

Merge branch 'dev' into CCT_Support

rfm69
Xose Pérez 6 years ago
committed by GitHub
parent
commit
fb55cd202e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 195 additions and 17 deletions
  1. +5
    -0
      README.md
  2. +2
    -0
      code/espurna/config/arduino.h
  3. +78
    -0
      code/espurna/config/hardware.h
  4. +1
    -1
      code/espurna/config/version.h
  5. +1
    -2
      code/espurna/homeassistant.ino
  6. +8
    -2
      code/espurna/light.ino
  7. +23
    -0
      code/espurna/migrate.ino
  8. +8
    -11
      code/espurna/sensors/PZEM004TSensor.h
  9. +9
    -0
      code/espurna/telnet.ino
  10. +9
    -0
      code/espurna/utils.ino
  11. +2
    -0
      code/espurna/wifi.ino
  12. +49
    -1
      code/platformio.ini
  13. BIN
      images/devices/tonbux-mosquito-killer.jpg

+ 5
- 0
README.md View File

@ -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**| |**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](images/devices/generic-dht11-10.jpg)|![Generic DS18B20 v1.0](images/devices/generic-ds18b20-10.jpg)||
|**Generic DHT11 v1.0**|**Generic DS18B20 v1.0**|| |**Generic DHT11 v1.0**|**Generic DS18B20 v1.0**||
|![Tonbux Mosquito Killer](images/devices/tonbux-mosquito-killer.jpg)|||
|**Tonbux Mosquito Killer**|||
**Other supported boards:** **Other supported boards:**
IteadStudio Sonoff S31, IteadStudio Sonoff POW R2, Zhilde ZLD-EU55-W, Luani HVIO 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 ## License
Copyright (C) 2016-2018 by Xose Pérez (@xoseperez) Copyright (C) 2016-2018 by Xose Pérez (@xoseperez)


+ 2
- 0
code/espurna/config/arduino.h View File

@ -80,6 +80,8 @@
//#define HELTEC_TOUCHRELAY //#define HELTEC_TOUCHRELAY
//#define ZHILDE_EU44_W //#define ZHILDE_EU44_W
//#define LUANI_HVIO //#define LUANI_HVIO
//#define ALLNET_4DUINO_IOT_WLAN_RELAIS
//#define TONBUX_MOSQUITO_KILLER
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// Features (values below are non-default values) // Features (values below are non-default values)


+ 78
- 0
code/espurna/config/hardware.h View File

@ -1904,6 +1904,7 @@
// LEDs // LEDs
#define LED1_PIN 2 #define LED1_PIN 2
#define LED1_PIN_INVERSE 0
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -1996,6 +1997,48 @@
#define LED1_PIN 1 #define LED1_PIN 1
#define LED1_PIN_INVERSE 1 #define LED1_PIN_INVERSE 1
// -----------------------------------------------------------------------------
// Allnet 4duino ESP8266-UP-Relais
// http://www.allnet.de/de/allnet-brand/produkte/neuheiten/p/allnet-4duino-iot-wlan-relais-unterputz-esp8266-up-relais/
// https://shop.allnet.de/fileadmin/transfer/products/148814.pdf
// -----------------------------------------------------------------------------
#elif defined(ALLNET_4DUINO_IOT_WLAN_RELAIS)
// Info
#define MANUFACTURER "ALLNET"
#define DEVICE "4DUINO_IOT_WLAN_RELAIS"
// Relays
#define RELAY1_PIN 14
#define RELAY1_RESET_PIN 12
#define RELAY1_TYPE RELAY_TYPE_LATCHED
// LEDs
#define LED1_PIN 0
#define LED1_PIN_INVERSE 1
// Buttons
//#define BUTTON1_PIN 0
//#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
// Using pins labelled as SDA & SCL as buttons
#define BUTTON2_PIN 4
#define BUTTON2_MODE BUTTON_PUSHBUTTON
#define BUTTON2_PRESS BUTTON_MODE_TOGGLE
#define BUTTON2_CLICK BUTTON_MODE_NONE
#define BUTTON2_DBLCLICK BUTTON_MODE_NONE
#define BUTTON2_LNGCLICK BUTTON_MODE_NONE
#define BUTTON2_LNGLNGCLICK BUTTON_MODE_NONE
#define BUTTON3_PIN 5
#define BUTTON3_MODE BUTTON_PUSHBUTTON
// Using pins labelled as SDA & SCL for I2C
//#define I2C_SDA_PIN 4
//#define I2C_SCL_PIN 5
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Luani HVIO // Luani HVIO
// https://luani.de/projekte/esp8266-hvio/ // https://luani.de/projekte/esp8266-hvio/
@ -2029,6 +2072,41 @@
#define LED1_PIN 15 #define LED1_PIN 15
#define LED1_PIN_INVERSE 0 #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!!) // TEST boards (do not use!!)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------


+ 1
- 1
code/espurna/config/version.h View File

@ -1,6 +1,6 @@
#define APP_NAME "ESPURNA" #define APP_NAME "ESPURNA"
#define APP_VERSION "1.12.6" #define APP_VERSION "1.12.6"
#define APP_REVISION ""
#define APP_REVISION "db84006"
#define APP_AUTHOR "xose.perez@gmail.com" #define APP_AUTHOR "xose.perez@gmail.com"
#define APP_WEBSITE "http://tinkerman.cat" #define APP_WEBSITE "http://tinkerman.cat"
#define CFG_VERSION 3 #define CFG_VERSION 3

+ 1
- 2
code/espurna/homeassistant.ino View File

@ -24,9 +24,8 @@ void _haSendMagnitude(unsigned char i, JsonObject& config) {
unsigned char type = magnitudeType(i); unsigned char type = magnitudeType(i);
config["name"] = getSetting("hostname") + String(" ") + magnitudeTopic(type); config["name"] = getSetting("hostname") + String(" ") + magnitudeTopic(type);
config.set("platform", "mqtt"); config.set("platform", "mqtt");
config.set("device_class", "sensor");
config["state_topic"] = mqttTopic(magnitudeTopicIndex(i).c_str(), false); config["state_topic"] = mqttTopic(magnitudeTopicIndex(i).c_str(), false);
config["unit_of_measurement"] = String("\"") + magnitudeUnits(type) + String("\"");
config["unit_of_measurement"] = magnitudeUnits(type);
} }


+ 8
- 2
code/espurna/light.ino View File

@ -141,7 +141,7 @@ void _generateBrightness() {
} else { } else {
// Don't apply brightness, it is already in the inputValue:
// Don't apply brightness, it is already in the target:
for (unsigned char i=0; i < _light_channel.size(); i++) { for (unsigned char i=0; i < _light_channel.size(); i++) {
if (_light_has_color & (i<3)) { if (_light_has_color & (i<3)) {
_light_channel[i].value = _light_channel[i].inputValue * brightness; _light_channel[i].value = _light_channel[i].inputValue * brightness;
@ -417,6 +417,7 @@ unsigned int _toPWM(unsigned char id) {
} }
void _shadow() { void _shadow() {
// Update transition ticker // Update transition ticker
_light_steps_left--; _light_steps_left--;
if (_light_steps_left == 0) _light_transition_ticker.detach(); if (_light_steps_left == 0) _light_transition_ticker.detach();
@ -424,15 +425,20 @@ void _shadow() {
// Transitions // Transitions
unsigned char target; unsigned char target;
for (unsigned int i=0; i < _light_channel.size(); i++) { for (unsigned int i=0; i < _light_channel.size(); i++) {
target = _light_state ? _light_channel[i].value : 0;
target = _light_state && _light_channel[i].state ? _light_channel[i].value : 0;
if (_light_steps_left == 0) { if (_light_steps_left == 0) {
_light_channel[i].current = target; _light_channel[i].current = target;
} else { } else {
double difference = (double) (target - _light_channel[i].current) / (_light_steps_left + 1); double difference = (double) (target - _light_channel[i].current) / (_light_steps_left + 1);
_light_channel[i].current = _light_channel[i].current + difference; _light_channel[i].current = _light_channel[i].current + difference;
} }
_light_channel[i].shadow = _light_channel[i].current; _light_channel[i].shadow = _light_channel[i].current;
} }
} }
void _lightProviderUpdate() { void _lightProviderUpdate() {


+ 23
- 0
code/espurna/migrate.ino View File

@ -930,6 +930,29 @@ void migrate() {
setSetting("relayGPIO", 1, 5); setSetting("relayGPIO", 1, 5);
setSetting("relayType", 1, RELAY_TYPE_NORMAL); setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ALLNET_4DUINO_IOT_WLAN_RELAIS)
setSetting("board", 73);
setSetting("relayGPIO", 0, 14);
setSetting("relayResetGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_LATCHED);
#elif defined(TONBUX_MOSQUITO_KILLER)
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);
#else #else
// Allow users to define new settings without migration config // Allow users to define new settings without migration config


+ 8
- 11
code/espurna/sensors/PZEM004TSensor.h View File

@ -20,9 +20,10 @@ class PZEM004TSensor : public BaseSensor {
// Public // Public
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
PZEM004TSensor(): BaseSensor(), _data() {
PZEM004TSensor(): BaseSensor() {
_count = 4; _count = 4;
_sensor_id = SENSOR_PZEM004T_ID; _sensor_id = SENSOR_PZEM004T_ID;
_ip = IPAddress(192,168,1,1);
} }
~PZEM004TSensor() { ~PZEM004TSensor() {
@ -43,7 +44,7 @@ class PZEM004TSensor : public BaseSensor {
_dirty = true; _dirty = true;
} }
void setSerial(Stream & serial) {
void setSerial(HardwareSerial * serial) {
_serial = serial; _serial = serial;
_dirty = true; _dirty = true;
} }
@ -58,10 +59,6 @@ class PZEM004TSensor : public BaseSensor {
return _pin_tx; return _pin_tx;
} }
Stream & getSerial() {
return _serial;
}
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Sensor API // Sensor API
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
@ -72,10 +69,10 @@ class PZEM004TSensor : public BaseSensor {
if (!_dirty) return; if (!_dirty) return;
if (_pzem) delete _pzem; if (_pzem) delete _pzem;
if (_serial == NULL) {
_pzem = PZEM004T(_pin_rx, _pin_tx);
if (_serial) {
_pzem = new PZEM004T(_serial);
} else { } else {
_pzem = PZEM004T(_serial);
_pzem = new PZEM004T(_pin_rx, _pin_tx);
} }
_pzem->setAddress(_ip); _pzem->setAddress(_ip);
@ -127,8 +124,8 @@ class PZEM004TSensor : public BaseSensor {
unsigned int _pin_rx = PZEM004T_RX_PIN; unsigned int _pin_rx = PZEM004T_RX_PIN;
unsigned int _pin_tx = PZEM004T_TX_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; PZEM004T * _pzem = NULL;
}; };


+ 9
- 0
code/espurna/telnet.ino View File

@ -66,6 +66,15 @@ void _telnetData(unsigned char clientId, void *data, size_t len) {
// Capture close connection // Capture close connection
char * p = (char *) data; char * p = (char *) data;
// C-d is sent as two bytes (sometimes repeating)
if (len >= 2) {
if ((p[0] == 0xFF) && (p[1] == 0xEC)) {
_telnetClients[clientId]->close(true);
return;
}
}
if ((strncmp(p, "close", 5) == 0) || (strncmp(p, "quit", 4) == 0)) { if ((strncmp(p, "close", 5) == 0) || (strncmp(p, "quit", 4) == 0)) {
_telnetClients[clientId]->close(); _telnetClients[clientId]->close();
return; return;


+ 9
- 0
code/espurna/utils.ino View File

@ -356,9 +356,15 @@ void info() {
#if ANALOG_SUPPORT #if ANALOG_SUPPORT
DEBUG_MSG_P(PSTR(" ANALOG")); DEBUG_MSG_P(PSTR(" ANALOG"));
#endif #endif
#if BH1750_SUPPORT
DEBUG_MSG_P(PSTR(" BH1750"));
#endif
#if BMX280_SUPPORT #if BMX280_SUPPORT
DEBUG_MSG_P(PSTR(" BMX280")); DEBUG_MSG_P(PSTR(" BMX280"));
#endif #endif
#if CSE7766_SUPPORT
DEBUG_MSG_P(PSTR(" CSE7766"));
#endif
#if DALLAS_SUPPORT #if DALLAS_SUPPORT
DEBUG_MSG_P(PSTR(" DALLAS")); DEBUG_MSG_P(PSTR(" DALLAS"));
#endif #endif
@ -401,6 +407,9 @@ void info() {
#if PZEM004T_SUPPORT #if PZEM004T_SUPPORT
DEBUG_MSG_P(PSTR(" PZEM004T")); DEBUG_MSG_P(PSTR(" PZEM004T"));
#endif #endif
#if SENSEAIR_SUPPORT
DEBUG_MSG_P(PSTR(" SENSEAIR"));
#endif
#if SHT3X_I2C_SUPPORT #if SHT3X_I2C_SUPPORT
DEBUG_MSG_P(PSTR(" SHT3X_I2C")); DEBUG_MSG_P(PSTR(" SHT3X_I2C"));
#endif #endif


+ 2
- 0
code/espurna/wifi.ino View File

@ -198,6 +198,8 @@ void _wifiInject() {
#if WIFI_AP_CAPTIVE #if WIFI_AP_CAPTIVE
#include "DNSServer.h"
DNSServer _wifi_dnsServer; DNSServer _wifi_dnsServer;
void _wifiCaptivePortal(justwifi_messages_t code, char * parameter) { void _wifiCaptivePortal(justwifi_messages_t code, char * parameter) {


+ 49
- 1
code/platformio.ini View File

@ -64,7 +64,7 @@ lib_deps =
https://bitbucket.org/xoseperez/fauxmoesp.git#2.4.2 https://bitbucket.org/xoseperez/fauxmoesp.git#2.4.2
https://github.com/xoseperez/hlw8012.git#1.1.0 https://github.com/xoseperez/hlw8012.git#1.1.0
https://github.com/markszabo/IRremoteESP8266#v2.2.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/madpilot/mDNSResolver#4cfcda1
https://github.com/xoseperez/my92xx#3.0.1 https://github.com/xoseperez/my92xx#3.0.1
https://bitbucket.org/xoseperez/nofuss.git#0.2.5 https://bitbucket.org/xoseperez/nofuss.git#0.2.5
@ -2104,3 +2104,51 @@ upload_speed = 115200
upload_port = "${env.ESPURNA_IP}" upload_port = "${env.ESPURNA_IP}"
upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266
extra_scripts = ${common.extra_scripts} extra_scripts = ${common.extra_scripts}
[env:allnet-4duino-iot-wlan-relais]
platform = ${common.platform}
framework = arduino
board = esp12e
board_flash_mode = dout
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m} -DALLNET_4DUINO_IOT_WLAN_RELAIS
monitor_baud = 115200
extra_scripts = ${common.extra_scripts}
[env:allnet-4duino-iot-wlan-relais-ota]
platform = ${common.platform}
framework = arduino
board = esp12e
board_flash_mode = dout
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m} -DALLNET_4DUINO_IOT_WLAN_RELAIS
upload_speed = 115200
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}

BIN
images/devices/tonbux-mosquito-killer.jpg View File

Before After
Width: 400  |  Height: 400  |  Size: 16 KiB

Loading…
Cancel
Save