From d54f5c29bf8848bba45f8b9c33cc43ff3963a80c Mon Sep 17 00:00:00 2001 From: Thomas Eckerstorfer Date: Sat, 7 Jul 2018 00:36:07 +0200 Subject: [PATCH 1/3] tx20 wind sensor added --- sonoff/language/bg-BG.h | 24 +++++ sonoff/language/cs-CZ.h | 24 +++++ sonoff/language/de-DE.h | 24 +++++ sonoff/language/el-GR.h | 24 +++++ sonoff/language/en-GB.h | 25 +++++ sonoff/language/es-AR.h | 24 +++++ sonoff/language/fr-FR.h | 24 +++++ sonoff/language/hu-HU.h | 24 +++++ sonoff/language/it-IT.h | 24 +++++ sonoff/language/nl-NL.h | 24 +++++ sonoff/language/pl-PL.h | 24 +++++ sonoff/language/pt-BR.h | 24 +++++ sonoff/language/pt-PT.h | 24 +++++ sonoff/language/ru-RU.h | 24 +++++ sonoff/language/uk-UK.h | 24 +++++ sonoff/language/zh-CN.h | 24 +++++ sonoff/language/zh-TW.h | 24 +++++ sonoff/sonoff.ino | 1 + sonoff/sonoff_template.h | 4 +- sonoff/xsns_91_tx20.ino | 204 +++++++++++++++++++++++++++++++++++++++ 20 files changed, 617 insertions(+), 1 deletion(-) create mode 100644 sonoff/xsns_91_tx20.ino diff --git a/sonoff/language/bg-BG.h b/sonoff/language/bg-BG.h index c485b79ffb84..9e852273f51a 100644 --- a/sonoff/language/bg-BG.h +++ b/sonoff/language/bg-BG.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Calibrated" #define D_HX_CAL_FAIL "Calibration failed" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "Няма" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/cs-CZ.h b/sonoff/language/cs-CZ.h index ab548ad702c0..b6a7e5e5b258 100644 --- a/sonoff/language/cs-CZ.h +++ b/sonoff/language/cs-CZ.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Zkalibrováno" #define D_HX_CAL_FAIL "Chyba kalibrace" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "Není" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/de-DE.h b/sonoff/language/de-DE.h index 19cbff44b6d0..2c66503e5ffc 100644 --- a/sonoff/language/de-DE.h +++ b/sonoff/language/de-DE.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "kalibriert" #define D_HX_CAL_FAIL "Kalibrierung fehlgeschlagen" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "None" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/el-GR.h b/sonoff/language/el-GR.h index c0873dd07d4c..535b4123968b 100644 --- a/sonoff/language/el-GR.h +++ b/sonoff/language/el-GR.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Calibrated" #define D_HX_CAL_FAIL "Calibration failed" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "Κανένας" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/en-GB.h b/sonoff/language/en-GB.h index eed796889f1e..af2fb05d689b 100644 --- a/sonoff/language/en-GB.h +++ b/sonoff/language/en-GB.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Calibrated" #define D_HX_CAL_FAIL "Calibration failed" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "None" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,8 @@ #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_HERTZ "Hz" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/es-AR.h b/sonoff/language/es-AR.h index cf34dbce9c4b..aa53d266f4d3 100644 --- a/sonoff/language/es-AR.h +++ b/sonoff/language/es-AR.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Calibrado" #define D_HX_CAL_FAIL "Falló Calibración" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "Ninguno" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/fr-FR.h b/sonoff/language/fr-FR.h index b70cbbb8bb2d..37b21381cc2a 100644 --- a/sonoff/language/fr-FR.h +++ b/sonoff/language/fr-FR.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Calibrated" #define D_HX_CAL_FAIL "Calibration failed" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "Aucun" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/hu-HU.h b/sonoff/language/hu-HU.h index b33e4cc41f31..3f366c042562 100644 --- a/sonoff/language/hu-HU.h +++ b/sonoff/language/hu-HU.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Calibrated" #define D_HX_CAL_FAIL "Calibration failed" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "Nincs" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/it-IT.h b/sonoff/language/it-IT.h index e819c85580d3..8f99d5910c5d 100644 --- a/sonoff/language/it-IT.h +++ b/sonoff/language/it-IT.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Calibrated" #define D_HX_CAL_FAIL "Calibration failed" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "Nessuno" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/nl-NL.h b/sonoff/language/nl-NL.h index eef55f90ae3c..42e3a59e21dc 100644 --- a/sonoff/language/nl-NL.h +++ b/sonoff/language/nl-NL.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Ge-ijkt" #define D_HX_CAL_FAIL "Ijken is mislukt" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "Geen" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/pl-PL.h b/sonoff/language/pl-PL.h index a99b9e9720a2..afd907c1b3dd 100644 --- a/sonoff/language/pl-PL.h +++ b/sonoff/language/pl-PL.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Calibrated" #define D_HX_CAL_FAIL "Calibration failed" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "Brak" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/pt-BR.h b/sonoff/language/pt-BR.h index fa8caec36f5e..09272e0e5cc0 100644 --- a/sonoff/language/pt-BR.h +++ b/sonoff/language/pt-BR.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Calibrated" #define D_HX_CAL_FAIL "Calibration failed" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "Nenhum" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "W/h" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/pt-PT.h b/sonoff/language/pt-PT.h index ae2ee431650a..848f45bcb4b5 100644 --- a/sonoff/language/pt-PT.h +++ b/sonoff/language/pt-PT.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Calibrated" #define D_HX_CAL_FAIL "Calibration failed" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "Nenhum" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/ru-RU.h b/sonoff/language/ru-RU.h index 61c2c2f08a5d..85b52199d0e0 100644 --- a/sonoff/language/ru-RU.h +++ b/sonoff/language/ru-RU.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Calibrated" #define D_HX_CAL_FAIL "Calibration failed" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "-нет-" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "Вт" #define D_UNIT_WATTHOUR "ВтЧ" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/uk-UK.h b/sonoff/language/uk-UK.h index 1b075a4b6f8e..57361056742c 100644 --- a/sonoff/language/uk-UK.h +++ b/sonoff/language/uk-UK.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Calibrated" #define D_HX_CAL_FAIL "Calibration failed" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "-відсутньо-" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "Вт" #define D_UNIT_WATTHOUR "ВтГод" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/zh-CN.h b/sonoff/language/zh-CN.h index 63f687f3ebdc..5d24e336cfd4 100644 --- a/sonoff/language/zh-CN.h +++ b/sonoff/language/zh-CN.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Calibrated" #define D_HX_CAL_FAIL "Calibration failed" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "无" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATTHOUR "瓦时" #define D_UNIT_HERTZ "赫兹" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/language/zh-TW.h b/sonoff/language/zh-TW.h index 89222d077bd8..d35751bed646 100644 --- a/sonoff/language/zh-TW.h +++ b/sonoff/language/zh-TW.h @@ -462,6 +462,28 @@ #define D_HX_CAL_DONE "Calibrated" #define D_HX_CAL_FAIL "Calibration failed" +//xsns_91_tx20 +#define D_TX20_NORTH "N" +#define D_TX20_NORTH_NORTH_EAST "NNE" +#define D_TX20_NORTH_EAST "NE" +#define D_TX20_EAST_NORTH_EAST "ENE" +#define D_TX20_EAST "E" +#define D_TX20_EAST_SOUTH_EAST "ESE" +#define D_TX20_SOUTH_EAST "SE" +#define D_TX20_SOUTH_SOUTH_EAST "SSE" +#define D_TX20_SOUTH "S" +#define D_TX20_SOUTH_SOUTH_WEST "SSW" +#define D_TX20_SOUTH_WEST "SW" +#define D_TX20_WEST_SOUTH_WEST "WSW" +#define D_TX20_WEST "W" +#define D_TX20_WEST_NORTH_WEST "WNW" + +#define D_TX20_NORTH_WEST "NW" +#define D_TX20_NORTH_NORTH_WEST "NNW" +#define D_TX20_WIND_DIRECTION "Wind Direction" +#define D_TX20_WIND_SPEED_AVG "Wind Speed Avg" +#define D_TX20_WIND_SPEED_MAX "Wind Speed Max" + // sonoff_template.h #define D_SENSOR_NONE "None" #define D_SENSOR_DHT11 "DHT11" @@ -502,6 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" +#define D_SENSOR_TX20_TX "TX20 TxD (Black)" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" @@ -536,6 +559,7 @@ #define D_UNIT_WATT "瓦" #define D_UNIT_WATTHOUR "瓦時" #define D_UNIT_WATT_METER_QUADRAT "W/m²" +#define D_UNIT_KMH "kpH" // Log message prefix #define D_LOG_APPLICATION "APP: " // Application diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index edb9253fb7e0..278af4c538c7 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -2726,4 +2726,5 @@ void loop() // yield(); // yield == delay(0), delay contains yield, auto yield in loop delay(sleep); // https://github.com/esp8266/Arduino/issues/2021 + XsnsCall(FUNC_LOOP); } diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index ad2a44e6bcb3..1cafc241cdf8 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -128,6 +128,7 @@ enum UserSelectablePins { GPIO_SDS0X1_TX, // Nova Fitness SDS011 Serial interface GPIO_HX711_SCK, // HX711 Load Cell clock GPIO_HX711_DAT, // HX711 Load Cell data + GPIO_TX20_TXD_BLACK, // TX20 Transmission Pin GPIO_SENSOR_END }; // Programmer selectable GPIO functionality offset by user selectable GPIOs @@ -182,7 +183,8 @@ const char kSensorNames[] PROGMEM = D_SENSOR_COUNTER "1n|" D_SENSOR_COUNTER "2n|" D_SENSOR_COUNTER "3n|" D_SENSOR_COUNTER "4n|" D_SENSOR_PZEM016_RX "|" D_SENSOR_PZEM017_RX "|" D_SENSOR_DFR562 "|" D_SENSOR_SDS0X1_TX "|" - D_SENSOR_HX711_SCK "|" D_SENSOR_HX711_DAT; + D_SENSOR_HX711_SCK "|" D_SENSOR_HX711_DAT "|" + D_SENSOR_TX20_TX; /********************************************************************************************/ diff --git a/sonoff/xsns_91_tx20.ino b/sonoff/xsns_91_tx20.ino new file mode 100644 index 000000000000..c349040e11ac --- /dev/null +++ b/sonoff/xsns_91_tx20.ino @@ -0,0 +1,204 @@ +/* + xsns_91_Tx20.ino - Tx20 wind sensor + support for Sonoff-Tasmota + + Copyright (C) 2018 Thomas Eckerstorfer and Theo Arends + based on https://github.com/bunnyhu/ESP8266_TX20_wind_sensor/ + http://blog.bubux.de/windsensor-tx20-mit-esp8266/ + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +/*********************************************************************************************\ + * Tx20 wind sensor + \*********************************************************************************************/ + +#ifdef USE_WEBSERVER + +const char HTTP_SNS_TX20[] PROGMEM = "%s" + "{s} " D_TX20_WIND_SPEED_AVG "{m}%s " D_UNIT_KMH "{e}" + "{s} " D_TX20_WIND_SPEED_MAX "{m}%s " D_UNIT_KMH "{e}" + "{s} " D_TX20_WIND_DIRECTION "{m}%s {e}"; + +#endif // USE_WEBSERVER + +const char TX20_Directions[16][4] = { + {D_TX20_NORTH}, {D_TX20_NORTH_NORTH_EAST}, + {D_TX20_NORTH_EAST}, {D_TX20_EAST_NORTH_EAST}, + {D_TX20_EAST}, {D_TX20_EAST_SOUTH_EAST}, + {D_TX20_SOUTH_EAST}, {D_TX20_SOUTH_SOUTH_EAST}, + {D_TX20_SOUTH}, {D_TX20_SOUTH_SOUTH_WEST}, + {D_TX20_SOUTH_WEST}, {D_TX20_WEST_SOUTH_WEST}, + {D_TX20_WEST}, {D_TX20_NORTH_NORTH_WEST}, + {D_TX20_NORTH_WEST}, {D_TX20_NORTH_NORTH_WEST}}; + +unsigned char chk; +unsigned char sa, sb, sd, se; +unsigned int sc, sf, dpin; +boolean validData = false; +boolean showData = false; +float wind_speed_max = 0; +float wind_sum = 0; +float count = 0; +float wind_speed_kmh = 0; + +boolean readTX20() { + int bitcount = 0; + + sa = sb = sd = se = 0; + sc = 0; + sf = 0; + String tx20RawDataS = ""; + // delayMicroseconds(2000); + + for (bitcount = 41; bitcount > 0; bitcount--) { + dpin = (digitalRead(pin[GPIO_TX20_TXD_BLACK])); + if (!dpin) { + tx20RawDataS += "1"; + } else { + tx20RawDataS += "0"; + } + if ((bitcount == 41 - 4) || (bitcount == 41 - 8) || (bitcount == 41 - 20) || + (bitcount == 41 - 24) || (bitcount == 41 - 28)) { + tx20RawDataS += " "; + } + if (bitcount > 41 - 5) { + // start, inverted + sa = (sa << 1) | (dpin ^ 1); + } else if (bitcount > 41 - 5 - 4) { + // wind dir, inverted + sb = sb >> 1 | ((dpin ^ 1) << 3); + } else if (bitcount > 41 - 5 - 4 - 12) { + // windspeed, inverted + sc = sc >> 1 | ((dpin ^ 1) << 11); + } else if (bitcount > 41 - 5 - 4 - 12 - 4) { + // checksum, inverted + sd = sd >> 1 | ((dpin ^ 1) << 3); + } else if (bitcount > 41 - 5 - 4 - 12 - 4 - 4) { + // wind dir + se = se >> 1 | (dpin << 3); + } else { + // windspeed + sf = sf >> 1 | (dpin << 11); + } + + delayMicroseconds(1220); + } + chk = (sb + (sc & 0xf) + ((sc >> 4) & 0xf) + ((sc >> 8) & 0xf)); + chk &= 0xf; + + if ((chk == sd) && + (sc < 400)) { // if checksum seems to be ok and wind speed below 40 m/s + return true; + } else { + return false; + } +} + +void Tx20Init() { + if (pin[GPIO_TX20_TXD_BLACK] < 99) { + AddLog(LOG_LEVEL_DEBUG); + pinMode(pin[GPIO_TX20_TXD_BLACK], INPUT); + } +} + +void Tx20Read() { + if (digitalRead(pin[GPIO_TX20_TXD_BLACK]) == 1) { + validData = readTX20(); + if (validData) { + count++; + float dir_now = float(sb) * 22.5; + float kmph = 0.36; + wind_speed_kmh = kmph * float(sc); + if (wind_speed_kmh > wind_speed_max) { + wind_speed_max = wind_speed_kmh; + } + wind_sum += wind_speed_kmh; + showData = true; + } + } +} + +void Tx20Show(boolean json) { + char wind_speed_string[10]; + char wind_speed_max_string[10]; + char wind_speed_avg_string[10]; + const char *wind_direction; + + if (showData) { + wind_direction = TX20_Directions[sb]; + dtostrf(wind_speed_kmh, 1, 2, wind_speed_string); + dtostrf(wind_speed_max, 1, 2, wind_speed_max_string); + + snprintf_P(log_data, sizeof(log_data), PSTR("Wind direction: %s"), + wind_direction); + AddLog(LOG_LEVEL_DEBUG); + snprintf_P(log_data, sizeof(log_data), PSTR("Wind max: %s km/h"), + wind_speed_max_string); + AddLog(LOG_LEVEL_DEBUG); + snprintf_P(log_data, sizeof(log_data), PSTR("Wind speed: %s km/h"), + wind_speed_string); + AddLog(LOG_LEVEL_DEBUG); + dtostrf(wind_sum / count, 1, 2, wind_speed_avg_string); + snprintf_P(log_data, sizeof(log_data), PSTR("Wind avg: %s km/h"), + wind_speed_avg_string); + AddLog(LOG_LEVEL_DEBUG); + + if (json) { + snprintf_P(mqtt_data, sizeof(mqtt_data), + PSTR("%s,\"TX20\":{\"SPEED_AVG:\":%s, \"SPEED_MAX\":%s, " + "\"DIRECTION\":\"%s\"}"), + mqtt_data, wind_speed_avg_string, wind_speed_max_string, + wind_direction); +#ifdef USE_WEBSERVER + } else { + snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TX20, + mqtt_data, wind_speed_avg_string, wind_speed_max_string, wind_direction); + +#endif // USE_WEBSERVER + } + + // showData = false; + count = 0; + wind_sum = 0; + wind_speed_max = 0; + } +} + + /*********************************************************************************************\ + * Interface + \*********************************************************************************************/ + +#define XSNS_91 + +boolean Xsns91(byte function) { + boolean result = false; + switch (function) { + case FUNC_INIT: + Tx20Init(); + break; + case FUNC_LOOP: + Tx20Read(); + break; + case FUNC_JSON_APPEND: + Tx20Show(1); + break; +#ifdef USE_WEBSERVER + case FUNC_WEB_APPEND: + Tx20Show(0); + break; +#endif // USE_WEBSERVER + } + return result; +} From ed2044f5afaa6369a4434628f76d1e3d6bf024aa Mon Sep 17 00:00:00 2001 From: Thomas Eckerstorfer Date: Sat, 7 Jul 2018 00:50:05 +0200 Subject: [PATCH 2/3] updated language files --- sonoff/language/bg-BG.h | 2 +- sonoff/language/cs-CZ.h | 2 +- sonoff/language/de-DE.h | 2 +- sonoff/language/el-GR.h | 2 +- sonoff/language/en-GB.h | 2 +- sonoff/language/es-AR.h | 2 +- sonoff/language/fr-FR.h | 2 +- sonoff/language/hu-HU.h | 2 +- sonoff/language/it-IT.h | 2 +- sonoff/language/nl-NL.h | 2 +- sonoff/language/pl-PL.h | 2 +- sonoff/language/pt-BR.h | 2 +- sonoff/language/pt-PT.h | 2 +- sonoff/language/ru-RU.h | 2 +- sonoff/language/uk-UK.h | 2 +- sonoff/language/zh-CN.h | 2 +- sonoff/language/zh-TW.h | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/sonoff/language/bg-BG.h b/sonoff/language/bg-BG.h index 9e852273f51a..48ef43f679bf 100644 --- a/sonoff/language/bg-BG.h +++ b/sonoff/language/bg-BG.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/cs-CZ.h b/sonoff/language/cs-CZ.h index b6a7e5e5b258..4534b7d715d5 100644 --- a/sonoff/language/cs-CZ.h +++ b/sonoff/language/cs-CZ.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/de-DE.h b/sonoff/language/de-DE.h index 2c66503e5ffc..68b8123ea0d0 100644 --- a/sonoff/language/de-DE.h +++ b/sonoff/language/de-DE.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/el-GR.h b/sonoff/language/el-GR.h index 535b4123968b..da01d4218253 100644 --- a/sonoff/language/el-GR.h +++ b/sonoff/language/el-GR.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/en-GB.h b/sonoff/language/en-GB.h index af2fb05d689b..585600fcc599 100644 --- a/sonoff/language/en-GB.h +++ b/sonoff/language/en-GB.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/es-AR.h b/sonoff/language/es-AR.h index aa53d266f4d3..d41e141b2e12 100644 --- a/sonoff/language/es-AR.h +++ b/sonoff/language/es-AR.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/fr-FR.h b/sonoff/language/fr-FR.h index 37b21381cc2a..f3394a740aa1 100644 --- a/sonoff/language/fr-FR.h +++ b/sonoff/language/fr-FR.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/hu-HU.h b/sonoff/language/hu-HU.h index 3f366c042562..0c479cf2b7c9 100644 --- a/sonoff/language/hu-HU.h +++ b/sonoff/language/hu-HU.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/it-IT.h b/sonoff/language/it-IT.h index 8f99d5910c5d..4f857480b576 100644 --- a/sonoff/language/it-IT.h +++ b/sonoff/language/it-IT.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/nl-NL.h b/sonoff/language/nl-NL.h index 42e3a59e21dc..7f8914fb58d6 100644 --- a/sonoff/language/nl-NL.h +++ b/sonoff/language/nl-NL.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/pl-PL.h b/sonoff/language/pl-PL.h index afd907c1b3dd..3806646139e6 100644 --- a/sonoff/language/pl-PL.h +++ b/sonoff/language/pl-PL.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/pt-BR.h b/sonoff/language/pt-BR.h index 09272e0e5cc0..164326b4095f 100644 --- a/sonoff/language/pt-BR.h +++ b/sonoff/language/pt-BR.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/pt-PT.h b/sonoff/language/pt-PT.h index 848f45bcb4b5..e014d6922857 100644 --- a/sonoff/language/pt-PT.h +++ b/sonoff/language/pt-PT.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/ru-RU.h b/sonoff/language/ru-RU.h index 85b52199d0e0..5670da739e49 100644 --- a/sonoff/language/ru-RU.h +++ b/sonoff/language/ru-RU.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/uk-UK.h b/sonoff/language/uk-UK.h index 57361056742c..4bc8d048261f 100644 --- a/sonoff/language/uk-UK.h +++ b/sonoff/language/uk-UK.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/zh-CN.h b/sonoff/language/zh-CN.h index 5d24e336cfd4..0c913822a7f3 100644 --- a/sonoff/language/zh-CN.h +++ b/sonoff/language/zh-CN.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" diff --git a/sonoff/language/zh-TW.h b/sonoff/language/zh-TW.h index d35751bed646..ed734caeff6d 100644 --- a/sonoff/language/zh-TW.h +++ b/sonoff/language/zh-TW.h @@ -524,7 +524,7 @@ #define D_SENSOR_SDM120_RX "SDM120 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" -#define D_SENSOR_TX20_TX "TX20 TxD (Black)" +#define D_SENSOR_TX20_TX "TX20 TxD Black" #define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_STB "TM16 STB" From 7c9de92d321a3b2d87ff5aaef6f75a4a915dcbdf Mon Sep 17 00:00:00 2001 From: Thomas Eckerstorfer Date: Sat, 20 Oct 2018 09:54:56 +0200 Subject: [PATCH 3/3] Added possibility to disable sensor. --- sonoff/user_config.h | 2 ++ sonoff/xsns_91_tx20.ino | 2 ++ 2 files changed, 4 insertions(+) diff --git a/sonoff/user_config.h b/sonoff/user_config.h index 32fbaa8ca0ce..d2d7eb015614 100644 --- a/sonoff/user_config.h +++ b/sonoff/user_config.h @@ -381,6 +381,8 @@ #define USE_TUYA_DIMMER // Add support for Tuya Serial Dimmer #define TUYA_DIMMER_ID 3 // Default dimmer Id +#define USE_TX20_wind_sensor // TX20 Wind sensor (+1k5 code) + /*********************************************************************************************\ * Debug features are only supported in development branch \*********************************************************************************************/ diff --git a/sonoff/xsns_91_tx20.ino b/sonoff/xsns_91_tx20.ino index c349040e11ac..fdbee8479cce 100644 --- a/sonoff/xsns_91_tx20.ino +++ b/sonoff/xsns_91_tx20.ino @@ -23,6 +23,7 @@ /*********************************************************************************************\ * Tx20 wind sensor \*********************************************************************************************/ +#ifdef USE_TX20_wind_sensor #ifdef USE_WEBSERVER @@ -202,3 +203,4 @@ boolean Xsns91(byte function) { } return result; } +#endif // USE_TX20_wind_sensor \ No newline at end of file