1technophile / OpenMQTTGateway

MQTT gateway for ESP8266 or ESP32 with bidirectional 433mhz/315mhz/868mhz, Infrared communications, BLE, Bluetooth, beacons detection, mi flora, mi jia, LYWSD02, LYWSD03MMC, Mi Scale, TPMS, BBQ thermometer compatibility & LoRa.
https://docs.openmqttgateway.com
GNU General Public License v3.0
3.57k stars 786 forks source link

Bridge on ESP32 with CC1101 stops receiving after transmitting #1197

Closed vspek closed 2 years ago

vspek commented 2 years ago

Describe the bug The bridge it is receiving signals and displaying them in the serial port / forwarding them to the mqtt boker. When it receives an instruction from the mqtt broker to transmit, it will transmit a signal but after that it will not display any incoming signals anymore. Reboot restores receiving. Changing to a different RF library also restores receiving.

To Reproduce Upload from the web https://docs.openmqttgateway.com/upload/web-install.html esp32dev-multi_receiver or esp32dev-pilight-CC1101 Configure the bridge Push button of rf remote see received signal Send out message to transmit mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTto433" -m '{"value":1315156}' bridge is showing that it is transmitting

Expected behavior After transmitting it should start receiving again.

Environment (please complete the following information):

logs N: RF_EMITTER_GPIO: 12 N: RF_RECEIVER_GPIO: 27 N: ZgatewayRTL_433 setup done N: Switching to RF Receiver: 433.92 N: OpenMQTTGateway modules: ["RF","RF2","Pilight","RTL_433"] N: ** Setup OpenMQTTGateway end ** W: MQTT connection... N: Connected to broker N: Send on /SYStoMQTT msg {"uptime":4,"version":"v0.9.11","freemem":103608,"mqttport":"1883","mqttsecure":false,"freestack":4680,"rssi":-54,"SSID":"NEUF_ERIC","ip":"192.168.0.11","mac":"24:0A:C4:59:B7:20","actRec":2,"mhz":433.92,"modules":["RF","RF2","Pilight","RTL_433"]} N: Send on /433toMQTT msg {"value":44739241,"protocol":29,"length":26,"delay":235,"tre_state":"-","binary":"10101010101010101010101001","raw":"10833,259,288,249,299,258,329,234,1325,217,311,261,1292,246,300,259,1301,261,314,204,1313,256,300,264,1292,249,310,232,1301,264,304,228,1313,245,319,229,1326,238,288,249,1304,260,298,236,1335,226,312,244,1317,234,1304,259,288,","mhz":433.92} N: Send on /433toMQTT msg {"value":425,"protocol":29,"length":9,"delay":235,"tre_state":"1FF0","binary":"110101001","raw":"10833,255,2567,257,1291,247,315,232,303,257,1310,224,1333,231,325,217,314,258,1318,","mhz":433.92} N: Send on /433toMQTT msg {"value":1429427541,"protocol":29,"length":31,"delay":236,"tre_state":"-","binary":"1010101001100110101010101010101","raw":"10864,258,284,248,1321,257,301,260,1318,228,307,245,1320,231,328,234,1316,249,1312,222,338,218,311,240,1337,238,1316,249,305,222,339,218,1338,235,303,255,1313,224,319,245,1313,243,312,261,1317,226,309,247,1316,234,325,234,1308,252,307,247,1315,245,310,236,1317,258,284,","mhz":433.92} N: Send on /433toMQTT msg {"value":2795945,"protocol":29,"length":22,"delay":236,"tre_state":"-","binary":"1010101010100110101001","raw":"10853,257,2566,257,1293,247,317,258,300,235,1318,250,1316,246,309,235,1321,259,282,247,1318,257,299,234,1319,250,1314,247,314,220,311,240,1339,235,313,227,1334,223,313,260,1325,236,1310,224,329,","mhz":433.92} N: Send on /SYStoMQTT msg {"uptime":124,"version":"v0.9.11","freemem":110872,"mqttport":"1883","mqttsecure":false,"freestack":3208,"rssi":-52,"SSID":"NEUF_ERIC","ip":"192.168.0.11","mac":"24:0A:C4:59:B7:20","actRec":2,"mhz":433.92,"modules":["RF","RF2","Pilight","RTL_433"]} N: [ MQTT->OMG ]: {"value":1315156} N: RF Protocol:1 N: RF Pulse Lgth: 350 N: Bits nb: 24 N: Transmit mhz: 433.92 N: MQTTtoRF OK N: Send on /433toMQTT msg {"value":1315156} N: Switching to RF Receiver: 433.92 Here is stops receiving nothing is showing up anymore Only after creating mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoPilight" -m '{"active":true}' N: [ MQTT->OMG ]: {"active":true} N: Send on /PilighttoMQTT msg {"active":true} N: Switching to Pilight Receiver: 433.92 after changing of library type it starts receiving again N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"on"},"protocol":"smartwares_switch","length":"1677610","value":"1677610","repeats":2,"status":2} N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"on"},"protocol":"arctech_switch","length":"1677610","value":"1677610","repeats":2,"status":2} N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"up"},"protocol":"arctech_screen","length":"1677610","value":"1677610","repeats":2,"status":2} N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"on"},"protocol":"arctech_dimmer","length":"1677610","value":"1677610","repeats":2,"status":2} N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"opened"},"protocol":"arctech_contact","length":"1677610","value":"1677610","repeats":2,"status":2} N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"on"},"protocol":"smartwares_switch","length":"1677610","value":"1677610","repeats":2,"status":2} N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"on"},"protocol":"arctech_switch","length":"1677610","value":"1677610","repeats":2,"status":2} N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"up"},"protocol":"arctech_screen","length":"1677610","value":"1677610","repeats":2,"status":2} N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"on"},"protocol":"arctech_dimmer","length":"1677610","value":"1677610","repeats":2,"status":2} N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"opened"},"protocol":"arctech_contact","length":"1677610","value":"1677610","repeats":2,"status":2} N: Send on /SYStoMQTT msg {"uptime":364,"version":"v0.9.11","freemem":110024,"mqttport":"1883","mqttsecure":false,"freestack":3208,"rssi":-54,"SSID":"NEUF_ERIC","ip":"192.168.0.11","mac":"24:0A:C4:59:B7:20","actRec":1,"mhz":433.92,"modules":["RF","RF2","Pilight","RTL_433"]} N: [ MQTT->OMG ]: {"message":"{\"systemcode\":12,\"unitcode\":22,\"on\":1}","protocol":"elro_400_switch"} N: Send on /PilighttoMQTT msg {"message":"{\"systemcode\":12,\"unitcode\":22,\"on\":1}","protocol":"elro_400_switch"} N: Send on /PilighttoMQTT msg {"message":"{\"systemcode\":12,\"unitcode\":22,\"on\":1}","protocol":"elro_400_switch"} N: Switching to Pilight Receiver: 433.92 here it stopped receiving after transmitting N: [ MQTT->OMG ]: {"active":true} N: Send on /PilighttoMQTT msg {"active":true} tried to trick with sending again mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoPilight" -m '{"active":true}', but that did not work, need to really change the library N: Switching to Pilight Receiver: 433.92 N: Send on /SYStoMQTT msg {"uptime":484,"version":"v0.9.11","freemem":110024,"mqttport":"1883","mqttsecure":false,"freestack":3208,"rssi":-54,"SSID":"NEUF_ERIC","ip":"192.168.0.11","mac":"24:0A:C4:59:B7:20","actRec":1,"mhz":433.92,"modules":["RF","RF2","Pilight","RTL_433"]} N: [ MQTT->OMG ]: {"active":true} N: Send on /433toMQTT msg {"active":true} N: Switching to RF Receiver: 433.92 N: [ MQTT->OMG ]: {"active":true} N: [ MQTT->OMG ]: {"active":true} N: Send on /PilighttoMQTT msg {"active":true} N: Switching to Pilight Receiver: 433.92 after switching back,, receiving again messages N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"on"},"protocol":"smartwares_switch","length":"1677610","value":"1677610","repeats":2,"status":2} N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"on"},"protocol":"arctech_switch","length":"1677610","value":"1677610","repeats":2,"status":2} N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"up"},"protocol":"arctech_screen","length":"1677610","value":"1677610","repeats":2,"status":2} N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"on"},"protocol":"arctech_dimmer","length":"1677610","value":"1677610","repeats":2,"status":2} N: Send on /PilighttoMQTT msg {"message":{"id":1677610,"unit":0,"state":"opened"},"protocol":"arctech_contact","length":"1677610","value":"1677610","repeats":2,"status":2}

