Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ZAP outlet switch in Sonoff RF Bridge #1095

Closed
dimitrystd opened this issue Oct 29, 2017 · 13 comments
Closed

Support ZAP outlet switch in Sonoff RF Bridge #1095

dimitrystd opened this issue Oct 29, 2017 · 13 comments

Comments

@dimitrystd
Copy link

Bought on amazon cheap RF outlet switch. They have name ZAP.
ZAP

Unfortunately RF Bridge returns different codes for the same button. This is what i see in console if press the same button

12:30:47 MQT: tele/rf_bridge/RESULT = {"RfReceived":{"Sync":5670, "Low":180, "High":540, "Data":"107500", "RfKey":"None"}}
12:30:49 MQT: tele/rf_bridge/RESULT = {"RfReceived":{"Sync":5750, "Low":0, "High":0, "Data":"10750C", "RfKey":"None"}}
12:30:52 MQT: tele/rf_bridge/RESULT = {"RfReceived":{"Sync":5670, "Low":180, "High":540, "Data":"107500", "RfKey":"None"}}
12:30:53 MQT: tele/rf_bridge/RESULT = {"RfReceived":{"Sync":5670, "Low":180, "High":540, "Data":"105500", "RfKey":"None"}}
12:30:54 MQT: tele/rf_bridge/RESULT = {"RfReceived":{"Sync":5750, "Low":150, "High":570, "Data":"10750C", "RfKey":"None"}}
12:30:55 MQT: tele/rf_bridge/RESULT = {"RfReceived":{"Sync":5710, "Low":180, "High":540, "Data":"107500", "RfKey":"None"}}

Remote control has chip HS2260A-R4. I found another ESP8266 project and as far as i understood from description this chip is similar to PT2260 and has fixed code.

How can i help with debug? Sorry, don't understand what and where to change in code.

P.S. In general RF bridge works, i use it for doorbell and rf pir sensor.

@benzino77
Copy link

I have very similar problem. Two remote controllers. One based on Hx2262 chip, and the other based on PT2264. RF Bridge is able to send codes (which I get from remotes using arduino, 433 receiver and RCSwitch library) to my outlet switches without any problem - rf bridge can on and off them:

cmnd/RFCode 4539729 #ON
cmnd/RFCode 4539732 #OFF

The problem is that RF Bridge reports almost always the same codes for different buttons on remote. For example:
RCSwitch/Arduino returns information (for PT2264):

**Button 1**
Decimal: 13980931 (24Bit) Binary: 110101010101010100000011 Tri-State: 1FFFFFFF0001 PulseLength: 505 microseconds Protocol: 1
Raw data: 15668,1564,516,1564,512,184,1528,1560,516,516,1524,1560,516,516,1524,1564,512,516,1524,1564,516,512,1528,1564,512,516,1528,1560,516,512,1528,1564,516,516,1524,516,1528,512,1528,516,1524,516,1524,516,1528,1560,512,1564,516,

**Button 2**
Decimal: 13980940 (24Bit) Binary: 110101010101010100001100 Tri-State: 1FFFFFFF0010 PulseLength: 505 microseconds Protocol: 1
Raw data: 15672,1560,520,1564,516,508,1528,1560,516,516,1524,1564,512,516,1528,1564,512,512,1532,1560,516,512,1528,1560,516,516,1528,1560,520,512,1528,1560,520,508,1532,512,1528,516,1528,512,1528,1564,512,1560,520,516,1528,512,1528,

but
RF Bridge with Tasmota on it returns always:

Nov 21 21:49:53 10.10.30.18 sonoff-rfb01-5278 ESP-MQT: tele/sonoff-rfb01/RESULT = {"RfReceived":{"Sync":15660,"Low":510,"High":1540,"Data":"D55557","RfKey":"None"}}
Nov 21 21:49:56 10.10.30.18 sonoff-rfb01-5278 ESP-MQT: tele/sonoff-rfb01/RESULT = {"RfReceived":{"Sync":15660,"Low":510,"High":1540,"Data":"D55557","RfKey":"None"}}

RCSwitch/Arduino returns information (for HX2262):

