Add support for Sonoff Pow R2 (#2340)

5.12.0m
* Add support for Sonoff Pow R2 (#2340)
This commit is contained in:
Theo Arends 2018-04-20 16:55:27 +02:00
parent 7dbd94b978
commit a8b83aa036
5 changed files with 24 additions and 8 deletions

View File

@ -45,6 +45,7 @@ The following devices are supported:
- [iTead Sonoff TH10/TH16 with temperature sensor](https://www.itead.cc/smart-home/sonoff-th.html)
- [iTead Sonoff Dual (R2)](https://www.itead.cc/smart-home/sonoff-dual.html)
- [iTead Sonoff Pow](https://www.itead.cc/smart-home/sonoff-pow.html)
- [iTead Sonoff Pow R2](https://www.itead.cc/sonoff-pow-r2.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 S20 Smart Socket](https://www.itead.cc/smart-socket.html)

View File

@ -3,7 +3,9 @@
* Add random window to timers (#2447)
* Add optional KNX IP Protocol Support (#2402)
* Add Greek language file (#2491)
* Add Bulgarian language file
* Add support for sensor HC-SR04 ultrasonic (#113, #1964, #2444)
* Add support for Sonoff Pow R2 (#2340)
* Fix compile error when using ESP/Arduino library v2.3.0 by reverting KNX async UDP library to default UDP library (#2488, #2492, #2493)
* Fix configuration filename truncation when it contains spaces (#2484, #2490)
*

View File

@ -2041,9 +2041,9 @@ void SerialInput()
}
/*-------------------------------------------------------------------------------------------*\
* Sonoff S31 4800 baud serial interface
* Sonoff S31 and Sonoff Pow R2 4800 baud serial interface
\*-------------------------------------------------------------------------------------------*/
if (SONOFF_S31 == Settings.module) {
if ((SONOFF_S31 == Settings.module) || (SONOFF_POW_R2 == Settings.module)) {
if (CseSerialInput()) {
serial_in_byte_counter = 0;
Serial.flush();

View File

@ -184,6 +184,7 @@ enum SupportedModules {
ARILUX_LC06,
SONOFF_S31,
ZENGGE_ZF_WF017,
SONOFF_POW_R2,
MAXMODULE };
/********************************************************************************************/
@ -208,6 +209,7 @@ const uint8_t kNiceList[MAXMODULE] PROGMEM = {
SONOFF_DUAL,
SONOFF_DUAL_R2,
SONOFF_POW,
SONOFF_POW_R2,
SONOFF_S31,
SONOFF_4CH,
SONOFF_4CHPRO,
@ -321,7 +323,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
GPIO_USER, // GPIO14 Optional sensor
0, 0, 0
},
{ "Sonoff Pow", // Sonoff Pow (ESP8266)
{ "Sonoff Pow", // Sonoff Pow (ESP8266 - HLW8012)
GPIO_KEY1, // GPIO00 Button
0, 0, 0, 0,
GPIO_HLW_SEL, // GPIO05 HLW8012 Sel output
@ -329,7 +331,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
GPIO_REL1, // GPIO12 Red Led and Relay (0 = Off, 1 = On)
GPIO_HLW_CF1, // GPIO13 HLW8012 CF1 voltage / current
GPIO_HLW_CF, // GPIO14 HLW8012 CF power
GPIO_LED1, // GPIO15 Green Led (0 = On, 1 = Off)
GPIO_LED1, // GPIO15 Blue Led (0 = On, 1 = Off)
0, 0
},
{ "Sonoff 4CH", // Sonoff 4CH (ESP8285)
@ -784,7 +786,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
GPIO_USER, // GPIO15 RGBW LED White
0, 0
},
{ "Sonoff S31", // Sonoff S31 (ESP8266)
{ "Sonoff S31", // Sonoff S31 (ESP8266 - CSE7766)
GPIO_KEY1, // GPIO00 Button
0, // GPIO01 Serial RXD 4800 baud 8E1 CSE7766 energy sensor
0,
@ -807,6 +809,17 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
GPIO_PWM1, // GPIO13 RGB LED Red
GPIO_PWM3, // GPIO14 RGB LED Blue
0, 0, 0
},
{ "Sonoff Pow R2", // Sonoff Pow R2 (ESP8285 - CSE7766)
GPIO_KEY1, // GPIO00 Button
0, // GPIO01 Serial RXD 4800 baud 8E1 CSE7766 energy sensor
0,
0, // GPIO03 Serial TXD
0, 0,
0, 0, 0, 0, 0, 0, // Flash connection
GPIO_REL1, // GPIO12 Red Led and Relay (0 = Off, 1 = On)
GPIO_LED1_INV, // GPIO13 Blue Led (0 = On, 1 = Off)
0, 0, 0, 0
}
};

View File

@ -252,7 +252,7 @@ void HlwInit()
}
/*********************************************************************************************\
* CSE7766 - Energy (Sonoff S31)
* CSE7766 - Energy (Sonoff S31 and Sonoff Pow R2)
*
* Based on datasheet from http://www.chipsea.com/UploadFiles/2017/08/11144342F01B5662.pdf
\*********************************************************************************************/
@ -1015,9 +1015,9 @@ boolean EnergyCommand()
void EnergyDrvInit()
{
energy_flg = ENERGY_NONE;
if ((pin[GPIO_HLW_SEL] < 99) && (pin[GPIO_HLW_CF1] < 99) && (pin[GPIO_HLW_CF] < 99)) { // Sonoff Pow
if ((pin[GPIO_HLW_SEL] < 99) && (pin[GPIO_HLW_CF1] < 99) && (pin[GPIO_HLW_CF] < 99)) { // Sonoff Pow or any HLW8012 based device
energy_flg = ENERGY_HLW8012;
} else if (SONOFF_S31 == Settings.module) { // Sonoff S31
} else if ((SONOFF_S31 == Settings.module) || (SONOFF_POW_R2 == Settings.module)) { // Sonoff S31 or Sonoff Pow R2
baudrate = 4800;
serial_config = SERIAL_8E1;
energy_flg = ENERGY_CSE7766;