NorthernMan54 commented 2 years ago

@vspek I'm going to try to recreate this later today/tomorrow.

A little pro tip, the status message that comes out every few minutes includes the active receiver.

{"uptime":124,"version":"v0.9.11","freemem":110872,"mqttport":"1883","mqttsecure":false,"freestack":3208,"rssi":-52,"SSID":"NEUF_ERIC","ip":"192.168.0.11","mac":"24:0A:C4:59:B7:20","actRec":2,"mhz":433.92,"modules":["RF","RF2","Pilight","RTL_433"]}

And the value definition can be found here

https://github.com/1technophile/OpenMQTTGateway/blob/3fb34af2ce2861cb158d0f85716ae198ae650c2c/main/config_RF.h#L159

NorthernMan54 commented 2 years ago

Well I was not able to recreate the issue....this is the latest development build. Let me try again with the binary release

This is from my test environment

N: ************* WELCOME TO OpenMQTTGateway **************
N: OpenMQTTGateway Version: version_tag
N: OTA Hostname: OMG_240AC4EC20DC.local
N: WiFi ok with manual config credentials
N: RF_EMITTER_GPIO: 22 
N: RF_RECEIVER_GPIO: 4 
N: RF_EMITTER_GPIO: 22 
N: RF_RECEIVER_GPIO: 4 
N: RF_EMITTER_GPIO: 22 
N: RF_RECEIVER_GPIO: 4 
N: ZgatewayRTL_433 setup done 
N: Switching to RF Receiver: 433.92
N: OpenMQTTGateway modules: ["RF","RF2","Pilight","RTL_433"]
N: ************** Setup OpenMQTTGateway end **************
W: MQTT connection...
N: Connected to broker
N: Send on /SYStoMQTT msg {"uptime":10,"version":"version_tag","freemem":87548,"mqttport":"1883","mqttsecure":false,"freestack":29368,"rssi":-52,"SSID":"The_Beach","BSSID":"6C:70:9F:E9:B1:5E","ip":"192.168.1.181","mac":"24:0A:C4:EC:20:DC","actRec":2,"mhz":433.92,"modules":["RF","RF2","Pilight","RTL_433"]}
N: Send on /433toMQTT msg {"value":3709864,"protocol":1,"length":24,"delay":244,"tre_state":"-","binary":"001110001001101110101000","raw":"7579,269,709,249,733,743,233,749,237,744,231,268,725,260,717,248,737,741,233,251,741,247,713,764,238,745,231,262,728,737,220,748,247,744,225,265,732,743,233,252,740,740,242,241,742,250,716,254,728,","mhz":433.92}
N: no pub. dupl
N: no pub. dupl
N: Send on /433toMQTT msg {"value":3709864,"protocol":1,"length":24,"delay":245,"tre_state":"-","binary":"001110001001101110101000","raw":"4600253,276,708,247,725,744,258,723,262,715,258,261,703,258,735,247,738,744,231,254,739,245,716,740,259,744,231,263,718,731,248,746,247,743,224,265,732,743,231,253,715,740,260,262,724,236,728,259,730,","mhz":433.92}
N: Send on /433toMQTT msg {"value":3709864,"protocol":1,"length":24,"delay":244,"tre_state":"-","binary":"001110001001101110101000","raw":"7579,283,714,246,728,744,242,761,234,746,237,235,724,261,727,261,716,753,224,266,732,245,726,742,260,724,261,236,724,743,249,736,246,751,223,243,735,746,256,229,743,741,236,260,726,265,721,263,716,","mhz":433.92}
N: no pub. dupl
N: no pub. dupl
N: no pub. dupl
N: Send on /433toMQTT msg {"value":3709864,"protocol":1,"length":24,"delay":245,"tre_state":"-","binary":"001110001001101110101000","raw":"7604,257,713,256,739,722,256,724,259,723,261,237,747,238,724,261,742,725,249,241,734,245,727,745,258,723,264,234,726,737,249,738,244,727,249,245,737,742,258,226,746,740,235,259,726,259,724,262,718,","mhz":433.92}
N: no pub. dupl
N: no pub. dupl
N: no pub. dupl
N: no pub. dupl
N: [ MQTT->OMG ]: {"value":3812919}
N: RF Protocol:1
N: RF Pulse Lgth: 350
N: Bits nb: 24
N: Transmit mhz: 433.92
N: MQTTtoRF OK
N: Send on /433toMQTT msg {"value":3812919}
N: Switching to RF Receiver: 433.92
N: Send on /433toMQTT msg {"value":3709864,"protocol":1,"length":24,"delay":244,"tre_state":"-","binary":"001110001001101110101000","raw":"4579,222,715,246,727,743,259,722,263,714,256,262,727,233,736,250,735,744,235,252,740,244,743,737,236,741,228,259,742,727,250,743,223,741,258,227,747,739,236,259,729,737,255,236,742,253,711,247,753,","mhz":433.92}
N: no pub. dupl
N: no pub. dupl
N: Send on /433toMQTT msg {"value":3709864,"protocol":1,"length":24,"delay":245,"tre_state":"-","binary":"001110001001101110101000","raw":"2941361,261,704,257,740,721,259,750,231,726,260,236,724,264,739,240,736,739,234,261,718,255,743,721,256,725,259,229,737,740,261,727,233,742,252,259,711,751,246,244,731,745,231,253,742,249,714,267,716,","mhz":433.92}
N: Send on /433toMQTT msg {"value":3709864,"protocol":1,"length":24,"delay":245,"tre_state":"-","binary":"001110001001101110101000","raw":"7583,289,717,247,735,746,232,747,236,754,233,264,702,262,730,253,714,748,256,226,746,248,741,740,236,742,232,267,727,734,246,727,246,744,224,266,734,745,233,253,716,763,239,261,722,239,738,263,727,","mhz":433.92}
N: no pub. dupl
N: Send on /433toMQTT msg {"value":3709864,"protocol":1,"length":24,"delay":245,"tre_state":"-","binary":"001110001001101110101000","raw":"6603040,247,718,268,718,761,236,742,231,742,249,256,717,248,735,244,727,741,258,229,737,244,740,739,259,717,249,261,735,728,247,743,223,766,232,251,723,744,234,262,725,740,232,263,728,262,715,249,736,","mhz":433.92}
N: no pub. dupl
N: no pub. dupl
N: no pub. dupl
N: no pub. dupl
N: [ MQTT->OMG ]: {"value":3812919}
N: RF Protocol:1
N: RF Pulse Lgth: 350
N: Bits nb: 24
N: Transmit mhz: 433.92
N: MQTTtoRF OK
N: Send on /433toMQTT msg {"value":3812919}
N: Switching to RF Receiver: 433.92
N: [ MQTT->OMG ]: {"value":3812919}
N: RF Protocol:1
N: RF Pulse Lgth: 350
N: Bits nb: 24
N: Transmit mhz: 433.92
N: MQTTtoRF OK
N: Send on /433toMQTT msg {"value":3812919}
N: Switching to RF Receiver: 433.92
N: Send on /433toMQTT msg {"value":3709864,"protocol":1,"length":24,"delay":245,"tre_state":"-","binary":"001110001001101110101000","raw":"7597,275,737,245,726,739,258,726,258,717,256,264,714,256,738,245,733,718,257,254,717,256,725,741,259,740,226,262,715,755,248,743,223,740,257,228,747,743,235,262,722,741,257,239,725,259,735,250,714,","mhz":433.92}
N: no pub. dupl
N: no pub. dupl
N: Send on /433toMQTT msg {"value":3709864,"protocol":1,"length":24,"delay":245,"tre_state":"-","binary":"001110001001101110101000","raw":"3152566,256,708,251,737,745,233,747,235,744,258,238,728,258,733,255,710,746,250,240,727,247,745,739,235,749,236,262,725,740,247,735,246,724,249,243,738,743,231,253,743,741,235,263,722,241,737,242,736,","mhz":433.92}
N: no pub. dupl
N: no pub. dupl
N: no pub. dupl
N: no pub. dupl
N: no pub. dupl
N: Send on /433toMQTT msg {"value":3709864,"protocol":1,"length":24,"delay":244,"tre_state":"-","binary":"001110001001101110101000","raw":"1191771,265,725,250,743,720,264,737,231,744,245,258,709,251,738,247,727,741,259,230,737,245,738,741,258,716,249,263,730,729,247,742,226,766,224,266,730,744,235,249,714,765,237,234,750,237,725,261,732,","mhz":433.92}
N: no pub. dupl
N: no pub. dupl
N: no pub. dupl
N: no pub. dupl
N: no pub. dupl
N: Send on /433toMQTT msg {"value":594650,"protocol":31,"length":25,"delay":227,"tre_state":"-","binary":"0000010010001001011011010","raw":"59264,198,409,205,409,203,410,203,411,203,409,381,230,205,408,205,407,383,228,205,409,206,409,203,408,380,230,205,410,206,407,381,229,232,418,381,232,361,231,209,412,385,231,383,231,209,408,385,230,182,410,","mhz":433.92}
N: Send on /SYStoMQTT msg {"uptime":130,"version":"version_tag","freemem":91112,"mqttport":"1883","mqttsecure":false,"freestack":27752,"rssi":-54,"SSID":"The_Beach","BSSID":"6C:70:9F:E9:B1:5E","ip":"192.168.1.181","mac":"24:0A:C4:EC:20:DC","actRec":2,"mhz":433.92,"modules":["RF","RF2","Pilight","RTL_433"]}
vspek commented 2 years ago

Thank you for looking into it. I see that you are using different port to send and receive than the binary released web upload version I will try to build one with these ports too.

NorthernMan54 commented 2 years ago

@vspek Those ports are just how my breadboard is wired up. I tried to wire it up that way so that all the gpio pins were on that side.

I have started with getting the pre-built binaries loaded onto my ESP32, but ran into some issues getting it running. My thought is that something in the pre-build binary is causing your issue, hence the need to get it working.

vspek commented 2 years ago

I download the git repository and build and uploaded with platformio esp32dev-pilight-cc1101 -> has the same issue for me. Can send and can receive but after sending stops receiving

esp32dev-multi_receiver:

NorthernMan54 commented 2 years ago

I did my testing with RF for both sending and receiving, what combination did you use?

vspek commented 2 years ago

I have the issue with pilight, so this one esp32dev-pilight-cc1101 or pilight activated in esp32dev-multi_receiver:

NorthernMan54 commented 2 years ago

I was able to identify the issue and prepared a fix #1202

Problem was identified as the PiLight receiver module going deaf after a PiLight signal was transmitted.

vspek commented 2 years ago

I can confirm that it works, thank you very much for the fix.