mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 20:56:35 +00:00
Merge remote-tracking branch 'upstream/development' into development
Conflicts: sonoff/language/it-IT.h
This commit is contained in:
commit
b6ed95a298
12
README.md
12
README.md
@ -1,7 +1,7 @@
|
|||||||
## Sonoff-Tasmota
|
## Sonoff-Tasmota
|
||||||
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
|
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
|
||||||
|
|
||||||
Current version is **5.10.0d** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
|
Current version is **5.10.0e** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
|
||||||
|
|
||||||
### ATTENTION All versions
|
### ATTENTION All versions
|
||||||
|
|
||||||
@ -42,6 +42,7 @@ The following devices are supported:
|
|||||||
- [iTead Sonoff 4CH](https://www.itead.cc/smart-home/sonoff-4ch.html)
|
- [iTead Sonoff 4CH](https://www.itead.cc/smart-home/sonoff-4ch.html)
|
||||||
- [iTead Sonoff 4CH Pro](https://www.itead.cc/smart-home/sonoff-4ch-pro.html)
|
- [iTead Sonoff 4CH Pro](https://www.itead.cc/smart-home/sonoff-4ch-pro.html)
|
||||||
- [iTead S20 Smart Socket](https://www.itead.cc/smart-socket.html)
|
- [iTead S20 Smart Socket](https://www.itead.cc/smart-socket.html)
|
||||||
|
- [Sonoff S22 Smart Socket](https://github.com/arendst/Sonoff-Tasmota/issues/627)
|
||||||
- [iTead Slampher](https://www.itead.cc/slampher.html)
|
- [iTead Slampher](https://www.itead.cc/slampher.html)
|
||||||
- [iTead Sonoff Touch](https://www.itead.cc/sonoff-touch.html)
|
- [iTead Sonoff Touch](https://www.itead.cc/sonoff-touch.html)
|
||||||
- [iTead Sonoff T1](https://www.itead.cc/sonoff-t1.html)
|
- [iTead Sonoff T1](https://www.itead.cc/sonoff-t1.html)
|
||||||
@ -54,8 +55,13 @@ The following devices are supported:
|
|||||||
- [iTead 1 Channel Switch 5V / 12V](https://www.itead.cc/smart-home/inching-self-locking-wifi-wireless-switch.html)
|
- [iTead 1 Channel Switch 5V / 12V](https://www.itead.cc/smart-home/inching-self-locking-wifi-wireless-switch.html)
|
||||||
- [iTead Motor Clockwise/Anticlockwise](https://www.itead.cc/smart-home/motor-reversing-wifi-wireless-switch.html)
|
- [iTead Motor Clockwise/Anticlockwise](https://www.itead.cc/smart-home/motor-reversing-wifi-wireless-switch.html)
|
||||||
- [Electrodragon IoT Relay Board](http://www.electrodragon.com/product/wifi-iot-relay-board-based-esp8266/)
|
- [Electrodragon IoT Relay Board](http://www.electrodragon.com/product/wifi-iot-relay-board-based-esp8266/)
|
||||||
- [AI Light or any my9291 compatible RGBW LED](http://www.ebay.com/itm/172644855726)
|
- AI Light or any my9291 compatible RGBW LED bulb
|
||||||
- MagicHome and AriLux AL-LC01 and AL-LC11
|
- H801 PWM LED controller
|
||||||
|
- [MagicHome PWM LED controller](https://github.com/arendst/Sonoff-Tasmota/wiki/MagicHome-LED-strip-controller)
|
||||||
|
- AriLux AL-LC01, AL-LC06 and AL-LC11 PWM LED controller
|
||||||
|
- [Supla device - Espablo-inCan mod. for electrical Installation box](https://forum.supla.org/viewtopic.php?f=33&t=2188)
|
||||||
|
- [Luani HVIO board](https://luani.de/projekte/esp8266-hvio/)
|
||||||
|
- Wemos D1 mini and NodeMcu
|
||||||
|
|
||||||
### License
|
### License
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ src_dir = sonoff
|
|||||||
;env_default = sonoff-NL
|
;env_default = sonoff-NL
|
||||||
;env_default = sonoff-DE
|
;env_default = sonoff-DE
|
||||||
;env_default = sonoff-PL
|
;env_default = sonoff-PL
|
||||||
|
;env_default = sonoff-IT
|
||||||
|
;env_default = sonoff-emulation
|
||||||
;env_default = sonoff-minimal
|
;env_default = sonoff-minimal
|
||||||
;env_default = sonoff-ds18x20
|
;env_default = sonoff-ds18x20
|
||||||
|
|
||||||
@ -73,8 +75,31 @@ lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
|
|||||||
; *** Serial Monitor options
|
; *** Serial Monitor options
|
||||||
monitor_baud = 115200
|
monitor_baud = 115200
|
||||||
|
|
||||||
|
[env:sonoff-IT]
|
||||||
|
platform = espressif8266
|
||||||
|
framework = arduino
|
||||||
|
board = esp01_1m
|
||||||
|
board_flash_mode = dout
|
||||||
|
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMQTT_MAX_PACKET_SIZE=512 -DMY_LANGUAGE=it-IT
|
||||||
|
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
|
||||||
|
|
||||||
|
; *** Serial Monitor options
|
||||||
|
monitor_baud = 115200
|
||||||
|
|
||||||
|
; Sonoff with Wemo and Hue emulation
|
||||||
|
[env:sonoff-emulation]
|
||||||
|
platform = espressif8266
|
||||||
|
framework = arduino
|
||||||
|
board = esp01_1m
|
||||||
|
board_flash_mode = dout
|
||||||
|
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMQTT_MAX_PACKET_SIZE=512 -DUSE_EMULATION
|
||||||
|
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
|
||||||
|
|
||||||
|
; Serial Monitor options
|
||||||
|
monitor_baud = 115200
|
||||||
|
|
||||||
; Sonoff minimal
|
; Sonoff minimal
|
||||||
[env:sonoff-minimal] ; Placeholder to be configured
|
[env:sonoff-minimal]
|
||||||
platform = espressif8266
|
platform = espressif8266
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = esp01_1m
|
board = esp01_1m
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
/* 5.10.0d
|
/* 5.10.0e
|
||||||
|
* Add Italian language file (#1449)
|
||||||
|
* Fix Wemo Emulation once again closest to issue (#1357)
|
||||||
|
* Add support for sensor SHT3x
|
||||||
|
*
|
||||||
|
* 5.10.0d
|
||||||
* Renamed commands Color2,3,4 to Color3,4,5
|
* Renamed commands Color2,3,4 to Color3,4,5
|
||||||
* Add command Color2 to set color while keeping same dimmer value
|
* Add command Color2 to set color while keeping same dimmer value
|
||||||
* Add led signal to Carbon Dioxide (CO2) sensors (see user_config.h)
|
* Add led signal to Carbon Dioxide (CO2) sensors (see user_config.h)
|
||||||
|
@ -118,6 +118,7 @@
|
|||||||
#define D_INITIALIZED "Inizializzato"
|
#define D_INITIALIZED "Inizializzato"
|
||||||
#define D_IP_ADDRESS "Indirizzo IP"
|
#define D_IP_ADDRESS "Indirizzo IP"
|
||||||
#define D_LIGHT "Light"
|
#define D_LIGHT "Light"
|
||||||
|
#define D_LIMIT "Limit"
|
||||||
#define D_LOCAL_TIME "Local"
|
#define D_LOCAL_TIME "Local"
|
||||||
#define D_LOW "Low"
|
#define D_LOW "Low"
|
||||||
#define D_LWT "LWT"
|
#define D_LWT "LWT"
|
||||||
@ -706,4 +707,4 @@
|
|||||||
#define D_CMND_MAXENERGY "MaxEnergy"
|
#define D_CMND_MAXENERGY "MaxEnergy"
|
||||||
#define D_CMND_MAXENERGYSTART "MaxEnergyStart"
|
#define D_CMND_MAXENERGYSTART "MaxEnergyStart"
|
||||||
|
|
||||||
#endif // _LANGUAGE_EN_GB_H_
|
#endif // _LANGUAGE_IT_IT_H_
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
#define DOMOTICZ_UPDATE_TIMER 0 // [DomoticzUpdateTimer] Send relay status (0 = disable, 1 - 3600 seconds) (Optional)
|
#define DOMOTICZ_UPDATE_TIMER 0 // [DomoticzUpdateTimer] Send relay status (0 = disable, 1 - 3600 seconds) (Optional)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef EMULATION
|
||||||
|
#define EMULATION EMUL_NONE // [Emulation] Select Belkin WeMo (single relay/light) or Hue Bridge emulation (multi relay/light) (EMUL_NONE, EMUL_WEMO or EMUL_HUE)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* RTC memory
|
* RTC memory
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
||||||
====================================================*/
|
====================================================*/
|
||||||
|
|
||||||
#define VERSION 0x050A0004
|
#define VERSION 0x050A0005
|
||||||
#define VERSION_STRING "5.10.0d" // Would be great to have a macro that fills this from VERSION ...
|
#define VERSION_STRING "5.10.0e" // Would be great to have a macro that fills this from VERSION ...
|
||||||
|
|
||||||
// Location specific includes
|
// Location specific includes
|
||||||
#include "sonoff.h" // Enumaration used in user_config.h
|
#include "sonoff.h" // Enumaration used in user_config.h
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
//#define MY_LANGUAGE nl-NL // Dutch in the Netherlands
|
//#define MY_LANGUAGE nl-NL // Dutch in the Netherlands
|
||||||
//#define MY_LANGUAGE de-DE // German in Germany
|
//#define MY_LANGUAGE de-DE // German in Germany
|
||||||
//#define MY_LANGUAGE pl-PL // Polish in Poland
|
//#define MY_LANGUAGE pl-PL // Polish in Poland
|
||||||
|
//#define MY_LANGUAGE it-IT // Italian in Italy
|
||||||
|
|
||||||
// -- Project -------------------------------------
|
// -- Project -------------------------------------
|
||||||
#define PROJECT "sonoff" // PROJECT is used as the default topic delimiter and OTA file name
|
#define PROJECT "sonoff" // PROJECT is used as the default topic delimiter and OTA file name
|
||||||
@ -122,7 +123,7 @@
|
|||||||
#define WEB_USERNAME "admin" // Web server Admin mode user name
|
#define WEB_USERNAME "admin" // Web server Admin mode user name
|
||||||
#define WEB_PASSWORD "" // [WebPassword] Web server Admin mode Password for WEB_USERNAME (empty string = Disable)
|
#define WEB_PASSWORD "" // [WebPassword] Web server Admin mode Password for WEB_USERNAME (empty string = Disable)
|
||||||
#define FRIENDLY_NAME "Sonoff" // [FriendlyName] Friendlyname up to 32 characters used by webpages and Alexa
|
#define FRIENDLY_NAME "Sonoff" // [FriendlyName] Friendlyname up to 32 characters used by webpages and Alexa
|
||||||
#define USE_EMULATION // Enable Belkin WeMo and Hue Bridge emulation for Alexa (+11k code, +2k mem)
|
#define USE_EMULATION // Enable Belkin WeMo and Hue Bridge emulation for Alexa (+16k code, +2k mem)
|
||||||
#define EMULATION EMUL_NONE // [Emulation] Select Belkin WeMo (single relay/light) or Hue Bridge emulation (multi relay/light) (EMUL_NONE, EMUL_WEMO or EMUL_HUE)
|
#define EMULATION EMUL_NONE // [Emulation] Select Belkin WeMo (single relay/light) or Hue Bridge emulation (multi relay/light) (EMUL_NONE, EMUL_WEMO or EMUL_HUE)
|
||||||
|
|
||||||
// -- mDNS ----------------------------------------
|
// -- mDNS ----------------------------------------
|
||||||
@ -172,9 +173,7 @@
|
|||||||
// -- I2C sensors ---------------------------------
|
// -- I2C sensors ---------------------------------
|
||||||
#define USE_I2C // I2C using library wire (+10k code, 0k2 mem, 124 iram)
|
#define USE_I2C // I2C using library wire (+10k code, 0k2 mem, 124 iram)
|
||||||
#define USE_SHT // Add I2C emulating code for SHT1X sensor (+1k4 code)
|
#define USE_SHT // Add I2C emulating code for SHT1X sensor (+1k4 code)
|
||||||
// #define USE_SHT3X // Add I2C code for SHT3x sensor based on Adafruit (+0k7 code)
|
#define USE_SHT3X // Add I2C code for SHT3x sensor (+0k6 code)
|
||||||
// #define USE_SHT3X_V2 // Add I2C code for SHT3x sensor based on EspEasy (+0k7 code)
|
|
||||||
// #define USE_SHT3X_V3 // Add I2C code for SHT3x sensor based on Wemos (+0k7 code)
|
|
||||||
#define USE_HTU // Add I2C code for HTU21/SI7013/SI7020/SI7021 sensor (+1k5 code)
|
#define USE_HTU // Add I2C code for HTU21/SI7013/SI7020/SI7021 sensor (+1k5 code)
|
||||||
#define USE_BMP // Add I2C code for BMP085/BMP180/BMP280/BME280 sensor (+4k code)
|
#define USE_BMP // Add I2C code for BMP085/BMP180/BMP280/BME280 sensor (+4k code)
|
||||||
// #define USE_BME680 // Add additional support for BME680 sensor using Adafruit Sensor and BME680 libraries (+6k code)
|
// #define USE_BME680 // Add additional support for BME680 sensor using Adafruit Sensor and BME680 libraries (+6k code)
|
||||||
|
@ -241,6 +241,38 @@ void PollUdp()
|
|||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
const char WEMO_EVENTSERVICE_XML[] PROGMEM =
|
const char WEMO_EVENTSERVICE_XML[] PROGMEM =
|
||||||
|
/*
|
||||||
|
// Original
|
||||||
|
"<?scpd xmlns=\"urn:Belkin:service-1-0\"?>"
|
||||||
|
"<actionList>"
|
||||||
|
"<action>"
|
||||||
|
"<name>SetBinaryState</name>"
|
||||||
|
"<argumentList>"
|
||||||
|
"<argument>"
|
||||||
|
"<retval/>"
|
||||||
|
"<name>BinaryState</name>"
|
||||||
|
"<relatedStateVariable>BinaryState</relatedStateVariable>"
|
||||||
|
"<direction>in</direction>"
|
||||||
|
"</argument>"
|
||||||
|
"</argumentList>"
|
||||||
|
"<serviceStateTable>"
|
||||||
|
"<stateVariable sendEvents=\"yes\">"
|
||||||
|
"<name>BinaryState</name>"
|
||||||
|
"<dataType>Boolean</dataType>"
|
||||||
|
"<defaultValue>0</defaultValue>"
|
||||||
|
"</stateVariable>"
|
||||||
|
"<stateVariable sendEvents=\"yes\">"
|
||||||
|
"<name>level</name>"
|
||||||
|
"<dataType>string</dataType>"
|
||||||
|
"<defaultValue>0</defaultValue>"
|
||||||
|
"</stateVariable>"
|
||||||
|
"</serviceStateTable>"
|
||||||
|
"</action>"
|
||||||
|
"</scpd>\r\n"
|
||||||
|
"\r\n";
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
// XosePerez version 20171108 - v2.3.0
|
// XosePerez version 20171108 - v2.3.0
|
||||||
"<?xml version=\"1.0\"?>"
|
"<?xml version=\"1.0\"?>"
|
||||||
"<scpd xmlns=\"urn:Belkin:service-1-0\">"
|
"<scpd xmlns=\"urn:Belkin:service-1-0\">"
|
||||||
@ -277,19 +309,63 @@ const char WEMO_EVENTSERVICE_XML[] PROGMEM =
|
|||||||
"</stateVariable>"
|
"</stateVariable>"
|
||||||
"</serviceStateTable>"
|
"</serviceStateTable>"
|
||||||
"</scpd>";
|
"</scpd>";
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Reloxx13 from #1357
|
||||||
|
"<?scpd xmlns=\"urn:Belkin:service-1-0\"?>"
|
||||||
|
"<actionList>"
|
||||||
|
"<action>"
|
||||||
|
"<name>SetBinaryState</name>"
|
||||||
|
"<argumentList>"
|
||||||
|
"<argument>"
|
||||||
|
"<retval/>"
|
||||||
|
"<name>BinaryState</name>"
|
||||||
|
"<relatedStateVariable>BinaryState</relatedStateVariable>"
|
||||||
|
"<direction>in</direction>"
|
||||||
|
"</argument>"
|
||||||
|
"</argumentList>"
|
||||||
|
"<serviceStateTable>"
|
||||||
|
"<stateVariable sendEvents=\"yes\">"
|
||||||
|
"<name>BinaryState</name>"
|
||||||
|
"<dataType>Boolean</dataType>"
|
||||||
|
"<defaultValue>0</defaultValue>"
|
||||||
|
"</stateVariable>"
|
||||||
|
"<stateVariable sendEvents=\"yes\">"
|
||||||
|
"<name>level</name>"
|
||||||
|
"<dataType>string</dataType>"
|
||||||
|
"<defaultValue>0</defaultValue>"
|
||||||
|
"</stateVariable>"
|
||||||
|
"</serviceStateTable>"
|
||||||
|
"</action>"
|
||||||
|
"<action>"
|
||||||
|
"<name>GetBinaryState</name>"
|
||||||
|
"<argumentList>"
|
||||||
|
"<argument>"
|
||||||
|
"<retval/>"
|
||||||
|
"<name>BinaryState</name>"
|
||||||
|
"<relatedStateVariable>BinaryState</relatedStateVariable>"
|
||||||
|
"<direction>out</direction>"
|
||||||
|
"</argument>"
|
||||||
|
"</argumentList>"
|
||||||
|
"</action>"
|
||||||
|
"</actionList>"
|
||||||
|
"</scpd>\r\n"
|
||||||
|
"\r\n";
|
||||||
|
|
||||||
const char WEMO_RESPONSE_STATE_SOAP[] PROGMEM =
|
const char WEMO_RESPONSE_STATE_SOAP[] PROGMEM =
|
||||||
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"
|
// Reloxx13 from #1357
|
||||||
|
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
||||||
"<s:Body>"
|
"<s:Body>"
|
||||||
"<u:SetBinaryState xmlns:u=\"urn:Belkin:service:basicevent:1\">"
|
"<u:SetBinaryStateResponse xmlns:u=\"urn:Belkin:service:basicevent:1\">"
|
||||||
"<BinaryState>{x1</BinaryState>"
|
"<BinaryState>{x1</BinaryState>"
|
||||||
"</u:SetBinaryState>"
|
"</u:SetBinaryStateResponse>"
|
||||||
"</s:Body>"
|
"</s:Body>"
|
||||||
"</s:Envelope>";
|
"</s:Envelope>\r\n"
|
||||||
|
"\r\n";
|
||||||
|
|
||||||
const char WEMO_SETUP_XML[] PROGMEM =
|
const char WEMO_SETUP_XML[] PROGMEM =
|
||||||
"<?xml version=\"1.0\"?>"
|
"<?xml version=\"1.0\"?>"
|
||||||
"<root>"
|
"<root xmlns=\"urn:Belkin:device-1-0\">"
|
||||||
"<device>"
|
"<device>"
|
||||||
"<deviceType>urn:Belkin:device:controllee:1</deviceType>"
|
"<deviceType>urn:Belkin:device:controllee:1</deviceType>"
|
||||||
"<friendlyName>{x1</friendlyName>"
|
"<friendlyName>{x1</friendlyName>"
|
||||||
@ -316,6 +392,7 @@ const char WEMO_SETUP_XML[] PROGMEM =
|
|||||||
void HandleUpnpEvent()
|
void HandleUpnpEvent()
|
||||||
{
|
{
|
||||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_BASIC_EVENT));
|
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_BASIC_EVENT));
|
||||||
|
|
||||||
String request = WebServer->arg(0);
|
String request = WebServer->arg(0);
|
||||||
String state_xml = FPSTR(WEMO_RESPONSE_STATE_SOAP);
|
String state_xml = FPSTR(WEMO_RESPONSE_STATE_SOAP);
|
||||||
//differentiate get and set state
|
//differentiate get and set state
|
||||||
@ -328,7 +405,7 @@ void HandleUpnpEvent()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(request.indexOf(F("GetBinaryState")) > 0){
|
else if(request.indexOf(F("GetBinaryState")) > 0){
|
||||||
state_xml.replace(F("SetBinaryState"), F("GetBinaryStateResponse"));
|
state_xml.replace(F("Set"), F("Get"));
|
||||||
}
|
}
|
||||||
state_xml.replace("{x1", String(bitRead(power, devices_present -1)));
|
state_xml.replace("{x1", String(bitRead(power, devices_present -1)));
|
||||||
WebServer->send(200, FPSTR(HDR_CTYPE_XML), state_xml);
|
WebServer->send(200, FPSTR(HDR_CTYPE_XML), state_xml);
|
||||||
@ -337,6 +414,7 @@ void HandleUpnpEvent()
|
|||||||
void HandleUpnpService()
|
void HandleUpnpService()
|
||||||
{
|
{
|
||||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_EVENT_SERVICE));
|
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, PSTR(D_WEMO_EVENT_SERVICE));
|
||||||
|
|
||||||
WebServer->send(200, FPSTR(HDR_CTYPE_PLAIN), FPSTR(WEMO_EVENTSERVICE_XML));
|
WebServer->send(200, FPSTR(HDR_CTYPE_PLAIN), FPSTR(WEMO_EVENTSERVICE_XML));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* SHT3X - Temperature and Humidy
|
* SHT3X - Temperature and Humidy
|
||||||
*
|
*
|
||||||
* Required library: none but based on Adafruit Industries SHT31 library
|
|
||||||
*
|
|
||||||
* I2C Address: 0x44 or 0x45
|
* I2C Address: 0x44 or 0x45
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
@ -34,14 +32,6 @@ uint8_t sht3x_type = 0;
|
|||||||
uint8_t sht3x_address;
|
uint8_t sht3x_address;
|
||||||
uint8_t sht3x_addresses[] = { SHT3X_ADDR_GND, SHT3X_ADDR_VDD };
|
uint8_t sht3x_addresses[] = { SHT3X_ADDR_GND, SHT3X_ADDR_VDD };
|
||||||
|
|
||||||
bool Sht3xConvert()
|
|
||||||
{
|
|
||||||
if (sht3x_type) {
|
|
||||||
return I2cWrite8(sht3x_address, 0x2C, 0x06);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Sht3xRead(float &t, float &h)
|
bool Sht3xRead(float &t, float &h)
|
||||||
{
|
{
|
||||||
unsigned int data[6];
|
unsigned int data[6];
|
||||||
@ -49,22 +39,20 @@ bool Sht3xRead(float &t, float &h)
|
|||||||
t = NAN;
|
t = NAN;
|
||||||
h = NAN;
|
h = NAN;
|
||||||
|
|
||||||
Wire.requestFrom(sht3x_address, (uint8_t)6);
|
Wire.beginTransmission(sht3x_address);
|
||||||
if (Wire.available() != 6) {
|
Wire.write(0x2C); // Enable clock stretching
|
||||||
|
Wire.write(0x06); // High repeatability
|
||||||
|
if (Wire.endTransmission() != 0) { // Stop I2C transmission
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Read 6 bytes of data
|
delay(30); // Timing verified with logic analyzer (10 is to short)
|
||||||
// cTemp msb, cTemp lsb, cTemp crc, humidity msb, humidity lsb, humidity crc
|
Wire.requestFrom(sht3x_address, (uint8_t)6); // Request 6 bytes of data
|
||||||
for (uint8_t i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
data[i] = Wire.read();
|
data[i] = Wire.read(); // cTemp msb, cTemp lsb, cTemp crc, humidity msb, humidity lsb, humidity crc
|
||||||
}
|
};
|
||||||
// delay(50);
|
|
||||||
// if (Wire.available() != 0) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
t = ConvertTemp((float)((((data[0] << 8) | data[1]) * 175) / 65535.0) - 45);
|
t = ConvertTemp((float)((((data[0] << 8) | data[1]) * 175) / 65535.0) - 45);
|
||||||
h = (float)((((data[3] << 8) | data[4]) * 100) / 65535.0);
|
h = (float)((((data[3] << 8) | data[4]) * 100) / 65535.0);
|
||||||
return true;
|
return (!isnan(t) && !isnan(h));
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
@ -75,10 +63,12 @@ void Sht3xDetect()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float t;
|
||||||
|
float h;
|
||||||
sht3x_type = 1;
|
sht3x_type = 1;
|
||||||
for (byte i = 0; i < sizeof(sht3x_addresses); i++) {
|
for (byte i = 0; i < sizeof(sht3x_addresses); i++) {
|
||||||
sht3x_address = sht3x_addresses[i];
|
sht3x_address = sht3x_addresses[i];
|
||||||
if (Sht3xConvert()) {
|
if (Sht3xRead(t, h)) {
|
||||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "SHT3X", sht3x_address);
|
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "SHT3X", sht3x_address);
|
||||||
AddLog(LOG_LEVEL_DEBUG);
|
AddLog(LOG_LEVEL_DEBUG);
|
||||||
return;
|
return;
|
||||||
@ -128,16 +118,12 @@ boolean Xsns14(byte function)
|
|||||||
case FUNC_INIT:
|
case FUNC_INIT:
|
||||||
Sht3xDetect();
|
Sht3xDetect();
|
||||||
break;
|
break;
|
||||||
case FUNC_PREP_BEFORE_TELEPERIOD:
|
|
||||||
Sht3xConvert();
|
|
||||||
break;
|
|
||||||
case FUNC_JSON_APPEND:
|
case FUNC_JSON_APPEND:
|
||||||
Sht3xShow(1);
|
Sht3xShow(1);
|
||||||
break;
|
break;
|
||||||
#ifdef USE_WEBSERVER
|
#ifdef USE_WEBSERVER
|
||||||
case FUNC_WEB_APPEND:
|
case FUNC_WEB_APPEND:
|
||||||
Sht3xShow(0);
|
Sht3xShow(0);
|
||||||
Sht3xConvert();
|
|
||||||
break;
|
break;
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
}
|
}
|
||||||
|
@ -1,142 +0,0 @@
|
|||||||
/*
|
|
||||||
xsns_14_sht3x.ino - SHT3X temperature and humidity sensor support for Sonoff-Tasmota
|
|
||||||
|
|
||||||
Copyright (C) 2018 Theo Arends
|
|
||||||
|
|
||||||
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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef USE_I2C
|
|
||||||
#ifdef USE_SHT3X_V2
|
|
||||||
/*********************************************************************************************\
|
|
||||||
* SHT3X - Temperature and Humidy
|
|
||||||
*
|
|
||||||
* Required library: none but based on EspEasy plugin 68
|
|
||||||
*
|
|
||||||
* I2C Address: 0x44 or 0x45
|
|
||||||
\*********************************************************************************************/
|
|
||||||
|
|
||||||
#define SHT3X_ADDR_GND 0x44 // address pin low (GND)
|
|
||||||
#define SHT3X_ADDR_VDD 0x45 // address pin high (VDD)
|
|
||||||
|
|
||||||
uint8_t sht3x_type = 0;
|
|
||||||
uint8_t sht3x_address;
|
|
||||||
uint8_t sht3x_addresses[] = { SHT3X_ADDR_GND, SHT3X_ADDR_VDD };
|
|
||||||
|
|
||||||
bool Sht3xInit()
|
|
||||||
{
|
|
||||||
if (sht3x_type) {
|
|
||||||
return I2cWrite8(sht3x_address, 0x20, 0x32); // Periodic 0.5mps and repeatability high
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Sht3xRead(float &t, float &h)
|
|
||||||
{
|
|
||||||
unsigned int data[6];
|
|
||||||
|
|
||||||
t = NAN;
|
|
||||||
h = NAN;
|
|
||||||
|
|
||||||
I2cWrite8(sht3x_address, 0xE0, 0x00); // Fetch data
|
|
||||||
Wire.requestFrom(sht3x_address, (uint8_t)6);
|
|
||||||
if (Wire.available() != 6) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Read 6 bytes of data
|
|
||||||
// cTemp msb, cTemp lsb, cTemp crc, humidity msb, humidity lsb, humidity crc
|
|
||||||
for (uint8_t i = 0; i < 6; i++) {
|
|
||||||
data[i] = Wire.read();
|
|
||||||
}
|
|
||||||
t = ConvertTemp((float)((((data[0] << 8) | data[1]) * 175) / 65535.0) - 45);
|
|
||||||
h = (float)((((data[3] << 8) | data[4]) * 100) / 65535.0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/********************************************************************************************/
|
|
||||||
|
|
||||||
void Sht3xDetect()
|
|
||||||
{
|
|
||||||
if (sht3x_type) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sht3x_type = 1;
|
|
||||||
for (byte i = 0; i < sizeof(sht3x_addresses); i++) {
|
|
||||||
sht3x_address = sht3x_addresses[i];
|
|
||||||
if (Sht3xInit()) {
|
|
||||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "SHT3X", sht3x_address);
|
|
||||||
AddLog(LOG_LEVEL_DEBUG);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sht3x_type = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sht3xShow(boolean json)
|
|
||||||
{
|
|
||||||
if (sht3x_type) {
|
|
||||||
float t;
|
|
||||||
float h;
|
|
||||||
if (Sht3xRead(t, h)) {
|
|
||||||
char temperature[10];
|
|
||||||
char humidity[10];
|
|
||||||
dtostrfd(t, Settings.flag2.temperature_resolution, temperature);
|
|
||||||
dtostrfd(h, Settings.flag2.humidity_resolution, humidity);
|
|
||||||
|
|
||||||
if (json) {
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), JSON_SNS_TEMPHUM, mqtt_data, "SHT3X", temperature, humidity);
|
|
||||||
#ifdef USE_DOMOTICZ
|
|
||||||
DomoticzTempHumSensor(temperature, humidity);
|
|
||||||
#endif // USE_DOMOTICZ
|
|
||||||
#ifdef USE_WEBSERVER
|
|
||||||
} else {
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, "SHT3X", temperature, TempUnit());
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_HUM, mqtt_data, "SHT3X", humidity);
|
|
||||||
#endif // USE_WEBSERVER
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************************************************************************\
|
|
||||||
* Interface
|
|
||||||
\*********************************************************************************************/
|
|
||||||
|
|
||||||
#define XSNS_14
|
|
||||||
|
|
||||||
boolean Xsns14(byte function)
|
|
||||||
{
|
|
||||||
boolean result = false;
|
|
||||||
|
|
||||||
if (i2c_flg) {
|
|
||||||
switch (function) {
|
|
||||||
case FUNC_INIT:
|
|
||||||
Sht3xDetect();
|
|
||||||
break;
|
|
||||||
case FUNC_JSON_APPEND:
|
|
||||||
Sht3xShow(1);
|
|
||||||
break;
|
|
||||||
#ifdef USE_WEBSERVER
|
|
||||||
case FUNC_WEB_APPEND:
|
|
||||||
Sht3xShow(0);
|
|
||||||
break;
|
|
||||||
#endif // USE_WEBSERVER
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // USE_SHT3X_V2
|
|
||||||
#endif // USE_I2C
|
|
@ -1,156 +0,0 @@
|
|||||||
/*
|
|
||||||
xsns_14_sht3x.ino - SHT3X temperature and humidity sensor support for Sonoff-Tasmota
|
|
||||||
|
|
||||||
Copyright (C) 2018 Theo Arends
|
|
||||||
|
|
||||||
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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef USE_I2C
|
|
||||||
#ifdef USE_SHT3X_V3
|
|
||||||
/*********************************************************************************************\
|
|
||||||
* SHT3X - Temperature and Humidy
|
|
||||||
*
|
|
||||||
* Required library: none but based on Wemos library
|
|
||||||
*
|
|
||||||
* I2C Address: 0x44 or 0x45
|
|
||||||
\*********************************************************************************************/
|
|
||||||
|
|
||||||
#define SHT3X_ADDR_GND 0x44 // address pin low (GND)
|
|
||||||
#define SHT3X_ADDR_VDD 0x45 // address pin high (VDD)
|
|
||||||
|
|
||||||
uint8_t sht3x_type = 0;
|
|
||||||
uint8_t sht3x_address;
|
|
||||||
uint8_t sht3x_addresses[] = { SHT3X_ADDR_GND, SHT3X_ADDR_VDD };
|
|
||||||
|
|
||||||
bool Sht3xConvert()
|
|
||||||
{
|
|
||||||
if (sht3x_type) {
|
|
||||||
// Start I2C Transmission
|
|
||||||
Wire.beginTransmission(sht3x_address);
|
|
||||||
// Send measurement command
|
|
||||||
Wire.write(0x2C);
|
|
||||||
Wire.write(0x06);
|
|
||||||
// Stop I2C transmission
|
|
||||||
if (Wire.endTransmission() != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Sht3xRead(float &t, float &h)
|
|
||||||
{
|
|
||||||
unsigned int data[6];
|
|
||||||
|
|
||||||
t = NAN;
|
|
||||||
h = NAN;
|
|
||||||
|
|
||||||
// Request 6 bytes of data
|
|
||||||
Wire.requestFrom(sht3x_address, (uint8_t)6);
|
|
||||||
// Read 6 bytes of data
|
|
||||||
// cTemp msb, cTemp lsb, cTemp crc, humidity msb, humidity lsb, humidity crc
|
|
||||||
for (int i = 0; i < 6; i++) {
|
|
||||||
data[i] = Wire.read();
|
|
||||||
};
|
|
||||||
delay(50);
|
|
||||||
if (Wire.available() != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Convert the data
|
|
||||||
t = ConvertTemp((float)((((data[0] << 8) | data[1]) * 175) / 65535.0) - 45);
|
|
||||||
h = (float)((((data[3] << 8) | data[4]) * 100) / 65535.0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/********************************************************************************************/
|
|
||||||
|
|
||||||
void Sht3xDetect()
|
|
||||||
{
|
|
||||||
if (sht3x_type) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sht3x_type = 1;
|
|
||||||
for (byte i = 0; i < sizeof(sht3x_addresses); i++) {
|
|
||||||
sht3x_address = sht3x_addresses[i];
|
|
||||||
if (Sht3xConvert()) {
|
|
||||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "SHT3X", sht3x_address);
|
|
||||||
AddLog(LOG_LEVEL_DEBUG);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sht3x_type = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sht3xShow(boolean json)
|
|
||||||
{
|
|
||||||
if (sht3x_type) {
|
|
||||||
float t;
|
|
||||||
float h;
|
|
||||||
if (Sht3xRead(t, h)) {
|
|
||||||
char temperature[10];
|
|
||||||
char humidity[10];
|
|
||||||
dtostrfd(t, Settings.flag2.temperature_resolution, temperature);
|
|
||||||
dtostrfd(h, Settings.flag2.humidity_resolution, humidity);
|
|
||||||
|
|
||||||
if (json) {
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), JSON_SNS_TEMPHUM, mqtt_data, "SHT3X", temperature, humidity);
|
|
||||||
#ifdef USE_DOMOTICZ
|
|
||||||
DomoticzTempHumSensor(temperature, humidity);
|
|
||||||
#endif // USE_DOMOTICZ
|
|
||||||
#ifdef USE_WEBSERVER
|
|
||||||
} else {
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, "SHT3X", temperature, TempUnit());
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_HUM, mqtt_data, "SHT3X", humidity);
|
|
||||||
#endif // USE_WEBSERVER
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************************************************************************\
|
|
||||||
* Interface
|
|
||||||
\*********************************************************************************************/
|
|
||||||
|
|
||||||
#define XSNS_14
|
|
||||||
|
|
||||||
boolean Xsns14(byte function)
|
|
||||||
{
|
|
||||||
boolean result = false;
|
|
||||||
|
|
||||||
if (i2c_flg) {
|
|
||||||
switch (function) {
|
|
||||||
case FUNC_INIT:
|
|
||||||
Sht3xDetect();
|
|
||||||
break;
|
|
||||||
case FUNC_PREP_BEFORE_TELEPERIOD:
|
|
||||||
Sht3xConvert();
|
|
||||||
break;
|
|
||||||
case FUNC_JSON_APPEND:
|
|
||||||
Sht3xShow(1);
|
|
||||||
break;
|
|
||||||
#ifdef USE_WEBSERVER
|
|
||||||
case FUNC_WEB_APPEND:
|
|
||||||
Sht3xShow(0);
|
|
||||||
Sht3xConvert();
|
|
||||||
break;
|
|
||||||
#endif // USE_WEBSERVER
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // USE_SHT3X_V3
|
|
||||||
#endif // USE_I2C
|
|
Loading…
x
Reference in New Issue
Block a user