**Button 1**
Decimal: 4539729 (24Bit) Binary: 010001010100010101010001 Tri-State: F0FFF0FFFF0F PulseLength: 329 microseconds Protocol: 1
Raw data: 10223,302,1014,962,358,302,1014,303,1016,302,1014,962,360,300,1019,959,358,302,1016,961,365,295,1019,959,362,298,1017,960,363,297,1019,959,361,299,1019,959,363,297,10
19,959,361,959,362,958,366,955,364,957,363,

**Button 2**
Decimal: 4539732 (24Bit) Binary: 010001010100010101010100 Tri-State: F0FFF0FFFFF0 PulseLength: 329 microseconds Protocol: 1
Raw data: 10237,290,1027,949,367,292,1026,292,1028,289,1027,950,369,290,1030,948,371,289,1032,946,370,289,1031,287,1030,288,1030,946,372,288,1035,943,383,276,1036,942,374,286,1
036,942,374,286,1040,937,373,287,1046,272,1037,

but
RF Bridge returns always:

Nov 21 20:23:40 10.10.30.18 sonoff-rfb01-5278 ESP-MQT: tele/sonoff-rfb01/RESULT = {"RfReceived":{"Sync":10260,"Low":340,"High":1000,"Data":"455551","RfKey":"None"}}
Nov 21 20:23:43 10.10.30.18 sonoff-rfb01-5278 ESP-MQT: tele/sonoff-rfb01/RESULT = {"RfReceived":{"Sync":10250,"Low":340,"High":1000,"Data":"455551","RfKey":"None"}}

I'm aware of that Tasmota reports data in HEX and RCSwitch in DEC

@arendst
Copy link
Owner

arendst commented Nov 22, 2017

Sorry guys but tasmota does NOT decode the RF signals as RCSwitch does. The Sonoff bridge contains a seperate microcontroller receiving and transmitting codes to and from Tasmota. I have no influence on the reception of the RF signal.

You'll have to contact iTead if you think the RF microntroller does a bad job in decoding signals.

@benzino77
Copy link

Thanks for quick response!
I do understand that Sonoff bridge have separate microcontroller for RF communication, but you perform a lot of magic in bridge code:

sync_time = serial_in_buffer[1] << 8 | serial_in_buffer[2];  // Sync time in uSec
low_time = serial_in_buffer[3] << 8 | serial_in_buffer[4];  // Low time in uSec
high_time = serial_in_buffer[5] << 8 | serial_in_buffer[6];  // High time in uSec
received_id = serial_in_buffer[7] << 16 | serial_in_buffer[8] << 8 | serial_in_buffer[9];

and I wonder maybe this is a problem?

@arendst
Copy link
Owner

arendst commented Nov 22, 2017

Try to find out what it does...

I can assure you that the data itself is not changed :-)

@benzino77
Copy link

I can see that the data itself is not changed :)
Found this on itead forum:
https://itead.freshdesk.com/support/discussions/topics/11000015088

Support Team claims that:

The receiving supports fixed code 433 frequency, like PT2260, PT2262, PT2264, EV1527, etc.

@benzino77
Copy link

I have performed more tests yesterday. An this is observation:

  • Changing SFB_TIME_AVOID_DUPLICATE to lower value (200,100,50,5 ms) changing returned data.
  • (changed SFB_TIME_AVOID_DUPLICATE back to 2000) pressing button "B" and than button "A" causes that returned data is (not always) ... correct!

@benzino77
Copy link

I think #1124 is related.

@benzino77
Copy link

I'm wondering about this piece of code:

 if (SonoffBridgeSerialInput()) {
      serial_in_byte_counter = 0;
      Serial.flush();
      return;
    }

/*-------------------------------------------------------------------------------------------*/

    if (serial_in_byte > 127) {                // binary data...
      serial_in_byte_counter = 0;
      Serial.flush();
      return;
    }
    if (isprint(serial_in_byte)) {
      if (serial_in_byte_counter < INPUT_BUFFER_SIZE) {  // add char to string if it still fits
        serial_in_buffer[serial_in_byte_counter++] = serial_in_byte;
      } else {
        serial_in_byte_counter = 0;
      }
    }

Function SonoffBridgeSerialInput returns 0 because it is not 0x55 value. Before it returns 0 it is performing: serial_in_buffer[serial_in_byte_counter++] = serial_in_byte
Then if the character is printable and we are not outside the buffer size there is once again serial_in_buffer[serial_in_byte_counter++] = serial_in_byte;
Is this possible that buffer is filled twice with the same character?

