xoseperez / espurna

Home automation firmware for ESP8266-based devices
http://tinkerman.cat
GNU General Public License v3.0
2.99k stars 636 forks source link

Firmware for a new (unsupported?) switch board #2541

Closed GitJa21 closed 1 year ago

GitJa21 commented 2 years ago

Device

Unnamed, seems like Geekcreit

Version

No response

Question

Hello! There is such a board. (PSF-B85/PSF-B04, RFE274DM and one unknown chip, apparently related to the RF part) It has two separate relay control buttons, a two-color LED indicating the operation of the board and two single-color LEDs indicating the operation of the relay. Using the buttons, we can switch wifi to hotspot and to pairing of 433MHz remotes. I don’t want to try e-Welink (especially register on their website) I really want to flash ESPurna into it. Since I like it and it is already flashed on different ESP switches in my network. Ofcourse, I want to be able to control both relays using the RF remote control. (I can't even imagine if this is possible on this board) Tell me what firmware can be used in finished form. Maybe someone has already tried... Is there a generic version where I can configure the GPIO and RCs scan-codes via the Web interface? Or adapt some of the existing firmware. IMG_20221004_230925 IMG_20221004_231025

mcspr commented 2 years ago

PSF-B04 is a ESP8285, so at least that works :)

Quick search through the device db for tasmota, here what looks like it

I'd expect RF works the same as other ITEAD / SONOFF devices (4CH RF, BASIC RF, wall mounted switch T1, etc.) - RF chip handles all the learning and emulates a button press when it receives a matching signal. Just a matter of finding out what it needs to 'learn' a signal

Flashing it is another question. Manual approach obviously works, see the db entry above to find GPIO0 and TX & RX pins. I wonder if ITEAD firmware still allows direct connections to devices' access point to initiate DIY mode and upgrade that way. Could be only for SONOFF devices, though

While we already have DUAL_R2 hardware that has matching pins https://github.com/xoseperez/espurna/blob/35656314aa5f452a5b09fbb3acbe508fde9e280a/code/espurna/config/hardware.h#L638-L670 https://github.com/xoseperez/espurna/blob/35656314aa5f452a5b09fbb3acbe508fde9e280a/code/platformio.ini#L445-L447 I am a bit worried b/c tasmota db has these completely different pins; we might have a mislabeled device https://templates.blakadder.com/sonoff_dual_R2.html

GitJa21 commented 2 years ago

Thanks a lot for the information. I flashed the firmware from Sonoff Dual R2. Through WEB everything works perfectly. Relay and LED. But for some reason, both the physical buttons and the radio began to work incorrectly. When the button is pressed, the state of the relay changes, and after releasing button, relay returns to the previous state.

mcspr commented 2 years ago

But for some reason, both the physical buttons and the radio began to work incorrectly. When the button is pressed, the state of the relay changes, and after releasing button, relay returns to the previous state.

Dual configuration specifies that these are 'switches', so 'press' and 'release' events toggle the relay. Could be remedied either by changing both and re-building, or adding a runtime setting that changes them from switch to pushbutton. In the terminal (DEBUG, telnet, serial connection)

set btnMode0 pushbutton
set btnMode1 pushbutton
reset

Reboot, and also check out what button 0 and button 1 say after that

mcspr commented 2 years ago

re. deleted message, were there any problems with the setup? I don't think pushbutton setup is wrong, but double-check the 'button 0' and 'button 1' output for the full config edit: and I should stress it again - reboot. unlike actions, mode setup of either switch or pushbutton happens on boot

GitJa21 commented 1 year ago

Thanks for the quick and interesting replies! Yes, I had to delete the message. I realized that I was playing with the old firmware (1.14) Then I reflashed and repeated the experiment (1.15) But unfortunately, your advice did not work with a new firmware too (of course I reboot the device). "btnMode0": "pushbutton", "btnMode1": "pushbutton",

[488471] [BUTTON] Button #0 event 1 (pressed)
[488493] [RELAY] #0 set to ON
[488979] [BUTTON] Button #0 event 3 (click)
[489000] [RELAY] #0 set to OFF
[489851] [BUTTON] Button #1 event 1 (pressed)
[489872] [RELAY] #1 set to ON
[490352] [BUTTON] Button #1 event 3 (click)
[490373] [RELAY] #1 set to OFF
[491378] [RELAY] Relay mask: 0b0

"btnMode0": "switch", "btnMode1": "switch",

[015009] [BUTTON] Button #0 event 1 (pressed)
[015031] [RELAY] #0 set to OFF
[015149] [BUTTON] Button #0 event 2 (released)
[015171] [RELAY] #0 set to ON
[016118] [BUTTON] Button #1 event 1 (pressed)
[016139] [RELAY] #1 set to OFF
[016269] [BUTTON] Button #1 event 2 (released)
[016290] [RELAY] #1 set to ON
[017296] [RELAY] Relay mask: 0b11

I tried other dual+ firmware and 4CH firmware worked as it should. True, 4 sliders are displayed (This is the lesser evil :) without rebuilding the firmware, of course)

Sorry, some commands from the wiki are not quite clear without examples. Is it possible to change the INPUT / OUTPUT direction of the GPIO and how to reassign it to the relay / button ...

By the way, RF works the same as other SonOff devices - RF chip handles all the learning and emulates a button press when it receives a matching signal. Indeed.

Here are some differences in settings. But I still can't figure out why it doesn't work correctly. (I set the switch mode manually after pushbutton, so nothing change anyway) изображение

mcspr commented 1 year ago

Ah, since dual declares pressed / btnPress in build config, we need to set it to none to accompany pushbutton mode change. 4ch doesn't have anything there, so it works like you expect.

Relay association is also a setting for button - btnRelay0, btnRelay1, and etc. numbered from 0 If action does something related to relays, it would use that relay index to relay-toggle or relay-on or relay-off

GitJa21 commented 1 year ago

Wow! I did not think that it is possible to reassign procedures on events. So commands

set btnRlse0 none 
set btnRlse1 none 

did their job. Everything works perfectly! Thanks a lot!