diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index cfcbde1f..3d2cb18d 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -95,178 +95,140 @@ enum boards { BOARD_TINKERMAN_RFM69GW, BOARD_ITEAD_SONOFF_IFAN02, BOARD_GENERIC_AG_L4, + BOARD_HOMECUBE_16A, BOARD_LAST }; // ----------------------------------------------------------------------------- -// Development boards -// ----------------------------------------------------------------------------- - -#if defined(NODEMCU_LOLIN) +// Board => Image type +// ----------------------------------------------------------------------------- + +#if \ + defined(ALLNET_4DUINO_IOT_WLAN_RELAIS) || \ + defined(ARNIEX_SWIFITCH) || \ + defined(BH_ONOFRE) || \ + defined(ELECTRODRAGON_WIFI_IOT) || \ + defined(ESTINK_WIFI_POWER_STRIP) || \ + defined(EUROMATE_WIFI_STECKER_SCHUKO) || \ + defined(EXS_WIFI_RELAY_V31) || \ + defined(GENERIC_8CH) || \ + defined(GENERIC_ESP01S_RELAY_V40) || \ + defined(GENERIC_ESP01S_RGBLED_V10) || \ + defined(GREEN_ESP8266RELAY) || \ + defined(HELTEC_TOUCHRELAY) || \ + defined(HEYGO_HY02) || \ + defined(IKE_ESPIKE) || \ + defined(ITEAD_1CH_INCHING) || \ + defined(ITEAD_MOTOR) || \ + defined(ITEAD_S20) || \ + defined(ITEAD_SLAMPHER) || \ + defined(ITEAD_SONOFF_4CH) || \ + defined(ITEAD_SONOFF_4CH_PRO) || \ + defined(ITEAD_SONOFF_BASIC) || \ + defined(ITEAD_SONOFF_DUAL_R2) || \ + defined(ITEAD_SONOFF_IFAN02) || \ + defined(ITEAD_SONOFF_RF) || \ + defined(ITEAD_SONOFF_SV) || \ + defined(ITEAD_SONOFF_T1_1CH) || \ + defined(ITEAD_SONOFF_T1_2CH) || \ + defined(ITEAD_SONOFF_T1_3CH) || \ + defined(ITEAD_SONOFF_TOUCH) || \ + defined(JANGOE_WIFI_RELAY_NC) || \ + defined(JANGOE_WIFI_RELAY_NO) || \ + defined(JORGEGARCIA_WIFI_RELAYS) || \ + defined(LINGAN_SWA1) || \ + defined(LUANI_HVIO) || \ + defined(NEO_COOLCAM_NAS_WR01W) || \ + defined(NODEMCU_LOLIN) || \ + defined(OPENENERGYMONITOR_MQTT_RELAY) || \ + defined(TINKERMAN_ESPURNA_SWITCH) || \ + defined(TONBUX_MOSQUITO_KILLER) || \ + defined(TONBUX_POWERSTRIP02) || \ + defined(TONBUX_XSSSA06) || \ + defined(WEMOS_D1_MINI_RELAYSHIELD) || \ + defined(WION_50055) || \ + defined(WORKCHOICE_ECOPLUG) || \ + defined(XENON_SM_PW702U) || \ + defined(YJZK_SWITCH_2CH) || \ + defined(ZHILDE_EU44_W) + + #define ESPURNA_IMAGE ESPURNA_BASIC + +// ----------------------------------------------------------------------------- + +#elif \ + defined(BLITZWOLF_BWSHP2) || \ + defined(HOMECUBE_16A) || \ + defined(ITEAD_SONOFF_POW) || \ + defined(KMC_70011) || \ + defined(MAXCIO_WUS002S) || \ + defined(TINKERMAN_ESPURNA_H06) || \ + defined(TINKERMAN_ESPURNA_H08) || \ + defined(VANZAVANZU_SMART_WIFI_PLUG_MINI) || \ + defined(YIDIAN_XSSSA05) + + #define ESPURNA_IMAGE ESPURNA_HLW8012 + + +// ----------------------------------------------------------------------------- + +#elif \ + defined(ITEAD_SONOFF_POW_R2) || \ + defined(ITEAD_SONOFF_S31) + + #define ESPURNA_IMAGE ESPURNA_CSE77XX - #define ESPURNA_IMAGE ESPURNA_BASIC +// ----------------------------------------------------------------------------- -#elif defined(WEMOS_D1_MINI_RELAYSHIELD) +#elif defined(GENERIC_V9261F) - #define ESPURNA_IMAGE ESPURNA_BASIC + #define ESPURNA_IMAGE ESPURNA_V9261F // ----------------------------------------------------------------------------- -// ESPurna -// ----------------------------------------------------------------------------- - -#elif defined(TINKERMAN_ESPURNA_H06) - #define ESPURNA_IMAGE ESPURNA_POWER +#elif defined(GENERIC_ECH1560) - // HLW8012 - #ifndef HLW8012_SUPPORT - #define HLW8012_SUPPORT 1 - #endif - #define HLW8012_SEL_PIN 2 - #define HLW8012_CF1_PIN 13 - #define HLW8012_CF_PIN 14 + #define ESPURNA_IMAGE ESPURNA_ECH1560 -#elif defined(TINKERMAN_ESPURNA_H08) +// ----------------------------------------------------------------------------- - #define ESPURNA_IMAGE ESPURNA_POWER +#elif \ + defined(GENERIC_ESP01S_DHT11_V10) || \ + defined(GENERIC_ESP01S_DS18B20_V10) || \ + defined(ITEAD_SONOFF_TH) - // HLW8012 - #ifndef HLW8012_SUPPORT - #define HLW8012_SUPPORT 1 - #endif - #define HLW8012_SEL_PIN 5 - #define HLW8012_CF1_PIN 13 - #define HLW8012_CF_PIN 14 + #define ESPURNA_IMAGE ESPURNA_SENSOR -#elif defined(TINKERMAN_ESPURNA_SWITCH) - #define ESPURNA_IMAGE ESPURNA_BASIC +// ----------------------------------------------------------------------------- -// Check http://tinkerman.cat/rfm69-wifi-gateway/ #elif defined(TINKERMAN_RFM69GW) #define ESPURNA_IMAGE ESPURNA_RFM69 - // RFM69GW - #define RFM69_SUPPORT 1 - - // Disable non-core modules - #define ALEXA_SUPPORT 0 - #define DOMOTICZ_SUPPORT 0 - #define HOMEASSISTANT_SUPPORT 0 - #define I2C_SUPPORT 0 - #define SCHEDULER_SUPPORT 0 - #define SENSOR_SUPPORT 0 - #define THINGSPEAK_SUPPORT 0 - -// ----------------------------------------------------------------------------- -// Itead Studio boards // ----------------------------------------------------------------------------- -#elif defined(ITEAD_SONOFF_BASIC) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -#elif defined(ITEAD_SONOFF_RF) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -#elif defined(ITEAD_SONOFF_TH) - - #define ESPURNA_IMAGE ESPURNA_SENSOR - - // Jack is connected to GPIO14 (and with a small hack to GPIO4) - #ifndef DALLAS_SUPPORT - #define DALLAS_SUPPORT 1 - #endif - #define DALLAS_PIN 14 - - #ifndef DHT_SUPPORT - #define DHT_SUPPORT 1 - #endif - #define DHT_PIN 14 - -#elif defined(ITEAD_SONOFF_SV) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -#elif defined(ITEAD_SLAMPHER) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -#elif defined(ITEAD_S20) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -#elif defined(ITEAD_SONOFF_TOUCH) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -#elif defined(ITEAD_SONOFF_POW) - - #define ESPURNA_IMAGE ESPURNA_POWER - - // HLW8012 - #ifndef HLW8012_SUPPORT - #define HLW8012_SUPPORT 1 - #endif - #define HLW8012_SEL_PIN 5 - #define HLW8012_CF1_PIN 13 - #define HLW8012_CF_PIN 14 - -#elif defined(ITEAD_SONOFF_POW_R2) - - #define ESPURNA_IMAGE ESPURNA_POWER - - // Disable UART noise - #define DEBUG_SERIAL_SUPPORT 0 - - // CSE7766 - #ifndef CSE7766_SUPPORT - #define CSE7766_SUPPORT 1 - #endif - #define CSE7766_PIN 1 - #elif defined(ITEAD_SONOFF_DUAL) #define ESPURNA_IMAGE ESPURNA_SONOFF_DUAL - #define SERIAL_BAUDRATE 19230 - #define RELAY_PROVIDER RELAY_PROVIDER_DUAL - #define DEBUG_SERIAL_SUPPORT 0 - -#elif defined(ITEAD_SONOFF_DUAL_R2) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -#elif defined(ITEAD_SONOFF_4CH) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -#elif defined(ITEAD_SONOFF_4CH_PRO) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -#elif defined(ITEAD_1CH_INCHING) +// ----------------------------------------------------------------------------- - #define ESPURNA_IMAGE ESPURNA_BASIC +#elif defined(STM_RELAY) -#elif defined(ITEAD_MOTOR) + #define ESPURNA_IMAGE ESPURNA_STM - #define ESPURNA_IMAGE ESPURNA_BASIC +// ----------------------------------------------------------------------------- -#elif defined(ITEAD_BNSZ01) +#elif defined(GENERIC_GEIGER_COUNTER) - #define ESPURNA_IMAGE ESPURNA_LIGHT + #define ESPURNA_IMAGE ESPURNA_GEIGER - // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER - #define LIGHT_CHANNELS 1 - #define LIGHT_CH1_PIN 12 - #define LIGHT_CH1_INVERSE 0 +// ----------------------------------------------------------------------------- +// PENDING +// ----------------------------------------------------------------------------- #elif defined(ITEAD_SONOFF_RFBRIDGE) @@ -297,13 +259,44 @@ enum boards { #define DEBUG_SERIAL_SUPPORT 0 #endif +// ----------------------------------------------------------------------------- + +#elif defined(MANCAVEMADE_ESPLIVE) + + #define ESPURNA_IMAGE ESPURNA_SENSOR + + // DS18B20 + #define DALLAS_PIN 2 + #define DALLAS_UPDATE_INTERVAL 5000 + #define TEMPERATURE_MIN_CHANGE 1.0 + +// ----------------------------------------------------------------------------- + +#elif defined(PILOTAK_ESP_DIN_V1) + + #define ESPURNA_IMAGE ESPURNA_SENSOR + + #ifndef RF_SUPPORT + #define RF_SUPPORT 1 // Does this need the RFBRIDGE image? + #endif + #define RF_PIN 14 + +// ----------------------------------------------------------------------------- + +#elif defined(ITEAD_BNSZ01) + + #define ESPURNA_IMAGE ESPURNA_DIMMER + + // Info + #define LIGHT_CHANNELS 1 + #define LIGHT_CH1_PIN 12 + #define LIGHT_CH1_INVERSE 0 + #elif defined(ITEAD_SONOFF_B1) - #define ESPURNA_IMAGE ESPURNA_LIGHT + #define ESPURNA_IMAGE ESPURNA_MY92XX // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_MY92XX #define LIGHT_CHANNELS 5 #define MY92XX_MODEL MY92XX_MODEL_MY9231 #define MY92XX_CHIPS 2 @@ -315,79 +308,20 @@ enum boards { #elif defined(ITEAD_SONOFF_LED) - #define ESPURNA_IMAGE ESPURNA_LIGHT + #define ESPURNA_IMAGE ESPURNA_DIMMER // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define LIGHT_CHANNELS 2 #define LIGHT_CH1_PIN 12 // Cold white #define LIGHT_CH2_PIN 14 // Warm white #define LIGHT_CH1_INVERSE 0 #define LIGHT_CH2_INVERSE 0 -#elif defined(ITEAD_SONOFF_T1_1CH) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -#elif defined(ITEAD_SONOFF_T1_2CH) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -#elif defined(ITEAD_SONOFF_T1_3CH) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -#elif defined(ITEAD_SONOFF_S31) - - #define ESPURNA_IMAGE ESPURNA_POWER - - // Disable UART noise - #define DEBUG_SERIAL_SUPPORT 0 - - // CSE7766 - #define CSE7766_SUPPORT 1 - #define CSE7766_PIN 1 - -#elif defined(ITEAD_SONOFF_IFAN02) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -// ----------------------------------------------------------------------------- -// YJZK -// ----------------------------------------------------------------------------- - -#elif defined(YJZK_SWITCH_2CH) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -// ----------------------------------------------------------------------------- -// Electrodragon boards -// ----------------------------------------------------------------------------- - -#elif defined(ELECTRODRAGON_WIFI_IOT) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -// ----------------------------------------------------------------------------- -// WorkChoice ecoPlug -// ----------------------------------------------------------------------------- - -#elif defined(WORKCHOICE_ECOPLUG) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -// ----------------------------------------------------------------------------- -// AI Thinker -// ----------------------------------------------------------------------------- - #elif defined(AITHINKER_AI_LIGHT) - #define ESPURNA_IMAGE ESPURNA_LIGHT + #define ESPURNA_IMAGE ESPURNA_MY92XX // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_MY92XX #define LIGHT_CHANNELS 4 #define MY92XX_MODEL MY92XX_MODEL_MY9291 #define MY92XX_CHIPS 1 @@ -396,17 +330,11 @@ enum boards { #define MY92XX_COMMAND MY92XX_COMMAND_DEFAULT #define MY92XX_MAPPING 0, 1, 2, 3 -// ----------------------------------------------------------------------------- -// LED Controller -// ----------------------------------------------------------------------------- - #elif defined(MAGICHOME_LED_CONTROLLER) - #define ESPURNA_IMAGE ESPURNA_LIGHT + #define ESPURNA_IMAGE ESPURNA_DIMMER // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define DUMMY_RELAY_COUNT 1 #define LIGHT_CHANNELS 4 #define LIGHT_CH1_PIN 14 // RED @@ -425,11 +353,9 @@ enum boards { #elif defined(MAGICHOME_LED_CONTROLLER_20) - #define ESPURNA_IMAGE ESPURNA_LIGHT + #define ESPURNA_IMAGE ESPURNA_DIMMER // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define LIGHT_CHANNELS 4 #define LIGHT_CH1_PIN 5 // RED #define LIGHT_CH2_PIN 12 // GREEN @@ -445,17 +371,11 @@ enum boards { #define IR_RECEIVER_PIN 4 #define IR_BUTTON_SET 1 -// ----------------------------------------------------------------------------- -// HUACANXING H801 & H802 -// ----------------------------------------------------------------------------- - #elif defined(HUACANXING_H801) - #define ESPURNA_IMAGE ESPURNA_LIGHT + #define ESPURNA_IMAGE ESPURNA_DIMMER // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define DEBUG_PORT Serial1 #define SERIAL_RX_ENABLED 1 #define LIGHT_CHANNELS 5 @@ -472,11 +392,9 @@ enum boards { #elif defined(HUACANXING_H802) - #define ESPURNA_IMAGE ESPURNA_LIGHT + #define ESPURNA_IMAGE ESPURNA_DIMMER // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define DEBUG_PORT Serial1 #define SERIAL_RX_ENABLED 1 #define LIGHT_CHANNELS 4 @@ -489,186 +407,67 @@ enum boards { #define LIGHT_CH3_INVERSE 0 #define LIGHT_CH4_INVERSE 0 -// ----------------------------------------------------------------------------- -// Jan Goedeke Wifi Relay -// https://github.com/JanGoe/esp8266-wifi-relay -// ----------------------------------------------------------------------------- - -#elif defined(JANGOE_WIFI_RELAY_NC) - - #define ESPURNA_IMAGE ESPURNA_BASIC +#elif defined(INTERMITTECH_QUINLED) -#elif defined(JANGOE_WIFI_RELAY_NO) + #define ESPURNA_IMAGE ESPURNA_DIMMER - #define ESPURNA_IMAGE ESPURNA_BASIC + // Info + #define LIGHT_CHANNELS 2 + #define LIGHT_CH1_PIN 0 + #define LIGHT_CH2_PIN 2 + #define LIGHT_CH1_INVERSE 0 + #define LIGHT_CH2_INVERSE 0 -// ----------------------------------------------------------------------------- -// Jorge García Wifi+Relays Board Kit -// https://www.tindie.com/products/jorgegarciadev/wifi--relays-board-kit -// https://github.com/jorgegarciadev/wifikit -// ----------------------------------------------------------------------------- +#elif defined(ARILUX_AL_LC01) -#elif defined(JORGEGARCIA_WIFI_RELAYS) + #define ESPURNA_IMAGE ESPURNA_DIMMER - #define ESPURNA_IMAGE ESPURNA_BASIC + // Info + #define LIGHT_CHANNELS 3 + #define LIGHT_CH1_PIN 5 // RED + #define LIGHT_CH2_PIN 12 // GREEN + #define LIGHT_CH3_PIN 13 // BLUE + #define LIGHT_CH1_INVERSE 0 + #define LIGHT_CH2_INVERSE 0 + #define LIGHT_CH3_INVERSE 0 -// ----------------------------------------------------------------------------- -// WiFi MQTT Relay / Thermostat -// ----------------------------------------------------------------------------- +#elif defined(ARILUX_AL_LC02) -#elif defined(OPENENERGYMONITOR_MQTT_RELAY) + #define ESPURNA_IMAGE ESPURNA_DIMMER - #define ESPURNA_IMAGE ESPURNA_BASIC + // Info + #define LIGHT_CHANNELS 4 + #define LIGHT_CH1_PIN 12 // RED + #define LIGHT_CH2_PIN 5 // GREEN + #define LIGHT_CH3_PIN 13 // BLUE + #define LIGHT_CH4_PIN 15 // WHITE1 + #define LIGHT_CH1_INVERSE 0 + #define LIGHT_CH2_INVERSE 0 + #define LIGHT_CH3_INVERSE 0 + #define LIGHT_CH4_INVERSE 0 -// ----------------------------------------------------------------------------- -// WiOn 50055 Indoor Wi-Fi Wall Outlet & Tap -// https://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_id=114&ipn=icep&toolid=20004&campid=5338044841&mpre=http%3A%2F%2Fwww.ebay.com%2Fitm%2FWiOn-50050-Indoor-Wi-Fi-Outlet-Wireless-Switch-Programmable-Timer-%2F263112281551 -// https://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_id=114&ipn=icep&toolid=20004&campid=5338044841&mpre=http%3A%2F%2Fwww.ebay.com%2Fitm%2FWiOn-50055-Indoor-Wi-Fi-Wall-Tap-Monitor-Energy-Usage-Wireless-Smart-Switch-%2F263020837777 -// ----------------------------------------------------------------------------- +#elif defined(ARILUX_AL_LC06) -#elif defined(WION_50055) + #define ESPURNA_IMAGE ESPURNA_DIMMER - #define ESPURNA_IMAGE ESPURNA_BASIC + // Info + #define LIGHT_CHANNELS 5 + #define LIGHT_CH1_PIN 14 // RED + #define LIGHT_CH2_PIN 12 // GREEN + #define LIGHT_CH3_PIN 13 // BLUE + #define LIGHT_CH4_PIN 15 // WHITE1 + #define LIGHT_CH5_PIN 5 // WHITE2 + #define LIGHT_CH1_INVERSE 0 + #define LIGHT_CH2_INVERSE 0 + #define LIGHT_CH3_INVERSE 0 + #define LIGHT_CH4_INVERSE 0 + #define LIGHT_CH5_INVERSE 0 -// ----------------------------------------------------------------------------- -// EX-Store Wifi Relay v3.1 -// https://ex-store.de/ESP8266-WiFi-Relay-V31 -// ----------------------------------------------------------------------------- +#elif defined(ARILUX_AL_LC11) -#elif defined(EXS_WIFI_RELAY_V31) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -// ----------------------------------------------------------------------------- -// V9261F -// ----------------------------------------------------------------------------- - -#elif defined(GENERIC_V9261F) - - #define ESPURNA_IMAGE ESPURNA_POWER + #define ESPURNA_IMAGE ESPURNA_DIMMER // Info - #define ALEXA_SUPPORT 0 - - // V9261F - #define V9261F_SUPPORT 1 - #define V9261F_PIN 2 - #define V9261F_PIN_INVERSE 1 - -// ----------------------------------------------------------------------------- -// ECH1560 -// ----------------------------------------------------------------------------- - -#elif defined(GENERIC_ECH1560) - - #define ESPURNA_IMAGE ESPURNA_POWER - - // Info - #define ALEXA_SUPPORT 0 - - // ECH1560 - #define ECH1560_SUPPORT 1 - #define ECH1560_CLK_PIN 4 - #define ECH1560_MISO_PIN 5 - #define ECH1560_INVERTED 0 - -// ----------------------------------------------------------------------------- -// ESPLive -// https://github.com/ManCaveMade/ESP-Live -// ----------------------------------------------------------------------------- - -#elif defined(MANCAVEMADE_ESPLIVE) - - #define ESPURNA_IMAGE ESPURNA_SENSOR - - // DS18B20 - #ifndef DALLAS_SUPPORT - #define DALLAS_SUPPORT 1 - #endif - #define DALLAS_PIN 2 - #define DALLAS_UPDATE_INTERVAL 5000 - #define TEMPERATURE_MIN_CHANGE 1.0 - -// ----------------------------------------------------------------------------- -// QuinLED -// http://blog.quindorian.org/2017/02/esp8266-led-lighting-quinled-v2-6-pcb.html -// ----------------------------------------------------------------------------- - -#elif defined(INTERMITTECH_QUINLED) - - #define ESPURNA_IMAGE ESPURNA_LIGHT - - // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER - #define LIGHT_CHANNELS 2 - #define LIGHT_CH1_PIN 0 - #define LIGHT_CH2_PIN 2 - #define LIGHT_CH1_INVERSE 0 - #define LIGHT_CH2_INVERSE 0 - -// ----------------------------------------------------------------------------- -// Arilux AL-LC06 -// ----------------------------------------------------------------------------- - -#elif defined(ARILUX_AL_LC01) - - #define ESPURNA_IMAGE ESPURNA_LIGHT - - // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER - #define LIGHT_CHANNELS 3 - #define LIGHT_CH1_PIN 5 // RED - #define LIGHT_CH2_PIN 12 // GREEN - #define LIGHT_CH3_PIN 13 // BLUE - #define LIGHT_CH1_INVERSE 0 - #define LIGHT_CH2_INVERSE 0 - #define LIGHT_CH3_INVERSE 0 - -#elif defined(ARILUX_AL_LC02) - - #define ESPURNA_IMAGE ESPURNA_LIGHT - - // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER - #define LIGHT_CHANNELS 4 - #define LIGHT_CH1_PIN 12 // RED - #define LIGHT_CH2_PIN 5 // GREEN - #define LIGHT_CH3_PIN 13 // BLUE - #define LIGHT_CH4_PIN 15 // WHITE1 - #define LIGHT_CH1_INVERSE 0 - #define LIGHT_CH2_INVERSE 0 - #define LIGHT_CH3_INVERSE 0 - #define LIGHT_CH4_INVERSE 0 - -#elif defined(ARILUX_AL_LC06) - - #define ESPURNA_IMAGE ESPURNA_LIGHT - - // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER - #define LIGHT_CHANNELS 5 - #define LIGHT_CH1_PIN 14 // RED - #define LIGHT_CH2_PIN 12 // GREEN - #define LIGHT_CH3_PIN 13 // BLUE - #define LIGHT_CH4_PIN 15 // WHITE1 - #define LIGHT_CH5_PIN 5 // WHITE2 - #define LIGHT_CH1_INVERSE 0 - #define LIGHT_CH2_INVERSE 0 - #define LIGHT_CH3_INVERSE 0 - #define LIGHT_CH4_INVERSE 0 - #define LIGHT_CH5_INVERSE 0 - -#elif defined(ARILUX_AL_LC11) - - #define ESPURNA_IMAGE ESPURNA_LIGHT - - // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define LIGHT_CHANNELS 5 #define LIGHT_CH1_PIN 5 // RED #define LIGHT_CH2_PIN 4 // GREEN @@ -683,11 +482,9 @@ enum boards { #elif defined(ARILUX_E27) - #define ESPURNA_IMAGE ESPURNA_LIGHT + #define ESPURNA_IMAGE ESPURNA_MY92XX // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_MY92XX #define LIGHT_CHANNELS 4 #define MY92XX_MODEL MY92XX_MODEL_MY9291 #define MY92XX_CHIPS 1 @@ -696,26 +493,11 @@ enum boards { #define MY92XX_COMMAND MY92XX_COMMAND_DEFAULT #define MY92XX_MAPPING 0, 1, 2, 3 -// ----------------------------------------------------------------------------- -// XENON SM-PW701U -// ----------------------------------------------------------------------------- - -#elif defined(XENON_SM_PW702U) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -// ----------------------------------------------------------------------------- -// AUTHOMETION LYT8266 -// https://authometion.com/shop/en/home/13-lyt8266.html -// ----------------------------------------------------------------------------- - #elif defined(AUTHOMETION_LYT8266) - #define ESPURNA_IMAGE ESPURNA_LIGHT + #define ESPURNA_IMAGE ESPURNA_DIMMER // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define LIGHT_CHANNELS 4 #define LIGHT_CH1_PIN 13 // RED #define LIGHT_CH2_PIN 12 // GREEN @@ -729,11 +511,9 @@ enum boards { #elif defined(GIZWITS_WITTY_CLOUD) - #define ESPURNA_IMAGE ESPURNA_LIGHT + #define ESPURNA_IMAGE ESPURNA_DIMMER // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define LIGHT_CHANNELS 3 #define LIGHT_CH1_PIN 15 // RED #define LIGHT_CH2_PIN 12 // GREEN @@ -744,591 +524,324 @@ enum boards { #define ANALOG_SUPPORT 1 // TODO: specific or generic? -// ----------------------------------------------------------------------------- -// KMC 70011 -// https://www.amazon.com/KMC-Monitoring-Required-Control-Compatible/dp/B07313TH7B -// ----------------------------------------------------------------------------- - -#elif defined(KMC_70011) - - #define ESPURNA_IMAGE ESPURNA_POWER - - // HLW8012 - #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_VOLTAGE_R_UP ( 2 * 1000000 ) // Upstream voltage resistor - -// ----------------------------------------------------------------------------- -// Euromate (?) Wifi Stecker Shuko -// https://www.obi.de/hausfunksteuerung/wifi-stecker-schuko/p/2291706 -// Thanks to @Geitde -// ----------------------------------------------------------------------------- - -#elif defined(EUROMATE_WIFI_STECKER_SCHUKO) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -// ----------------------------------------------------------------------------- -// Generic 8CH -// ----------------------------------------------------------------------------- - -#elif defined(GENERIC_8CH) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -// ----------------------------------------------------------------------------- -// STM RELAY -// ----------------------------------------------------------------------------- - -#elif defined(STM_RELAY) - - #define ESPURNA_IMAGE ESPURNA_STM - - #define RELAY_PROVIDER RELAY_PROVIDER_STM - #define DEBUG_SERIAL_SUPPORT 0 - -// ----------------------------------------------------------------------------- -// Tonbux Powerstrip02 -// ----------------------------------------------------------------------------- +#elif defined(GENERIC_AG_L4) -#elif defined(TONBUX_POWERSTRIP02) + #define ESPURNA_IMAGE ESPURNA_DIMMER - #define ESPURNA_IMAGE ESPURNA_BASIC + // Info + #define LIGHT_CHANNELS 3 + #define LIGHT_CH1_PIN 14 // RED + #define LIGHT_CH2_PIN 13 // GREEN + #define LIGHT_CH3_PIN 12 // BLUE + #define LIGHT_CH1_INVERSE 0 + #define LIGHT_CH2_INVERSE 0 + #define LIGHT_CH3_INVERSE 0 // ----------------------------------------------------------------------------- -// Lingan SWA1 +// TEST boards (do not use!!) // ----------------------------------------------------------------------------- -#elif defined(LINGAN_SWA1) +#elif defined(TRAVIS01) #define ESPURNA_IMAGE ESPURNA_BASIC -// ----------------------------------------------------------------------------- -// HEYGO HY02 -// ----------------------------------------------------------------------------- - -#elif defined(HEYGO_HY02) - - #define ESPURNA_IMAGE ESPURNA_BASIC + // A bit of I2C - pins 3,4 + #define I2C_SDA_PIN 3 + #define I2C_SCL_PIN 4 -// ----------------------------------------------------------------------------- -// Maxcio W-US002S -// ----------------------------------------------------------------------------- + // And, as they say in "From Dusk till Dawn": + // This is a sensor blow out! + // Alright, we got white sensor, black sensor, spanish sensor, yellow sensor. We got hot sensor, cold sensor. + // We got wet sensor. We got smelly sensor. We got hairy sensor, bloody sensor. We got snapping sensor. + // We got silk sensor, velvet sensor, naugahyde sensor. We even got horse sensor, dog sensor, chicken sensor. + // C'mon, you want sensor, come on in sensor lovers! + // If we don’t got it, you don't want it! + #define AM2320_SUPPORT 1 + #define BH1750_SUPPORT 1 + #define BMX280_SUPPORT 1 + #define SHT3X_I2C_SUPPORT 1 + #define EMON_ADC121_SUPPORT 1 + #define EMON_ADS1X15_SUPPORT 1 + #define SHT3X_I2C_SUPPORT 1 + #define SI7021_SUPPORT 1 + #define PMSX003_SUPPORT 1 + #define SENSEAIR_SUPPORT 1 -#elif defined(MAXCIO_WUS002S) - #define ESPURNA_IMAGE ESPURNA_POWER + // A bit of lights - pin 5 + #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT + #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER + #define DUMMY_RELAY_COUNT 1 + #define LIGHT_CHANNELS 1 + #define LIGHT_CH1_PIN 5 + #define LIGHT_CH1_INVERSE 0 - // HLW8012 + // A bit of HLW8012 - pins 6,7,8 #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_CURRENT_R 0.002 // Current resistor - #define HLW8012_VOLTAGE_R_UP ( 2 * 1000000 ) // Upstream voltage resistor - -// ----------------------------------------------------------------------------- -// YiDian XS-SSA05 -// ----------------------------------------------------------------------------- - -#elif defined(YIDIAN_XSSSA05) - - #define ESPURNA_IMAGE ESPURNA_POWER + #define HLW8012_SEL_PIN 6 + #define HLW8012_CF1_PIN 7 + #define HLW8012_CF_PIN 8 - // HLW8012 - #ifndef HLW8012_SUPPORT - #define HLW8012_SUPPORT 1 + // A bit of Dallas - pin 9 + #ifndef DALLAS_SUPPORT + #define DALLAS_SUPPORT 1 #endif - #define HLW8012_SEL_PIN 3 - #define HLW8012_CF1_PIN 14 - #define HLW8012_CF_PIN 5 - #define HLW8012_CURRENT_R 0.001 // Current resistor - #define HLW8012_VOLTAGE_R_UP ( 2 * 1200000 ) // Upstream voltage resistor - -// ----------------------------------------------------------------------------- -// TONBUX XS-SSA06 -// ----------------------------------------------------------------------------- - -#elif defined(TONBUX_XSSSA06) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -// ----------------------------------------------------------------------------- -// GREEN ESP8266 RELAY MODULE -// https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180323113846&SearchText=Green+ESP8266 -// ----------------------------------------------------------------------------- - -#elif defined(GREEN_ESP8266RELAY) + #define DALLAS_PIN 9 - #define ESPURNA_IMAGE ESPURNA_BASIC - -// ----------------------------------------------------------------------------- -// Henrique Gravina ESPIKE -// https://github.com/Henriquegravina/Espike -// ----------------------------------------------------------------------------- - -#elif defined(IKE_ESPIKE) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -// ----------------------------------------------------------------------------- -// SWIFITCH -// https://github.com/ArnieX/swifitch -// ----------------------------------------------------------------------------- - -#elif defined(ARNIEX_SWIFITCH) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -// ----------------------------------------------------------------------------- -// ESP-01S RELAY v4.0 -// https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180404024035&SearchText=esp-01s+relay -// ----------------------------------------------------------------------------- - -#elif defined(GENERIC_ESP01S_RELAY_V40) - - #define ESPURNA_IMAGE ESPURNA_BASIC - -// ----------------------------------------------------------------------------- -// ESP-01S RGB LED v1.0 (some sold with ws2818) -// https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180404023816&SearchText=esp-01s+led+controller -// ----------------------------------------------------------------------------- + // A bit of ECH1560 - pins 10,11, 12 + #ifndef ECH1560_SUPPORT + #define ECH1560_SUPPORT 1 + #endif + #define ECH1560_CLK_PIN 10 + #define ECH1560_MISO_PIN 11 + #define ECH1560_INVERTED 12 -#elif defined(GENERIC_ESP01S_RGBLED_V10) +#elif defined(TRAVIS02) #define ESPURNA_IMAGE ESPURNA_BASIC -// ----------------------------------------------------------------------------- -// ESP-01S DHT11 v1.0 -// https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180410105907&SearchText=esp-01s+dht11 -// ----------------------------------------------------------------------------- + // A bit of CSE7766 - pin 1 + #ifndef CSE7766_SUPPORT + #define CSE7766_SUPPORT 1 + #endif + #define CSE7766_PIN 1 -#elif defined(GENERIC_ESP01S_DHT11_V10) + // Relay type dual - pins 2,3 + #define RELAY_PROVIDER RELAY_PROVIDER_DUAL + #define RELAY1_PIN 2 + #define RELAY2_PIN 3 + #define RELAY1_TYPE RELAY_TYPE_NORMAL + #define RELAY2_TYPE RELAY_TYPE_NORMAL - #define ESPURNA_IMAGE ESPURNA_SENSOR + // IR - pin 4 + #define IR_SUPPORT 1 + #define IR_RECEIVER_PIN 4 + #define IR_BUTTON_SET 1 - // DHT11 + // A bit of DHT - pin 5 #ifndef DHT_SUPPORT #define DHT_SUPPORT 1 #endif - #define DHT_PIN 2 - #define DHT_TYPE DHT_CHIP_DHT11 - -// ----------------------------------------------------------------------------- -// ESP-01S DS18B20 v1.0 -// https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180410105933&SearchText=esp-01s+ds18b20 -// ----------------------------------------------------------------------------- - -#elif defined(GENERIC_ESP01S_DS18B20_V10) - - #define ESPURNA_IMAGE ESPURNA_SENSOR - - // DB18B20 - #ifndef DALLAS_SUPPORT - #define DALLAS_SUPPORT 1 - #endif - #define DALLAS_PIN 2 + #define DHT_PIN 5 -// ----------------------------------------------------------------------------- -// ESP-DIN relay board V1 -// https://github.com/pilotak/esp_din -// ----------------------------------------------------------------------------- - -#elif defined(PILOTAK_ESP_DIN_V1) - - #define ESPURNA_IMAGE ESPURNA_SENSOR - - #define I2C_SDA_PIN 12 // TODO:what is this for? - #define I2C_SCL_PIN 13 + // A bit of TMP3X (analog) + #define TMP3X_SUPPORT 1 - #ifndef DALLAS_SUPPORT - #define DALLAS_SUPPORT 1 - #endif - #define DALLAS_PIN 2 + // A bit of EVENTS - pin 10 + #define EVENTS_SUPPORT 1 + #define EVENTS_PIN 6 - #ifndef RF_SUPPORT - #define RF_SUPPORT 1 - #endif - #define RF_PIN 14 + // Sonar + #define SONAR_SUPPORT 1 + #define SONAR_TRIGGER 7 + #define SONAR_ECHO 8 - #ifndef DIGITAL_SUPPORT - #define DIGITAL_SUPPORT 1 - #endif - #define DIGITAL_PIN 16 - #define DIGITAL_PIN_MODE INPUT + // MHZ19 + #define MHZ19_SUPPORT 1 + #define MHZ19_RX_PIN 9 + #define MHZ19_TX_PIN 10 -// ----------------------------------------------------------------------------- -// Heltec Touch Relay -// https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180408043114&SearchText=esp8266+touch+relay -// ----------------------------------------------------------------------------- + // PZEM004T + #define PZEM004T_SUPPORT 1 + #define PZEM004T_RX_PIN 11 + #define PZEM004T_TX_PIN 12 -#elif defined(HELTEC_TOUCHRELAY) + // V9261F + #define V9261F_SUPPORT 1 + #define V9261F_PIN 13 - #define ESPURNA_IMAGE ESPURNA_BASIC + // GUVAS12SD + #define GUVAS12SD_SUPPORT 1 + #define GUVAS12SD_PIN 14 -// ----------------------------------------------------------------------------- -// Zhilde ZLD-EU44-W -// http://www.zhilde.com/product/60705150109-805652505/EU_WiFi_Surge_Protector_Extension_Socket_4_Outlets_works_with_Amazon_Echo_Smart_Power_Strip.html -// ----------------------------------------------------------------------------- + // Test non-default modules + #define MDNS_CLIENT_SUPPORT 1 + #define NOFUSS_SUPPORT 1 + #define UART_MQTT_SUPPORT 1 + #define INFLUXDB_SUPPORT 1 + #define IR_SUPPORT 1 -#elif defined(ZHILDE_EU44_W) +#elif defined(TRAVIS03) #define ESPURNA_IMAGE ESPURNA_BASIC - // Based on the reporter, this product uses GPIO1 and 3 for the button - // and onboard LED, so hardware serial should be disabled... - #define DEBUG_SERIAL_SUPPORT 0 - -// ----------------------------------------------------------------------------- -// 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 -// ----------------------------------------------------------------------------- + // MY9231 Light - pins 1,2 + #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT + #define LIGHT_PROVIDER LIGHT_PROVIDER_MY92XX + #define DUMMY_RELAY_COUNT 1 + #define LIGHT_CHANNELS 5 + #define MY92XX_MODEL MY92XX_MODEL_MY9231 + #define MY92XX_CHIPS 2 + #define MY92XX_DI_PIN 1 + #define MY92XX_DCKI_PIN 2 + #define MY92XX_COMMAND MY92XX_COMMAND_DEFAULT + #define MY92XX_MAPPING 4, 3, 5, 0, 1 -#elif defined(ALLNET_4DUINO_IOT_WLAN_RELAIS) + // A bit of Analog EMON (analog) + #ifndef EMON_ANALOG_SUPPORT + #define EMON_ANALOG_SUPPORT 1 + #endif - #define ESPURNA_IMAGE ESPURNA_BASIC + // Test non-default modules + #define LLMNR_SUPPORT 1 + #define NETBIOS_SUPPORT 1 + #define SSDP_SUPPORT 1 // ----------------------------------------------------------------------------- -// Luani HVIO -// https://luani.de/projekte/esp8266-hvio/ -// https://luani.de/blog/esp8266-230v-io-modul/ +// ESPurna Core // ----------------------------------------------------------------------------- -#elif defined(LUANI_HVIO) - - #define ESPURNA_IMAGE ESPURNA_BASIC +#else -// ----------------------------------------------------------------------------- -// 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 -// ----------------------------------------------------------------------------- + // This is a special device targeted to generate a light-weight binary image + // meant to be able to do two-step-updates: + // https://github.com/xoseperez/espurna/wiki/TwoStepUpdates -#elif defined(TONBUX_MOSQUITO_KILLER) + #define ESPURNA_IMAGE ESPURNA_CORE - #define ESPURNA_IMAGE ESPURNA_BASIC +#endif // ----------------------------------------------------------------------------- -// NEO Coolcam NAS-WR01W Wifi Smart Power Plug -// https://es.aliexpress.com/item/-/32854589733.html?spm=a219c.12010608.0.0.6d084e68xX0y5N -// https://www.fasttech.com/product/9649426-neo-coolcam-nas-wr01w-wifi-smart-power-plug-eu +// Image definitions // ----------------------------------------------------------------------------- -#elif defined(NEO_COOLCAM_NAS_WR01W) +#if ESPURNA_IMAGE == ESPURNA_CORE - #define ESPURNA_IMAGE ESPURNA_BASIC - -// ------------------------------------------------------------------------------ -// Estink Wifi Power Strip -// https://www.amazon.de/Steckdosenleiste-Ladeger%C3%A4t-Sprachsteuerung-SmartphonesTablets-Android/dp/B0796W5FZY -// Fornorm Wi-Fi USB Extension Socket (ZLD-34EU) -// https://www.aliexpress.com/item/Fornorm-WiFi-Extension-Socket-with-Surge-Protector-Smart-Power-Strip-3-Outlets-and-4-USB-Charging/32849743948.html -// ----------------------------------------------------------------------------- - -#elif defined(ESTINK_WIFI_POWER_STRIP) - - #define ESPURNA_IMAGE ESPURNA_BASIC + // Disable non-core modules + #define ALEXA_SUPPORT 0 + #define BROKER_SUPPORT 0 + #define BUTTON_SUPPORT 0 + #define DOMOTICZ_SUPPORT 0 + #define HOMEASSISTANT_SUPPORT 0 + #define I2C_SUPPORT 0 + #define MDNS_SERVER_SUPPORT 0 + #define MQTT_SUPPORT 0 + #define NTP_SUPPORT 0 + #define SCHEDULER_SUPPORT 0 + #define SENSOR_SUPPORT 0 + #define THINGSPEAK_SUPPORT 0 + #define WEB_SUPPORT 0 - // Disable UART noise since this board uses GPIO3 - #define DEBUG_SERIAL_SUPPORT 0 + // Extra light-weight image + //#define DEBUG_SERIAL_SUPPORT 0 + //#define DEBUG_TELNET_SUPPORT 0 + //#define DEBUG_WEB_SUPPORT 0 + //#define LED_SUPPORT 0 + //#define TELNET_SUPPORT 0 + //#define TERMINAL_SUPPORT 0 -// ----------------------------------------------------------------------------- -// Bruno Horta's OnOfre -// https://www.bhonofre.pt/ -// https://github.com/brunohorta82/BH_OnOfre/ -// ----------------------------------------------------------------------------- +#elif ESPURNA_IMAGE == ESPURNA_BASIC -#elif defined(BH_ONOFRE) +#elif ESPURNA_IMAGE == ESPURNA_DIMMER - #define ESPURNA_IMAGE ESPURNA_BASIC + #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT + #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER -// ----------------------------------------------------------------------------- -// Several boards under different names uing a power chip labelled BL0937 or HJL-01 -// * Blitzwolf (https://www.amazon.es/Inteligente-Temporización-Dispositivos-Cualquier-BlitzWolf/dp/B07BMQP142) -// * HomeCube (https://www.amazon.de/Steckdose-Homecube-intelligente-Verbrauchsanzeige-funktioniert/dp/B076Q2LKHG) -// * Coosa (https://www.amazon.com/COOSA-Monitoring-Function-Campatible-Assiatant/dp/B0788W9TDR) -// * Goosund (http://www.gosund.com/?m=content&c=index&a=show&catid=6&id=5) -// * Ablue (https://www.amazon.de/Intelligente-Steckdose-Ablue-Funktioniert-Assistant/dp/B076DRFRZC) -// ----------------------------------------------------------------------------- +#elif ESPURNA_IMAGE == ESPURNA_MY92XX -#elif defined(BLITZWOLF_BWSHP2) + #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT + #define LIGHT_PROVIDER LIGHT_PROVIDER_MY92XX - #define ESPURNA_IMAGE ESPURNA_POWER +#elif ESPURNA_IMAGE == ESPURNA_EMON - // HJL01 / BL0937 - #ifndef HLW8012_SUPPORT - #define HLW8012_SUPPORT 1 - #endif - #define HLW8012_SEL_PIN 12 - #define HLW8012_CF1_PIN 14 - #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 -// ---------------------------------------------------------------------------------------- -#elif defined(HOMECUBE_16A) - - #define ESPURNA_IMAGE ESPURNA_POWER - - // HJL01 / BL0937 - #ifndef HLW8012_SUPPORT - #define HLW8012_SUPPORT 1 + #ifndef EMON_ANALOG_SUPPORT + #define EMON_ANALOG_SUPPORT 1 #endif - #define HLW8012_SEL_PIN 16 - #define HLW8012_CF1_PIN 14 - #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 - -// ----------------------------------------------------------------------------- -// VANZAVANZU Smart Outlet Socket (based on BL0937 or HJL-01) -// https://www.amazon.com/Smart-Plug-Wifi-Mini-VANZAVANZU/dp/B078PHD6S5 -// ----------------------------------------------------------------------------- - -#elif defined(VANZAVANZU_SMART_WIFI_PLUG_MINI) + #ifndef EMON_ADC121_SUPPORT + #define EMON_ADC121_SUPPORT 1 + #endif - #define ESPURNA_IMAGE ESPURNA_POWER + #ifndef EMON_ADS1X15_SUPPORT + #define EMON_ADS1X15_SUPPORT 1 + #endif - // Disable UART noise - #define DEBUG_SERIAL_SUPPORT 0 +#elif ESPURNA_IMAGE == ESPURNA_HLW8012 - // HJL01 / BL0937 #ifndef HLW8012_SUPPORT #define HLW8012_SUPPORT 1 #endif - #define HLW8012_SEL_PIN 3 - #define HLW8012_CF1_PIN 14 - #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 - -#elif defined(GENERIC_AG_L4) - - #define ESPURNA_IMAGE ESPURNA_LIGHT - // Info - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER - #define LIGHT_CHANNELS 3 - #define LIGHT_CH1_PIN 14 // RED - #define LIGHT_CH2_PIN 13 // GREEN - #define LIGHT_CH3_PIN 12 // BLUE - #define LIGHT_CH1_INVERSE 0 - #define LIGHT_CH2_INVERSE 0 - #define LIGHT_CH3_INVERSE 0 -// ----------------------------------------------------------------------------- -// Generic board with Geiger Counter -// ----------------------------------------------------------------------------- +#elif ESPURNA_IMAGE == ESPURNA_CSE77XX -#elif defined(GENERIC_GEIGER_COUNTER) + #ifndef CSE7766_SUPPORT + #define CSE7766_SUPPORT 1 + #endif - #define ESPURNA_IMAGE ESPURNA_GEIGER +#elif ESPURNA_IMAGE == ESPURNA_V9261F - // Enable Geiger Counter - #define GEIGER_SUPPORT 1 + #ifndef V9261F_SUPPORT + #define V9261F_SUPPORT 1 + #endif - // Disable uneeded modules + #ifndef ALEXA_SUPPORT #define ALEXA_SUPPORT 0 - #define SCHEDULER_SUPPORT 0 - -// ----------------------------------------------------------------------------- -// TEST boards (do not use!!) -// ----------------------------------------------------------------------------- - -#elif defined(TRAVIS01) - - // A bit of I2C - pins 3,4 - #define I2C_SDA_PIN 3 - #define I2C_SCL_PIN 4 - - // And, as they say in "From Dusk till Dawn": - // This is a sensor blow out! - // Alright, we got white sensor, black sensor, spanish sensor, yellow sensor. We got hot sensor, cold sensor. - // We got wet sensor. We got smelly sensor. We got hairy sensor, bloody sensor. We got snapping sensor. - // We got silk sensor, velvet sensor, naugahyde sensor. We even got horse sensor, dog sensor, chicken sensor. - // C'mon, you want sensor, come on in sensor lovers! - // If we don’t got it, you don't want it! - #define AM2320_SUPPORT 1 - #define BH1750_SUPPORT 1 - #define BMX280_SUPPORT 1 - #define SHT3X_I2C_SUPPORT 1 - #define EMON_ADC121_SUPPORT 1 - #define EMON_ADS1X15_SUPPORT 1 - #define SHT3X_I2C_SUPPORT 1 - #define SI7021_SUPPORT 1 - #define PMSX003_SUPPORT 1 - #define SENSEAIR_SUPPORT 1 - - - // A bit of lights - pin 5 - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER - #define DUMMY_RELAY_COUNT 1 - #define LIGHT_CHANNELS 1 - #define LIGHT_CH1_PIN 5 - #define LIGHT_CH1_INVERSE 0 - - // A bit of HLW8012 - pins 6,7,8 - #ifndef HLW8012_SUPPORT - #define HLW8012_SUPPORT 1 #endif - #define HLW8012_SEL_PIN 6 - #define HLW8012_CF1_PIN 7 - #define HLW8012_CF_PIN 8 - // A bit of Dallas - pin 9 - #ifndef DALLAS_SUPPORT - #define DALLAS_SUPPORT 1 - #endif - #define DALLAS_PIN 9 +#elif ESPURNA_IMAGE == ESPURNA_ECH1560 - // A bit of ECH1560 - pins 10,11, 12 #ifndef ECH1560_SUPPORT - #define ECH1560_SUPPORT 1 + #define ECH1560_SUPPORT 1 #endif - #define ECH1560_CLK_PIN 10 - #define ECH1560_MISO_PIN 11 - #define ECH1560_INVERTED 12 - -#elif defined(TRAVIS02) - // A bit of CSE7766 - pin 1 - #ifndef CSE7766_SUPPORT - #define CSE7766_SUPPORT 1 + #ifndef ALEXA_SUPPORT + #define ALEXA_SUPPORT 0 #endif - #define CSE7766_PIN 1 - - // Relay type dual - pins 2,3 - #define RELAY_PROVIDER RELAY_PROVIDER_DUAL - #define RELAY1_PIN 2 - #define RELAY2_PIN 3 - #define RELAY1_TYPE RELAY_TYPE_NORMAL - #define RELAY2_TYPE RELAY_TYPE_NORMAL - // IR - pin 4 - #define IR_SUPPORT 1 - #define IR_RECEIVER_PIN 4 - #define IR_BUTTON_SET 1 +#elif ESPURNA_IMAGE == ESPURNA_SENSOR - // A bit of DHT - pin 5 - #ifndef DHT_SUPPORT - #define DHT_SUPPORT 1 + #ifndef ANALOG_SUPPORT + #define ANALOG_SUPPORT 1 #endif - #define DHT_PIN 5 - - // A bit of TMP3X (analog) - #define TMP3X_SUPPORT 1 - - // A bit of EVENTS - pin 10 - #define EVENTS_SUPPORT 1 - #define EVENTS_PIN 6 - // Sonar - #define SONAR_SUPPORT 1 - #define SONAR_TRIGGER 7 - #define SONAR_ECHO 8 - - // MHZ19 - #define MHZ19_SUPPORT 1 - #define MHZ19_RX_PIN 9 - #define MHZ19_TX_PIN 10 - - // PZEM004T - #define PZEM004T_SUPPORT 1 - #define PZEM004T_RX_PIN 11 - #define PZEM004T_TX_PIN 12 + #ifndef DALLAS_SUPPORT + #define DALLAS_SUPPORT 1 + #endif - // V9261F - #define V9261F_SUPPORT 1 - #define V9261F_PIN 13 + #ifndef DHT_SUPPORT + #define DHT_SUPPORT 1 + #endif - // GUVAS12SD - #define GUVAS12SD_SUPPORT 1 - #define GUVAS12SD_PIN 14 + #ifndef DIGITAL_SUPPORT + #define DIGITAL_SUPPORT 1 + #endif - // Test non-default modules - #define MDNS_CLIENT_SUPPORT 1 - #define NOFUSS_SUPPORT 1 - #define UART_MQTT_SUPPORT 1 - #define INFLUXDB_SUPPORT 1 - #define IR_SUPPORT 1 +#elif ESPURNA_IMAGE == ESPURNA_SONOFF_DUAL -#elif defined(TRAVIS03) + #define SERIAL_BAUDRATE 19230 + #define RELAY_PROVIDER RELAY_PROVIDER_DUAL + #define DEBUG_SERIAL_SUPPORT 0 - // MY9231 Light - pins 1,2 - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_MY92XX - #define DUMMY_RELAY_COUNT 1 - #define LIGHT_CHANNELS 5 - #define MY92XX_MODEL MY92XX_MODEL_MY9231 - #define MY92XX_CHIPS 2 - #define MY92XX_DI_PIN 1 - #define MY92XX_DCKI_PIN 2 - #define MY92XX_COMMAND MY92XX_COMMAND_DEFAULT - #define MY92XX_MAPPING 4, 3, 5, 0, 1 +#elif ESPURNA_IMAGE == ESPURNA_SONOFF_RFBRIDGE - // A bit of Analog EMON (analog) - #ifndef EMON_ANALOG_SUPPORT - #define EMON_ANALOG_SUPPORT 1 - #endif +#elif ESPURNA_IMAGE == ESPURNA_RFM69 - // Test non-default modules - #define LLMNR_SUPPORT 1 - #define NETBIOS_SUPPORT 1 - #define SSDP_SUPPORT 1 + // RFM69GW + #define RFM69_SUPPORT 1 -// ----------------------------------------------------------------------------- -// ESPurna Core -// ----------------------------------------------------------------------------- + // Disable non-core modules + #define ALEXA_SUPPORT 0 + #define DOMOTICZ_SUPPORT 0 + #define HOMEASSISTANT_SUPPORT 0 + #define I2C_SUPPORT 0 + #define SCHEDULER_SUPPORT 0 + #define SENSOR_SUPPORT 0 + #define THINGSPEAK_SUPPORT 0 -#else +#elif ESPURNA_IMAGE == ESPURNA_STM - // This is a special device targeted to generate a light-weight binary image - // meant to be able to do two-step-updates: - // https://github.com/xoseperez/espurna/wiki/TwoStepUpdates + #define RELAY_PROVIDER RELAY_PROVIDER_STM + #define DEBUG_SERIAL_SUPPORT 0 - #define ESPURNA_IMAGE ESPURNA_CORE +#elif ESPURNA_IMAGE == ESPURNA_GEIGER - // Disable non-core modules - #define ALEXA_SUPPORT 0 - #define BROKER_SUPPORT 0 - #define BUTTON_SUPPORT 0 - #define DOMOTICZ_SUPPORT 0 - #define HOMEASSISTANT_SUPPORT 0 - #define I2C_SUPPORT 0 - #define MDNS_SERVER_SUPPORT 0 - #define MQTT_SUPPORT 0 - #define NTP_SUPPORT 0 - #define SCHEDULER_SUPPORT 0 - #define SENSOR_SUPPORT 0 - #define THINGSPEAK_SUPPORT 0 - #define WEB_SUPPORT 0 + // Enable Geiger Counter + #define GEIGER_SUPPORT 1 - // Extra light-weight image - //#define DEBUG_SERIAL_SUPPORT 0 - //#define DEBUG_TELNET_SUPPORT 0 - //#define DEBUG_WEB_SUPPORT 0 - //#define LED_SUPPORT 0 - //#define TELNET_SUPPORT 0 - //#define TERMINAL_SUPPORT 0 + // Disable uneeded modules + #define ALEXA_SUPPORT 0 + #define SCHEDULER_SUPPORT 0 #endif diff --git a/code/espurna/config/sensors.h b/code/espurna/config/sensors.h index fa220fc8..3e979e35 100644 --- a/code/espurna/config/sensors.h +++ b/code/espurna/config/sensors.h @@ -238,6 +238,10 @@ #define EMON_REPORT_POWER 1 // Report power #define EMON_REPORT_ENERGY 1 // Report energy +#define EMON_PROVIDER_ANALOG 1 +#define EMON_PROVIDER_ADC121 2 +#define EMON_PROVIDER_ADS1X15 3 + //------------------------------------------------------------------------------ // Energy Monitor based on ADC121 // Enable support by passing EMON_ADC121_SUPPORT=1 build flag @@ -310,7 +314,7 @@ #endif #ifndef GEIGER_PIN -#define GEIGER_PIN D1 // GPIO to monitor "D1" => "GPIO5" +#define GEIGER_PIN 5 // GPIO to monitor "D1" => "GPIO5" #endif #ifndef GEIGER_PIN_MODE @@ -493,20 +497,21 @@ #endif #ifndef PMS_USE_SOFT -#define PMS_USE_SOFT 0 // If PMS_USE_SOFT == 1, DEBUG_SERIAL_SUPPORT must be 0 +#define PMS_USE_SOFT 0 // If PMS_USE_SOFT == 1, DEBUG_SERIAL_SUPPORT must be 0 #endif #ifndef PMS_RX_PIN -#define PMS_RX_PIN 13 // Software serial RX GPIO (if PMS_USE_SOFT == 1) +#define PMS_RX_PIN 13 // Software serial RX GPIO (if PMS_USE_SOFT == 1) #endif #ifndef PMS_TX_PIN -#define PMS_TX_PIN 15 // Software serial TX GPIO (if PMS_USE_SOFT == 1) +#define PMS_TX_PIN 15 // Software serial TX GPIO (if PMS_USE_SOFT == 1) #endif #ifndef PMS_HW_PORT -#define PMS_HW_PORT Serial // Hardware serial port (if PMS_USE_SOFT == 0) +#define PMS_HW_PORT Serial // Hardware serial port (if PMS_USE_SOFT == 0) #endif + //------------------------------------------------------------------------------ // PZEM004T based power monitor // Enable support by passing PZEM004T_SUPPORT=1 build flag diff --git a/code/espurna/config/types.h b/code/espurna/config/types.h index d3141e67..d1c0e76f 100644 --- a/code/espurna/config/types.h +++ b/code/espurna/config/types.h @@ -7,16 +7,30 @@ // IMAGES // ----------------------------------------------------------------------------- +// Basics #define ESPURNA_CORE 0 // minimal #define ESPURNA_BASIC 1 // relay, button, led -#define ESPURNA_LIGHT 2 // ESPURNA_BASIC + light drivers -#define ESPURNA_POWER 3 // ESPURNA_BASIC + power monitoring sensors -#define ESPURNA_SENSOR 4 // ESPURNA_BASIC + basic sensors -#define ESPURNA_SONOFF_DUAL 10 // Device specific -#define ESPURNA_SONOFF_RFBRIDGE 11 // Device specific -#define ESPURNA_RFM69 12 // Device specific -#define ESPURNA_STM 13 // Device specific -#define ESPURNA_GEIGER 14 // Device specific + +// Lights +#define ESPURNA_DIMMER 10 +#define ESPURNA_MY92XX 11 + +// Power monitoring +#define ESPURNA_EMON 20 +#define ESPURNA_HLW8012 21 +#define ESPURNA_CSE77XX 22 +#define ESPURNA_V9261F 23 +#define ESPURNA_ECH1560 24 + +// Sensors +#define ESPURNA_SENSOR 30 + +// Device specific +#define ESPURNA_SONOFF_DUAL 40 +#define ESPURNA_SONOFF_RFBRIDGE 41 +#define ESPURNA_RFM69 42 +#define ESPURNA_STM 43 +#define ESPURNA_GEIGER 44 // ----------------------------------------------------------------------------- // WIFI diff --git a/code/espurna/hardware.ino b/code/espurna/hardware.ino index 53d35e84..844ed125 100644 --- a/code/espurna/hardware.ino +++ b/code/espurna/hardware.ino @@ -12,7 +12,7 @@ Copyright (C) 2016-2018 by Xose Pérez // // Configuration settings for each device, the most common ones are: // -// board: ID of the board according to XXX +// board: ID of the board according to boards enum in hardware.h // device: Name of the device ("string") // btnGPIO : GPIO for the n-th button (0-based) // btnRelay : Relay index linked to the n-th button @@ -94,6 +94,7 @@ void _hardwareLoad() { setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); setSetting("btnRelay", 0, 0); + // Jack is connected to GPIO14 (and with a small hack to GPIO4) setSetting("dhtEnabled", 1); setSetting("dhtGPIO", 0, 14); @@ -1247,6 +1248,7 @@ void _hardwareLoad() { setSetting("hlwSELGPIO", 3); setSetting("hlwCF1GPIO", 14); setSetting("hlwCFGPIO", 5); + setSetting("hlwCurRes", 0.001); setSetting("hlwVolResUp", 2400000); #elif defined(TONBUX_XSSSA06) @@ -1613,6 +1615,7 @@ void _hardwareLoad() { setSetting("rlyType", 2, RELAY_TYPE_NORMAL); setSetting("rlyType", 3, RELAY_TYPE_NORMAL); + // Disable UART noise since this board uses GPIO3 setSetting("dbgSerial", 0); #elif defined(BH_ONOFRE) @@ -1666,12 +1669,46 @@ void _hardwareLoad() { setSetting("hlwSELGPIO", 12); setSetting("hlwCF1GPIO", 14); setSetting("hlwCFGPIO", 5); - setSetting("hlwCurLevel", LOW); - setSetting("hlwInt", FALLING); + setSetting("hlwCurSel", LOW); + setSetting("hlwIntMode", FALLING); setSetting("curRatio", 25740); setSetting("volRatio", 313400); setSetting("pwrRatio", 3414290); + #elif defined(HOMECUBE_16A) + + // Homecube 16A is similar to BLITZWOLF_BWSHP2 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 + + setSetting("board", BOARD_HOMECUBE_16A); + setSetting("device", "HOMECUBE_16A"); + + setSetting("btnGPIO", 0, 13); + setSetting("btnMode", 0, BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH); + setSetting("btnRelay", 0, 0); + + setSetting("ledGPIO", 0, 2); + setSetting("ledGPIO", 1, 12); + setSetting("ledGPIO", 2, 0); + setSetting("ledLogic", 0, GPIO_LOGIC_DIRECT); + setSetting("ledLogic", 1, GPIO_LOGIC_DIRECT); + setSetting("ledLogic", 2, GPIO_LOGIC_DIRECT); + setSetting("ledMode", 0, LED_MODE_WIFI); + setSetting("ledMode", 1, LED_MODE_FINDME); + setSetting("ledMode", 2, LED_MODE_OFF); + setSetting("ledRelay", 1, 0); + + setSetting("rlyGPIO", 0, 15); + setSetting("rlyType", 0, RELAY_TYPE_NORMAL); + + setSetting("hlwSELGPIO", 16); + setSetting("hlwCF1GPIO", 14); + setSetting("hlwCFGPIO", 5); + setSetting("hlwCurSel", LOW); + setSetting("hlwIntMode", FALLING); + setSetting("curRatio", 25740); + setSetting("volRatio", 313400); + setSetting("pwrRatio", 3414290); #elif defined(TINKERMAN_ESPURNA_SWITCH) @@ -1749,18 +1786,21 @@ void _hardwareLoad() { setSetting("hlwSELGPIO", 3); setSetting("hlwCF1GPIO", 14); setSetting("hlwCFGPIO", 5); - setSetting("hlwCurLevel", LOW); - setSetting("hlwInt", FALLING); + setSetting("hlwCurSel", LOW); + setSetting("hlwIntMode", FALLING); setSetting("curRatio", 25740); setSetting("volRatio", 313400); setSetting("pwrRatio", 3414290); + setSetting("dbgSerial", 0); + #elif defined(GENERIC_GEIGER_COUNTER) setSetting("board", BOARD_GENERIC_GEIGER_COUNTER); setSetting("device", "GENERIC_GEIGER_COUNTER"); setSetting("geiEnabled", 1); + setSetting("geiGPIO", 5); #elif defined(TINKERMAN_RFM69GW) diff --git a/code/espurna/sensor.ino b/code/espurna/sensor.ino index 1e5371c0..97ddc5c7 100644 --- a/code/espurna/sensor.ino +++ b/code/espurna/sensor.ino @@ -6,7 +6,7 @@ Copyright (C) 2016-2018 by Xose Pérez Module key prefix: sns Magnitude-based key prefix: pwr ene cur vol tmp hum -Sensor-based key previs: hlw bme dht ds cse v92 pze ech gei +Sensor-based key previs: air am ana bh bmx cse dht dig ds ech emon evt gei guv hlw mhz ntc pms pzem sht son tmp3x v92 */ @@ -302,290 +302,334 @@ void _sensorReset() { void _sensorLoad() { /* + Only loaded (those with *_SUPPORT to 1) and enabled (*Enabled setting to 1) + sensors are being initialized here. + */ - This is temporal, in the future sensors will be initialized based on - soft configuration (data stored in EEPROM config) so you will be able - to define and configure new sensors on the fly - - At the time being, only enabled sensors (those with *_SUPPORT to 1) are being - loaded and initialized here. If you want to add new sensors of the same type - just duplicate the block and change the arguments for the set* methods. - Check the DHT block below for an example - - */ + unsigned char index = 0; + unsigned char gpio = GPIO_NONE; - #if AM2320_SUPPORT - { + #if AM2320_SUPPORT + if (getSetting("amEnabled", 0).toInt() == 1) { AM2320Sensor * sensor = new AM2320Sensor(); - sensor->setAddress(AM2320_ADDRESS); + sensor->setAddress(getSetting("amAddress", AM2320_ADDRESS).toInt()); _sensors.push_back(sensor); - } - #endif + } + #endif #if ANALOG_SUPPORT - { + if (getSetting("anaEnabled", 0).toInt() == 1) { AnalogSensor * sensor = new AnalogSensor(); - sensor->setSamples(ANALOG_SAMPLES); - sensor->setDelay(ANALOG_DELAY); + sensor->setSamples(getSetting("anaSamples", ANALOG_SAMPLES).toInt()); + sensor->setDelay(getSetting("anaDelay", ANALOG_DELAY).toInt()); _sensors.push_back(sensor); } #endif #if BH1750_SUPPORT - { + if (getSetting("bhEnabled", 0).toInt() == 1) { BH1750Sensor * sensor = new BH1750Sensor(); - sensor->setAddress(BH1750_ADDRESS); - sensor->setMode(BH1750_MODE); + sensor->setAddress(getSetting("bhAddress", BH1750_ADDRESS).toInt()); + sensor->setMode(getSetting("bhMode", BH1750_MODE).toInt()); _sensors.push_back(sensor); } #endif #if BMX280_SUPPORT - { + if (getSetting("bmx280Enabled", 0).toInt() == 1) { BMX280Sensor * sensor = new BMX280Sensor(); - sensor->setAddress(BMX280_ADDRESS); + sensor->setAddress(getSetting("bmx280Address", BMX280_ADDRESS).toInt()); _sensors.push_back(sensor); } #endif #if CSE7766_SUPPORT - { - CSE7766Sensor * sensor = new CSE7766Sensor(); - sensor->setRX(CSE7766_PIN); - _sensors.push_back(sensor); - } - #endif + if (getSetting("cseEnabled", 0).toInt() == 1) { + if ((gpio = getSetting("cseGPIO", GPIO_NONE).toInt()) != GPIO_NONE) { - #if DALLAS_SUPPORT - { - DallasSensor * sensor = new DallasSensor(); - sensor->setGPIO(DALLAS_PIN); - _sensors.push_back(sensor); + CSE7766Sensor * sensor = new CSE7766Sensor(); + + sensor->setRX(gpio); + + double value; + value = getSetting("curRatio", 0).toFloat(); + if (value > 0) sensor->setCurrentRatio(value); + value = getSetting("volRatio", 0).toFloat(); + if (value > 0) sensor->setVoltageRatio(value); + value = getSetting("pwrRatio", 0).toFloat(); + if (value > 0) sensor->setPowerRatio(value); + + _sensors.push_back(sensor); + + } } #endif - #if DHT_SUPPORT - { - DHTSensor * sensor = new DHTSensor(); - sensor->setGPIO(DHT_PIN); - sensor->setType(DHT_TYPE); - _sensors.push_back(sensor); + #if DALLAS_SUPPORT + if (getSetting("dsEnabled", 0).toInt() == 1) { + index = 0; + while ((gpio = getSetting("dsGPIO", index, GPIO_NONE).toInt()) != GPIO_NONE) { + DallasSensor * sensor = new DallasSensor(); + sensor->setGPIO(gpio); + _sensors.push_back(sensor); + index++; + } } #endif - /* - // Example on how to add a second DHT sensor - // DHT2_PIN and DHT2_TYPE should be defined in sensors.h file #if DHT_SUPPORT - { - DHTSensor * sensor = new DHTSensor(); - sensor->setGPIO(DHT2_PIN); - sensor->setType(DHT2_TYPE); - _sensors.push_back(sensor); + if (getSetting("dhtEnabled", 0).toInt() == 1) { + index = 0; + while ((gpio = getSetting("dhtGPIO", index, GPIO_NONE).toInt()) != GPIO_NONE) { + DHTSensor * sensor = new DHTSensor(); + sensor->setGPIO(gpio); + sensor->setType(getSetting("dhtType", index, DHT_CHIP_DHT22).toInt()); + _sensors.push_back(sensor); + index++; + } } #endif - */ #if DIGITAL_SUPPORT - { - DigitalSensor * sensor = new DigitalSensor(); - sensor->setGPIO(DIGITAL_PIN); - sensor->setMode(DIGITAL_PIN_MODE); - sensor->setDefault(DIGITAL_DEFAULT_STATE); - _sensors.push_back(sensor); + if (getSetting("digEnabled", 0).toInt() == 1) { + index = 0; + while ((gpio = getSetting("digGPIO", index, GPIO_NONE).toInt()) != GPIO_NONE) { + DigitalSensor * sensor = new DigitalSensor(); + sensor->setGPIO(gpio); + sensor->setMode(getSetting("digMode", index, DIGITAL_PIN_MODE).toInt()); + sensor->setDefault(getSetting("digDefault", index, DIGITAL_DEFAULT_STATE).toInt()); + _sensors.push_back(sensor); + index++; + } } #endif #if ECH1560_SUPPORT - { + if (getSetting("echEnabled", 0).toInt() == 1) { ECH1560Sensor * sensor = new ECH1560Sensor(); - sensor->setCLK(ECH1560_CLK_PIN); - sensor->setMISO(ECH1560_MISO_PIN); - sensor->setInverted(ECH1560_INVERTED); + sensor->setCLK(getSetting("echCLKGPIO", ECH1560_CLK_PIN).toInt()); + sensor->setMISO(getSetting("echMISOGPIO", ECH1560_MISO_PIN).toInt()); + sensor->setInverted(getSetting("echLogic", ECH1560_INVERTED).toInt()); _sensors.push_back(sensor); } #endif - #if EMON_ADC121_SUPPORT - { - EmonADC121Sensor * sensor = new EmonADC121Sensor(); - sensor->setAddress(EMON_ADC121_I2C_ADDRESS); - sensor->setVoltage(EMON_MAINS_VOLTAGE); - sensor->setReference(EMON_REFERENCE_VOLTAGE); - sensor->setCurrentRatio(0, EMON_CURRENT_RATIO); - _sensors.push_back(sensor); - } - #endif + #if EMON_ADC121_SUPPORT || EMON_ADS1X15_SUPPORT || EMON_ANALOG_SUPPORT - #if EMON_ADS1X15_SUPPORT - { - EmonADS1X15Sensor * sensor = new EmonADS1X15Sensor(); - sensor->setAddress(EMON_ADS1X15_I2C_ADDRESS); - sensor->setType(EMON_ADS1X15_TYPE); - sensor->setMask(EMON_ADS1X15_MASK); - sensor->setGain(EMON_ADS1X15_GAIN); - sensor->setVoltage(EMON_MAINS_VOLTAGE); - sensor->setCurrentRatio(0, EMON_CURRENT_RATIO); - sensor->setCurrentRatio(1, EMON_CURRENT_RATIO); - sensor->setCurrentRatio(2, EMON_CURRENT_RATIO); - sensor->setCurrentRatio(3, EMON_CURRENT_RATIO); - _sensors.push_back(sensor); - } - #endif + if (getSetting("emonEnabled", 0).toInt() == 1) { + + #if EMON_ADC121_SUPPORT + if (getSetting("emonProvider", 0).toInt() == EMON_PROVIDER_ADC121) { + EmonADC121Sensor * sensor = new EmonADC121Sensor(); + sensor->setAddress(getSetting("emonAddress", EMON_ADC121_I2C_ADDRESS).toInt()); + sensor->setReference(getSetting("emonReference", EMON_REFERENCE_VOLTAGE).toInt()); + sensor->setCurrentRatio(0, getSetting("curRatio", EMON_CURRENT_RATIO).toFloat()); + sensor->setVoltage(getSetting("volNominal", EMON_MAINS_VOLTAGE).toInt()); + _sensors.push_back(sensor); + } + #endif + + #if EMON_ADS1X15_SUPPORT + if (getSetting("emonProvider", 0).toInt() == EMON_PROVIDER_ADS1X15) { + EmonADS1X15Sensor * sensor = new EmonADS1X15Sensor(); + sensor->setAddress(getSetting("emonAddress", EMON_ADS1X15_I2C_ADDRESS).toInt()); + sensor->setType(getSetting("emonType", EMON_ADS1X15_TYPE).toInt()); + sensor->setMask(getSetting("emonMask", EMON_ADS1X15_MASK).toInt()); + sensor->setGain(getSetting("emonGain", EMON_ADS1X15_GAIN).toInt()); + sensor->setReference(getSetting("emonReference", EMON_REFERENCE_VOLTAGE).toInt()); + double curRatio = getSetting("curRatio", EMON_CURRENT_RATIO).toFloat(); + sensor->setCurrentRatio(0, getSetting("curRatio", 0, curRatio).toFloat()); + sensor->setCurrentRatio(1, getSetting("curRatio", 1, curRatio).toFloat()); + sensor->setCurrentRatio(2, getSetting("curRatio", 2, curRatio).toFloat()); + sensor->setCurrentRatio(3, getSetting("curRatio", 3, curRatio).toFloat()); + sensor->setVoltage(getSetting("volNominal", EMON_MAINS_VOLTAGE).toInt()); + _sensors.push_back(sensor); + } + #endif + + #if EMON_ANALOG_SUPPORT + if (getSetting("emonProvider", 0).toInt() == EMON_PROVIDER_ANALOG) { + EmonAnalogSensor * sensor = new EmonAnalogSensor(); + sensor->setReference(getSetting("emonReference", EMON_REFERENCE_VOLTAGE).toInt()); + sensor->setCurrentRatio(0, getSetting("curRatio", EMON_CURRENT_RATIO).toFloat()); + sensor->setVoltage(getSetting("volNominal", EMON_MAINS_VOLTAGE).toInt()); + _sensors.push_back(sensor); + } + #endif - #if EMON_ANALOG_SUPPORT - { - EmonAnalogSensor * sensor = new EmonAnalogSensor(); - sensor->setVoltage(EMON_MAINS_VOLTAGE); - sensor->setReference(EMON_REFERENCE_VOLTAGE); - sensor->setCurrentRatio(0, EMON_CURRENT_RATIO); - _sensors.push_back(sensor); } + #endif #if EVENTS_SUPPORT - { - EventSensor * sensor = new EventSensor(); - sensor->setGPIO(EVENTS_PIN); - sensor->setTrigger(EVENTS_TRIGGER); - sensor->setPinMode(EVENTS_PIN_MODE); - sensor->setDebounceTime(EVENTS_DEBOUNCE); - sensor->setInterruptMode(EVENTS_INTERRUPT_MODE); - _sensors.push_back(sensor); + if (getSetting("evtEnabled", 0).toInt() == 1) { + index = 0; + while ((gpio = getSetting("evtGPIO", index, GPIO_NONE).toInt()) != GPIO_NONE) { + EventSensor * sensor = new EventSensor(); + sensor->setGPIO(gpio); + sensor->setTrigger(getSetting("evtTrigger", index, EVENTS_TRIGGER).toInt()); + sensor->setPinMode(getSetting("evtMode", index, EVENTS_PIN_MODE).toInt()); + sensor->setDebounceTime(getSetting("evtDebounce", index, EVENTS_DEBOUNCE).toInt()); + sensor->setInterruptMode(getSetting("evtIntMode", index, EVENTS_INTERRUPT_MODE).toInt()); + _sensors.push_back(sensor); + index++; + } } #endif #if GEIGER_SUPPORT - { - GeigerSensor * sensor = new GeigerSensor(); // Create instance of thr Geiger module. - sensor->setGPIO(GEIGER_PIN); // Interrupt pin of the attached geiger counter board. - sensor->setMode(GEIGER_PIN_MODE); // This pin is an input. - sensor->setDebounceTime(GEIGER_DEBOUNCE); // Debounce time 25ms, because https://github.com/Trickx/espurna/wiki/Geiger-counter - sensor->setInterruptMode(GEIGER_INTERRUPT_MODE); // Interrupt triggering: edge detection rising. - sensor->setCPM2SievertFactor(GEIGER_CPM2SIEVERT); // Conversion factor from counts per minute to µSv/h - _sensors.push_back(sensor); + if (getSetting("geiEnabled", 0).toInt() == 1) { + if ((gpio = getSetting("geiGPIO", GPIO_NONE).toInt()) != GPIO_NONE) { + GeigerSensor * sensor = new GeigerSensor(); // Create instance of the Geiger module. + sensor->setGPIO(gpio); // Interrupt pin of the attached geiger counter board. + sensor->setMode(getSetting("geiMode", GEIGER_PIN_MODE).toInt()); // This pin is an input. + sensor->setDebounceTime(getSetting("geiDebounce", GEIGER_DEBOUNCE).toInt()); // Debounce time 25ms, because https://github.com/Trickx/espurna/wiki/Geiger-counter + sensor->setInterruptMode(getSetting("geiIntMode", GEIGER_INTERRUPT_MODE).toInt()); // Interrupt triggering: edge detection rising. + sensor->setCPM2SievertFactor(getSetting("geiRatio", GEIGER_CPM2SIEVERT).toInt()); // Conversion factor from counts per minute to µSv/h + _sensors.push_back(sensor); + } } #endif #if GUVAS12SD_SUPPORT - { - GUVAS12SDSensor * sensor = new GUVAS12SDSensor(); - sensor->setGPIO(GUVAS12SD_PIN); - _sensors.push_back(sensor); + if (getSetting("guvEnabled", 0).toInt() == 1) { + if ((gpio = getSetting("guvGPIO", GPIO_NONE).toInt()) != GPIO_NONE) { + GUVAS12SDSensor * sensor = new GUVAS12SDSensor(); + sensor->setGPIO(gpio); + _sensors.push_back(sensor); + } } #endif #if SONAR_SUPPORT - { + if (getSetting("sonEnabled", 0).toInt() == 1) { SonarSensor * sensor = new SonarSensor(); - sensor->setEcho(SONAR_ECHO); - sensor->setIterations(SONAR_ITERATIONS); - sensor->setMaxDistance(SONAR_MAX_DISTANCE); - sensor->setTrigger(SONAR_TRIGGER); + sensor->setEcho(getSetting("sonEcho", SONAR_ECHO).toInt()); + sensor->setTrigger(getSetting("sonTrigger", SONAR_TRIGGER).toInt()); + sensor->setIterations(getSetting("sonIterations", SONAR_ITERATIONS).toInt()); + sensor->setMaxDistance(getSetting("sonMaxDist", SONAR_MAX_DISTANCE0).toInt()); _sensors.push_back(sensor); } #endif #if HLW8012_SUPPORT - { + if (getSetting("hlwEnabled", 0).toInt() == 1) { + HLW8012Sensor * sensor = new HLW8012Sensor(); - sensor->setSEL(HLW8012_SEL_PIN); - sensor->setCF(HLW8012_CF_PIN); - sensor->setCF1(HLW8012_CF1_PIN); - sensor->setSELCurrent(HLW8012_SEL_CURRENT); + + sensor->setSEL(getSetting("hlwSELGPIO", HLW8012_SEL_PIN).toInt()); + sensor->setCF(getSetting("hlwCFGPIO", HLW8012_CF_PIN).toInt()); + sensor->setCF1(getSetting("hlwCF1GPIO", HLW8012_CF1_PIN).toInt()); + sensor->setCurrentSEL(getSetting("hlwCurSel", HLW8012_SEL_CURRENT).toInt()); + sensor->setInterruptMode(getSetting("hlwIntMode", HLW8012_INTERRUPT_ON).toInt()); + sensor->setCurrentResistor(getSetting("hlwCurRes", HLW8012_CURRENT_R ).toFloat()); + sensor->setUpstreamResistor(getSetting("hlwVolResUp", HLW8012_VOLTAGE_R_UP).toFloat()); + sensor->setDownstreamResistor(getSetting("hlwVolResDw", HLW8012_VOLTAGE_R_DOWN).toFloat()); + + double value; + value = getSetting("curRatio", HLW8012_CURRENT_RATIO).toFloat(); + if (value > 0) sensor->setCurrentRatio(value); + value = getSetting("volRatio", HLW8012_VOLTAGE_RATIO).toFloat(); + if (value > 0) sensor->setVoltageRatio(value); + value = getSetting("pwrRatio", HLW8012_POWER_RATIO).toFloat(); + if (value > 0) sensor->setPowerRatio(value); + _sensors.push_back(sensor); + } #endif #if MHZ19_SUPPORT - { + if (getSetting("mhzEnabled", 0).toInt() == 1) { MHZ19Sensor * sensor = new MHZ19Sensor(); - sensor->setRX(MHZ19_RX_PIN); - sensor->setTX(MHZ19_TX_PIN); + sensor->setRX(getSetting("mhzRX", MHZ19_RX_PIN).toInt()); + sensor->setTX(getSetting("mhzTX", MHZ19_TX_PIN).toInt()); _sensors.push_back(sensor); } #endif #if NTC_SUPPORT - { + if (getSetting("ntcEnabled", 0).toInt() == 1) { NTCSensor * sensor = new NTCSensor(); - sensor->setSamples(NTC_SAMPLES); - sensor->setDelay(NTC_DELAY); - sensor->setUpstreamResistor(NTC_R_UP); - sensor->setDownstreamResistor(NTC_R_DOWN); - sensor->setBeta(NTC_BETA); - sensor->setR0(NTC_R0); - sensor->setT0(NTC_T0); + sensor->setSamples(getSetting("ntcSamples", NTC_SAMPLES).toInt()); + sensor->setDelay(getSetting("ntcDelay", NTC_DELAY).toInt()); + sensor->setUpstreamResistor(getSetting("ntcResUp", NTC_R_UP).toInt()); + sensor->setDownstreamResistor(getSetting("ntcResDown", NTC_R_DOWN).toInt()); + sensor->setBeta(getSetting("ntcBeta", NTC_BETA).toInt()); + sensor->setR0(getSetting("ntcR0", NTC_R0).toInt()); + sensor->setT0(getSetting("ntcT0", NTC_T0).toFloat()); _sensors.push_back(sensor); } #endif #if SENSEAIR_SUPPORT - { + if (getSetting("airEnabled", 0).toInt() == 1) { SenseAirSensor * sensor = new SenseAirSensor(); - sensor->setRX(SENSEAIR_RX_PIN); - sensor->setTX(SENSEAIR_TX_PIN); + sensor->setRX(getSetting("airRX", SENSEAIR_RX_PIN).toInt()); + sensor->setTX(getSetting("airTX", SENSEAIR_TX_PIN).toInt()); _sensors.push_back(sensor); } #endif #if PMSX003_SUPPORT - { + if (getSetting("pmsEnabled", 0).toInt() == 1) { PMSX003Sensor * sensor = new PMSX003Sensor(); - #if PMS_USE_SOFT - sensor->setRX(PMS_RX_PIN); - sensor->setTX(PMS_TX_PIN); - #else + if (getSetting("pmsSoft", PMS_USE_SOFT).toInt() == 1) { + sensor->setRX(getSetting("pmsRX", PMS_RX_PIN).toInt()); + sensor->setTX(getSetting("pmsTX", PMS_TX_PIN).toInt()); + } else { sensor->setSerial(& PMS_HW_PORT); - #endif - sensor->setType(PMS_TYPE); + } + sensor->setType(getSetting("pmsType", PMS_TYPE).toInt()); _sensors.push_back(sensor); } #endif #if PZEM004T_SUPPORT - { + if (getSetting("pzemEnabled", 0).toInt() == 1) { PZEM004TSensor * sensor = new PZEM004TSensor(); - #if PZEM004T_USE_SOFT - sensor->setRX(PZEM004T_RX_PIN); - sensor->setTX(PZEM004T_TX_PIN); - #else + if (getSetting("pzemSoft", PZEM004T_USE_SOFT).toInt() == 1) { + sensor->setRX(getSetting("pzemRX", PZEM004T_RX_PIN).toInt()); + sensor->setTX(getSetting("pzemTX", PZEM004T_TX_PIN).toInt()); + } else { sensor->setSerial(& PZEM004T_HW_PORT); - #endif + } _sensors.push_back(sensor); } #endif #if SHT3X_I2C_SUPPORT - { - SHT3XI2CSensor * sensor = new SHT3XI2CSensor(); - sensor->setAddress(SHT3X_I2C_ADDRESS); - _sensors.push_back(sensor); + if (getSetting("shtEnabled", 0).toInt() == 1) { + SHT3XI2CSensor * sensor = new SHT3XI2CSensor(); + sensor->setAddress(getSetting("shtAddress", SHT3X_I2C_ADDRESS).toInt()); + _sensors.push_back(sensor); } #endif #if SI7021_SUPPORT - { - SI7021Sensor * sensor = new SI7021Sensor(); - sensor->setAddress(SI7021_ADDRESS); - _sensors.push_back(sensor); + if (getSetting("si7021Enabled", 0).toInt() == 1) { + SI7021Sensor * sensor = new SI7021Sensor(); + sensor->setAddress(getSetting("si7021Address", SI7021_ADDRESS).toInt()); + _sensors.push_back(sensor); } #endif #if TMP3X_SUPPORT - { - TMP3XSensor * sensor = new TMP3XSensor(); - sensor->setType(TMP3X_TYPE); - _sensors.push_back(sensor); + if (getSetting("tmp3xEnabled", 0).toInt() == 1) { + TMP3XSensor * sensor = new TMP3XSensor(); + sensor->setType(getSetting("tmp3xType", TMP3X_TYPE).toInt()); + _sensors.push_back(sensor); } #endif #if V9261F_SUPPORT - { - V9261FSensor * sensor = new V9261FSensor(); - sensor->setRX(V9261F_PIN); - sensor->setInverted(V9261F_PIN_INVERSE); - _sensors.push_back(sensor); + if (getSetting("v92Enabled", 0).toInt() == 1) { + if ((gpio = getSetting("v92GPIO", GPIO_NONE).toInt()) != GPIO_NONE) { + V9261FSensor * sensor = new V9261FSensor(); + sensor->setRX(gpio); + sensor->setInverted(getSetting("v92Inverse", V9261F_PIN_INVERSE).toInt()); + _sensors.push_back(sensor); + } } #endif @@ -657,60 +701,6 @@ void _sensorInit() { _sensorCallback(i, type, value); }); - // Custom initializations - - #if EMON_ANALOG_SUPPORT - - if (_sensors[i]->getID() == SENSOR_EMON_ANALOG_ID) { - EmonAnalogSensor * sensor = (EmonAnalogSensor *) _sensors[i]; - sensor->setCurrentRatio(0, getSetting("curRatio", EMON_CURRENT_RATIO).toFloat()); - sensor->setVoltage(getSetting("volNominal", EMON_MAINS_VOLTAGE).toInt()); - } - - #endif // EMON_ANALOG_SUPPORT - - #if HLW8012_SUPPORT - - if (_sensors[i]->getID() == SENSOR_HLW8012_ID) { - - HLW8012Sensor * sensor = (HLW8012Sensor *) _sensors[i]; - - double value; - - value = getSetting("curRatio", HLW8012_CURRENT_RATIO).toFloat(); - if (value > 0) sensor->setCurrentRatio(value); - - value = getSetting("volRatio", HLW8012_VOLTAGE_RATIO).toFloat(); - if (value > 0) sensor->setVoltageRatio(value); - - value = getSetting("pwrRatio", HLW8012_POWER_RATIO).toFloat(); - if (value > 0) sensor->setPowerRatio(value); - - } - - #endif // HLW8012_SUPPORT - - #if CSE7766_SUPPORT - - if (_sensors[i]->getID() == SENSOR_CSE7766_ID) { - - CSE7766Sensor * sensor = (CSE7766Sensor *) _sensors[i]; - - double value; - - value = getSetting("curRatio", 0).toFloat(); - if (value > 0) sensor->setCurrentRatio(value); - - value = getSetting("volRatio", 0).toFloat(); - if (value > 0) sensor->setVoltageRatio(value); - - value = getSetting("pwrRatio", 0).toFloat(); - if (value > 0) sensor->setPowerRatio(value); - - } - - #endif // CSE7766_SUPPORT - } } @@ -883,17 +873,32 @@ bool _sensorKeyCheck(const char * key) { if (strncmp(key, "tmp", 3) == 0) return true; if (strncmp(key, "hum", 3) == 0) return true; - if (strncmp(key, "bme", 3) == 0) return true; + if (strncmp(key, "air", 3) == 0) return true; + if (strncmp(key, "am", 2) == 0) return true; + if (strncmp(key, "ana", 3) == 0) return true; + if (strncmp(key, "bh", 2) == 0) return true; + if (strncmp(key, "bmx", 3) == 0) return true; + if (strncmp(key, "cse", 3) == 0) return true; if (strncmp(key, "dht", 3) == 0) return true; + if (strncmp(key, "dig", 3) == 0) return true; if (strncmp(key, "ds" , 2) == 0) return true; - if (strncmp(key, "hlw", 3) == 0) return true; - if (strncmp(key, "cse", 3) == 0) return true; - if (strncmp(key, "v92", 3) == 0) return true; if (strncmp(key, "ech", 3) == 0) return true; + if (strncmp(key, "emon", 4) == 0) return true; + if (strncmp(key, "evt", 3) == 0) return true; if (strncmp(key, "gei", 3) == 0) return true; - if (strncmp(key, "pze", 3) == 0) return true; + if (strncmp(key, "guv", 3) == 0) return true; + if (strncmp(key, "hlw", 3) == 0) return true; + if (strncmp(key, "mhz", 3) == 0) return true; + if (strncmp(key, "ntc", 3) == 0) return true; + if (strncmp(key, "pms", 3) == 0) return true; + if (strncmp(key, "pzem", 4) == 0) return true; + if (strncmp(key, "sht", 3) == 0) return true; + if (strncmp(key, "son", 3) == 0) return true; + if (strncmp(key, "tmp3x", 4) == 0) return true; + if (strncmp(key, "v92", 3) == 0) return true; return false; + } void _sensorBackwards() { diff --git a/code/espurna/sensors/HLW8012Sensor.h b/code/espurna/sensors/HLW8012Sensor.h index a65e74b1..19017795 100644 --- a/code/espurna/sensors/HLW8012Sensor.h +++ b/code/espurna/sensors/HLW8012Sensor.h @@ -72,10 +72,14 @@ class HLW8012Sensor : public BaseSensor { _dirty = true; } - void setSELCurrent(bool value) { + void setCurrentSEL(bool value) { _sel_current = value; } + void setInterruptMode(unsigned char mode) { + _interrupt_mode = mode; + } + void setCurrentRatio(double value) { _hlw8012->setCurrentMultiplier(value); }; @@ -88,6 +92,18 @@ class HLW8012Sensor : public BaseSensor { _hlw8012->setPowerMultiplier(value); }; + void setCurrentResistor(double value) { + _current_resistor = value; + }; + + void setUpstreamResistor(double value) { + _upstream_resistor = value; + }; + + void setDownstreamResistor(double value) { + _downstream_resistor = value; + }; + // --------------------------------------------------------------------- unsigned char getSEL() { @@ -143,7 +159,7 @@ class HLW8012Sensor : public BaseSensor { // * The CURRENT_RESISTOR is the 1milliOhm copper-manganese resistor in series with the main line // * The VOLTAGE_RESISTOR_UPSTREAM are the 5 470kOhm resistors in the voltage divider that feeds the V2P pin in the HLW8012 // * The VOLTAGE_RESISTOR_DOWNSTREAM is the 1kOhm resistor in the voltage divider that feeds the V2P pin in the HLW8012 - _hlw8012->setResistors(HLW8012_CURRENT_R, HLW8012_VOLTAGE_R_UP, HLW8012_VOLTAGE_R_DOWN); + _hlw8012->setResistors(_current_resistor, _upstream_resistor, _downstream_resistor); // Handle interrupts #if HLW8012_USE_INTERRUPTS @@ -234,13 +250,13 @@ class HLW8012Sensor : public BaseSensor { if (_interrupt_cf != _cf) { if (_interrupt_cf != GPIO_NONE) _detach(_interrupt_cf); - _attach(this, _cf, HLW8012_INTERRUPT_ON); + _attach(this, _cf, _interrupt_mode); _interrupt_cf = _cf; } if (_interrupt_cf1 != _cf1) { if (_interrupt_cf1 != GPIO_NONE) _detach(_interrupt_cf1); - _attach(this, _cf1, HLW8012_INTERRUPT_ON); + _attach(this, _cf1, _interrupt_mode); _interrupt_cf1 = _cf1; } @@ -260,7 +276,12 @@ class HLW8012Sensor : public BaseSensor { unsigned char _sel = GPIO_NONE; unsigned char _cf = GPIO_NONE; unsigned char _cf1 = GPIO_NONE; + bool _sel_current = true; + unsigned char _interrupt_mode = HLW8012_INTERRUPT_ON; + double _current_resistor = HLW8012_CURRENT_R; + double _upstream_resistor = HLW8012_VOLTAGE_R_UP; + double _downstream_resistor = HLW8012_VOLTAGE_R_DOWN; HLW8012 * _hlw8012 = NULL; diff --git a/code/espurna/sensors/PMSX003Sensor.h b/code/espurna/sensors/PMSX003Sensor.h index 64611418..1a09c604 100644 --- a/code/espurna/sensors/PMSX003Sensor.h +++ b/code/espurna/sensors/PMSX003Sensor.h @@ -11,10 +11,7 @@ #include "Arduino.h" #include "BaseSensor.h" - -#if PMS_USE_SOFT #include -#endif // Generic data #define PMS_BAUD_RATE 9600