@benzino77
Copy link

I've found another remote controller based on HS1527 chip ... and this one is working great. Each button generate different Data information on device console/mqtt/syslog.

What is interesting: https://github.com/sui77/rc-switch/wiki/KnowHow_LineCoding

I do believe that for some devices Tasmota or Software on RF Chip does wrong data processing.

arendst added a commit that referenced this issue Dec 3, 2017
* Fix Sonoff Bridge missed learned key if learned data contains 0x55
(End of Transmission) flag (#1095, #1294)
@benzino77
Copy link

Theo, you are a Rock Star!

arendst added a commit that referenced this issue Dec 6, 2017
5.10.0a
 * Add (experimental) support for sensor SHT3x
 * Add support
for sensor MH-Z19(B) using serial interface to be enabled with define
USE_MHZ19 in user_config.h (#561, #1248)
 * Add (experimental) support
for sensor MH-Z19(B) using SoftwareSerial to be enabled with define
USE_MHZ19 in user_config.h (#561, #1248)
 * Add support for iTead SI7021
temperature and humidity sensor by consolidating DHT22 into AM2301 and
using former DHT22 as SI7021 (#735)
 * Fix BME280 calculation (#1051)
 *
Add support for BME680 using adafruit libraries (#1212)
 * Change
ADS1115 default voltage range from +/-2V to +/-6V (#1289)
 * Add
multipress support and more user configurable options to Sonoff Dual R2
(#1291)
 * Fix Sonoff Bridge missed learned key if learned data contains
0x55 (End of Transmission) flag (#1095, #1294)
 * Add support for
TSL2561 using adafruit library (#661, #1311)
 * Add alternative support
for SHT3x (#1314)
arendst added a commit that referenced this issue Dec 8, 2017
5.10.0a
 * Add (experimental) support for sensor SHT3x
 * Add support
for sensor MH-Z19(B) using serial interface to be enabled with define
USE_MHZ19_HARD_SERIAL in user_config.h (#561, #1248)
 * Add
(experimental) support for sensor MH-Z19(B) using SoftwareSerial to be
enabled with define USE_MHZ19_SOFT_SERIAL_OBSOLETE in user_config.h
(#561, #1248)
 * Add (experimental) support for sensor MH-Z19(B) using
stripped SoftwareSerial to be enabled with define USE_MHZ19_SOFT_SERIAL
in user_config.h (#561, #1248)
 * Add support for iTead SI7021
temperature and humidity sensor by consolidating DHT22 into AM2301 and
using former DHT22 as SI7021 (#735)
 * Fix BME280 calculation (#1051)
 *
Add support for BME680 using adafruit libraries (#1212)
 * Change
ADS1115 default voltage range from +/-2V to +/-6V (#1289)
 * Add
multipress support and more user configurable options to Sonoff Dual R2
(#1291)
 * Fix Sonoff Bridge missed learned key if learned data contains
0x55 (End of Transmission) flag (#1095, #1294)
 * Add support for
TSL2561 using adafruit library (#661, #1311)
 * Add alternative support
for SHT3x (#1314)
@dimitrystd
Copy link
Author

Thanks @arendst . Just tested 5.10.0a and it works fine. For some reason i still see different codes in console, but i can learn codes now and they work if i send them.

P.S. This is what i see in console when press the same button

18:30:23 MQT: tele/rf_bridge/RESULT = {"RfReceived":{"Sync":5670,"Low":160,"High":560,"Data":"105500","RfKey":"None"}}
18:30:24 MQT: tele/rf_bridge/RESULT = {"RfReceived":{"Sync":5670,"Low":190,"High":530,"Data":"107500","RfKey":"None"}}
18:30:26 MQT: tele/rf_bridge/RESULT = {"RfReceived":{"Sync":5690,"Low":170,"High":550,"Data":"10750C","RfKey":"None"}}
18:30:27 MQT: tele/rf_bridge/RESULT = {"RfReceived":{"Sync":5670,"Low":160,"High":560,"Data":"107500","RfKey":"None"}}
18:30:28 MQT: tele/rf_bridge/RESULT = {"RfReceived":{"Sync":5710,"Low":190,"High":530,"Data":"105500","RfKey":"None"}}
18:30:29 MQT: tele/rf_bridge/RESULT = {"RfReceived":{"Sync":2090,"Low":180,"High":540,"Data":"10750C","RfKey":"None"}}
18:30:30 MQT: tele/rf_bridge/RESULT = {"RfReceived":{"Sync":5690,"Low":180,"High":540,"Data":"105500","RfKey":"None"}}

arendst added a commit that referenced this issue Jan 7, 2018
5.11.0 20180107
 * Minor webpage HTML optimizations (#1358)
 * Updated
German translation (#1438)
 * Change Sonoff Pow Energy MQTT data message
and consolidate Status 8 into Status 10
 * Change ADS1115 default
voltage range from +/-2V to +/-6V (#1289)
 * Change text to Active for 3
minutes (#1364)
 * Change Wemo SetBinaryState to distinguish from
GetBinaryState (#1357)
 * Change output of HTTP command to valid JSON
and Array only (#1363)
 * Removed all MQTT, JSON and Command language
defines from locale files and set fixed to English (#1473)
 * Renamed
commands Color2,3,4 to Color3,4,5
 * Fix BME280 calculation (#1051)
 *
Fix Sonoff Bridge missed learned key if learned data contains 0x55 (End
of Transmission) flag (#1095, #1294)
 * Fix PWM initialization in
Dimmer/Color mode (#1321)
 * Fix Wemo Emulation (#1357)
 * Fix display
of build date and time in non-english locale (#1465)
 * Fix Wemo and Hue
emulation by adding M-Search response delay (#1486)
 * Add libraries
Adafruit_BME680-1.0.5, Adafruit_Sensor-1.0.2.02, TasmotaSerial-1.0.0 and
TSL2561-Arduino-Library
 * Add command Color2 to set color while keeping
same dimmer value
 * Add device function pointers
 * Add support for
SenseAir S8 CO2 sensor
 * Add color led signal to Carbon Dioxide (CO2)
sensors using defines CO2_LOW and CO2_HIGH in user_config.h
 * Add
support for Domoticz Air Quality sensor to be used by MH-Z19(B) and
SenseAir sensors
 * Add support for PZEM004T energy sensor
 * Add
support for iTead SI7021 temperature and humidity sensor by
consolidating DHT22 into AM2301 and using former DHT22 as SI7021 (#735)

* Add support for BME680 using adafruit libraries (#1212)
 * Add support
for MH-Z19(B) CO2 sensor (#561, #1248)
 * Add multipress support and
more user configurable GPIO to Sonoff Dual R2 (#1291)
 * Add support for
TSL2561 using adafruit library (#661, #1311)
 * Add support for SHT3x
(#1314)
 * Add support for Arilux LC06 (#1414)
 * Add Italian language
file (#1449)
 * Add 2nd Gen Alexa support to Wemo emulation discovery
(#1357, #1450)
 * Add define for additional number of WS2812 schemes
(#1463)
joecotton pushed a commit to joecotton/Sonoff-Tasmota that referenced this issue Jan 8, 2018
5.11.0 20180107
 * Minor webpage HTML optimizations (arendst#1358)
 * Updated
German translation (arendst#1438)
 * Change Sonoff Pow Energy MQTT data message
and consolidate Status 8 into Status 10
 * Change ADS1115 default
voltage range from +/-2V to +/-6V (arendst#1289)
 * Change text to Active for 3
minutes (arendst#1364)
 * Change Wemo SetBinaryState to distinguish from
GetBinaryState (arendst#1357)
 * Change output of HTTP command to valid JSON
and Array only (arendst#1363)
 * Removed all MQTT, JSON and Command language
defines from locale files and set fixed to English (arendst#1473)
 * Renamed
commands Color2,3,4 to Color3,4,5
 * Fix BME280 calculation (arendst#1051)
 *
Fix Sonoff Bridge missed learned key if learned data contains 0x55 (End
of Transmission) flag (arendst#1095, arendst#1294)
 * Fix PWM initialization in
Dimmer/Color mode (arendst#1321)
 * Fix Wemo Emulation (arendst#1357)
 * Fix display
of build date and time in non-english locale (arendst#1465)
 * Fix Wemo and Hue
emulation by adding M-Search response delay (arendst#1486)
 * Add libraries
Adafruit_BME680-1.0.5, Adafruit_Sensor-1.0.2.02, TasmotaSerial-1.0.0 and
TSL2561-Arduino-Library
 * Add command Color2 to set color while keeping
same dimmer value
 * Add device function pointers
 * Add support for
SenseAir S8 CO2 sensor
 * Add color led signal to Carbon Dioxide (CO2)
sensors using defines CO2_LOW and CO2_HIGH in user_config.h
 * Add
support for Domoticz Air Quality sensor to be used by MH-Z19(B) and
SenseAir sensors
 * Add support for PZEM004T energy sensor
 * Add
support for iTead SI7021 temperature and humidity sensor by
consolidating DHT22 into AM2301 and using former DHT22 as SI7021 (arendst#735)

* Add support for BME680 using adafruit libraries (arendst#1212)
 * Add support
for MH-Z19(B) CO2 sensor (arendst#561, arendst#1248)
 * Add multipress support and
more user configurable GPIO to Sonoff Dual R2 (arendst#1291)
 * Add support for
TSL2561 using adafruit library (arendst#661, arendst#1311)
 * Add support for SHT3x
(arendst#1314)
 * Add support for Arilux LC06 (arendst#1414)
 * Add Italian language
file (arendst#1449)
 * Add 2nd Gen Alexa support to Wemo emulation discovery
(arendst#1357, arendst#1450)
 * Add define for additional number of WS2812 schemes
(arendst#1463)
@MACscr
Copy link

MACscr commented Jan 11, 2018

So has this been solved in the most recent release or is receiving still inconsistent?

@MACscr
Copy link

MACscr commented Jan 22, 2018

Why is this closed when the issue still exists?

curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
* Fix Sonoff Bridge missed learned key if learned data contains 0x55
(End of Transmission) flag (arendst#1095, arendst#1294)
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
5.10.0a
 * Add (experimental) support for sensor SHT3x
 * Add support
for sensor MH-Z19(B) using serial interface to be enabled with define
USE_MHZ19 in user_config.h (arendst#561, arendst#1248)
 * Add (experimental) support
for sensor MH-Z19(B) using SoftwareSerial to be enabled with define
USE_MHZ19 in user_config.h (arendst#561, arendst#1248)
 * Add support for iTead SI7021
temperature and humidity sensor by consolidating DHT22 into AM2301 and
using former DHT22 as SI7021 (arendst#735)
 * Fix BME280 calculation (arendst#1051)
 *
Add support for BME680 using adafruit libraries (arendst#1212)
 * Change
ADS1115 default voltage range from +/-2V to +/-6V (arendst#1289)
 * Add
multipress support and more user configurable options to Sonoff Dual R2
(arendst#1291)
 * Fix Sonoff Bridge missed learned key if learned data contains
0x55 (End of Transmission) flag (arendst#1095, arendst#1294)
 * Add support for
TSL2561 using adafruit library (arendst#661, arendst#1311)
 * Add alternative support
for SHT3x (arendst#1314)
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
5.10.0a
 * Add (experimental) support for sensor SHT3x
 * Add support
for sensor MH-Z19(B) using serial interface to be enabled with define
USE_MHZ19_HARD_SERIAL in user_config.h (arendst#561, arendst#1248)
 * Add
(experimental) support for sensor MH-Z19(B) using SoftwareSerial to be
enabled with define USE_MHZ19_SOFT_SERIAL_OBSOLETE in user_config.h
(arendst#561, arendst#1248)
 * Add (experimental) support for sensor MH-Z19(B) using
stripped SoftwareSerial to be enabled with define USE_MHZ19_SOFT_SERIAL
in user_config.h (arendst#561, arendst#1248)
 * Add support for iTead SI7021
temperature and humidity sensor by consolidating DHT22 into AM2301 and
using former DHT22 as SI7021 (arendst#735)
 * Fix BME280 calculation (arendst#1051)
 *
Add support for BME680 using adafruit libraries (arendst#1212)
 * Change
ADS1115 default voltage range from +/-2V to +/-6V (arendst#1289)
 * Add
multipress support and more user configurable options to Sonoff Dual R2
(arendst#1291)
 * Fix Sonoff Bridge missed learned key if learned data contains
0x55 (End of Transmission) flag (arendst#1095, arendst#1294)
 * Add support for
TSL2561 using adafruit library (arendst#661, arendst#1311)
 * Add alternative support
for SHT3x (arendst#1314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants