openshwprojects / OpenBK7231T_App

Open source firmware (Tasmota/Esphome replacement) for BK7231T, BK7231N, BL2028N, T34, XR809, W800/W801, W600/W601, BL602 and LN882H
https://openbekeniot.github.io/webapp/devicesList.html
1.4k stars 245 forks source link

BSEED Lightswitch with WB3S, can't turn off? #110

Open blind-coder opened 2 years ago

blind-coder commented 2 years ago

Hello,

I have a lightswitch that came with Tuya on a WB3S. I flashed the file OpenBK7231T_UA_1.5.8.bin on it successfully and I can now more or less use it. The device looks a lot like https://templates.blakadder.com/bseed_2_gang.html only it has only a single switch instead of two.

I was able to configure it like this: image

When P6 is off, an output on P10 will illuminate a red light around the button. When P6 is on, the red light will be off, no matter what P10 says. When P10 is ON, I can use P7 to turn P6 ON. But I can't use P7 to turn P6 OFF again.

Also, with the original FW, there was a dim BLUE light around the button as well, but I can't find that on the configuration, no matter what I do (Rel, LED, PWM).

Any help would be greatly appreciated!

Kind regards, blindcoder

openshwprojects commented 2 years ago

I am not sure if I understand, but you are using Btn role incorrectly.

P7 Btn is linked with a single press to channel 1 and with double click to.... to channel 1 as well?? It makes no sense.

You should try configuring P7 as Btn with 1 in first textbox (single press toggles channel 1) and 2 in second textbox (double clicks toggles channel 2).

Also, do you really have two relays in that device?

blind-coder commented 2 years ago

There's just one relay in there. I wanted to have the button always toggle relay 1, regardless of single or double press.

I think I found the issue, though: while flashing I think I broke the 8 pin holes on the lower board and now the upper board no longer is properly fixed in the lower board. I'll fix that later and then try to find where the red and blue led is attached to. The blue one maaay be on a pwm as it was possible to configure its brightness with the Tuya firmware.

Kind regards, Benjamin

Am 6. Juli 2022 17:02:52 MESZ schrieb openshwprojects @.***>:

I am not sure if I understand, but you are using Btn role incorrectly.

P7 Btn is linked with a single press to channel 1 and with double click to.... to channel 1 as well?? It makes no sense.

You should try configuring P7 as Btn with 1 in first textbox (single press toggles channel 1) and 2 in second textbox (double clicks toggles channel 2).

Also, do you really have two relays in that device?

-- Reply to this email directly or view it on GitHub: https://github.com/openshwprojects/OpenBK7231T_App/issues/110#issuecomment-1176333603 You are receiving this because you authored the thread.

Message ID: @.***> -- Diese Nachricht wurde von meinem Android-Gerät mit K-9 Mail gesendet.

blind-coder commented 2 years ago

After fixing the pin connectors of the boards it now looks better, but I still can't figure out how to control the red and blue LEDs.

blind-coder commented 2 years ago

For more information, I have this item: https://templates.blakadder.com/unsupported/bseed-switch-plug.html I have now tried "LED" on all pins except P6 and P7 (which are now correctly Relay 1 and Btn 1 and work nicely: image

I tried "LED" with "2" on all other pins, as well as PWM on pins 8,9, 24 and 26, to no avail. Maybe there's a TuyaMCU involved somewhere. Is there a way to get RX and TX input / output?

blind-coder commented 2 years ago

Ooof, this is getting worse.

I changed P6 to "PWM". Increasing PWM up to (and including) 66 increases the intensity of the blue LED around the button. Increasing it to 67 (or more) turns on the light connected to the switch. To turn the light off again, the PWM value needs to be set to 26 or less afterwards.

Now I just need to a) link that somehow to the button on the front and b) turn off the red light as well.

blind-coder commented 2 years ago

Changing P7 from Btn to PWM 2 lets me change the red light intensity somewhat, but then I can't use it as a button anymore. Maybe I shorted two pins somewhere? I should probably get a new device.

blind-coder commented 2 years ago

Okay, I ordered a new device, should be here on Friday.

Lastly, if that device is equally weird, is there a way to hook a button up to a set of actions? Like On Btn 1 turn on: increase PWM 2 to 100 On Btn 1 turn off: decrease PWM 2 to 0; sleep 1 second; increase PWM 2 to 25

Is that possible without having to hook into Home Assistant or any other dependency?

openshwprojects commented 2 years ago

This could be done with a bit more advancing scripting,can you wait a bit, I'll add that possibility

blind-coder commented 2 years ago

I can wait a lot, no worries! I can do it easily throught HA, I just feel like this is some "basic" functionality that should be possible without a dependency on network.

blind-coder commented 2 years ago

The replacement now arrived, but it's of course different from the one I had. This one is based around a T34 chip. They handily have pads for a few pins where I can solder some wires to: image

Not sure I'm reading this correctly, but would you agree that the pins from left to right are, according to https://developer.tuya.com/en/docs/iot/t34-module-datasheet?id=Ka0l4h5zvg6j8: Ground P0 - TX2 P1 - RX2 P11 - TX1 P10 - RX1

next to this pad are also CEN, 3.3V and P21 (for some reason).

blind-coder commented 2 years ago

Successfully flashed the N version of your FW to it, this time without breaking or shorting any data lines hopefully. Took me a bit to realize that disconnecting and connecting GND to my serial adapter would reset the adapter, thus resetting it from an OS perspective. Using CEN to GND worked fine then.

Going to configure it now.

blind-coder commented 2 years ago

image

Done with configuration. This one is much simpler than the other, with a simple relay, a button and two LEDs, one of which I put on Wif LED_n (because it's inverted for some reason).

Thank you for this wonderful software!

openshwprojects commented 2 years ago

So you have found T34 version of chip? Can you provide more information? Which deviece, where bought, etc? Photos of inside?

blind-coder commented 2 years ago

This one, in black, bought two days ago: https://smile.amazon.de/gp/product/B07PWB4R4T Front side of the switch. Touch button in the center (white rectangle), underneath that are the red and blue LED: image Underside of the switch riser board. T34 in top left, six pins to connect to main board in lower left: image Inner main board of the switch, maybe not that interesting, pins to connect riser board with T34 in lower left: image

openshwprojects commented 2 years ago

That's very interesting, I have never seen a T34 device myself before. If you want to contribute, you can create a short topic , topic name - T34 chip - [device name here] - openbeken configuration and in topic content post some photos, information where to buy, post screenshots of your configuration (pins), etc, here: https://www.elektroda.com/rtvforum/forum507.html

I'm trying to create some kind of database of the devices. Thanks!

liamstears commented 2 years ago

20220709_114930 20220709_114812 20220709_114827 20220709_114842

I hope that posting here is the correct place, I have a very similar device, 1 gang light switch/dimmer. It has 1 on/off button and brightness up and down buttons either side of it. Each has LED underneath.

No matter what I try I can't seem to configure it, I think I just don't understand how it works. I was successful and flashed OpenBK7231N_QIO_1.6.1.bin and also just done ota update OpenBK7231N_1.6.1.rbl

But now I don't know how to setup, I don't know how to assign pins. I hope to get some help? Sorry if this is not the right place to post but I hope to get help and share information so other people can buy and use this device with this firmware....

blind-coder commented 2 years ago

@liamstears once you have it flashed, it opens a WiFi AP at "OpenBeken_" that you can connect to. After connecting, open a browser and go to http://192.168.4.1/ where you'll get a config screen. You can then configure your own WiFi settings (2.4GHz only). Once you have it connected to your WiFi, find its IP address (from your router's webinterface), connect to its IP address in a browser again and then you can configure the pins through the webinterface.

liamstears commented 2 years ago

@liamstears once you have it flashed, it opens a WiFi AP at "OpenBeken_" that you can connect to. After connecting, open a browser and go to http://192.168.4.1/ where you'll get a config screen. You can then configure your own WiFi settings (2.4GHz only). Once you have it connected to your WiFi, find its IP address (from your router's webinterface), connect to its IP address in a browser again and then you can configure the pins through the webinterface.

Thank you for a quick reply, yes I have done this and I can set pins but I don't know what to set each pin to, I have tried some different settings but nothing on the switch changes/works...

liamstears commented 2 years ago

Also BL0942 driver seems to be started, is this normal? I don't need this...

EDIT: Not to worry, I removed BL0942 from startup

blind-coder commented 2 years ago

I just went through all pins, set them to Rel 1 and tried to toggle it from the main page to see if something happened. Then went on to do the same with Btn, LED and in your case Dimmer as well.

liamstears commented 2 years ago

I can try this but it will take some hours. Can I ask, is it normal that the light switch functions normally and buttons all light up correctly when using the switch? It is only the firmware/software side not working

liamstears commented 2 years ago

I have now tried Rel 1, LED 1, LED_N 1 on every channel and nothing. Something is not right here...

blind-coder commented 2 years ago

If the button keeps working after you flashed the T34, you most probably have a TuyaMCU somewhere in between. That's another chip which communicates with the T34 using RX/TX using a binary protocol. Look for codes starting with 0x55 0xaa on the serial line when you turn the light on or off.

liamstears commented 2 years ago

If the button keeps working after you flashed the T34, you most probably have a TuyaMCU somewhere in between. That's another chip which communicates with the T34 using RX/TX using a binary protocol. Look for codes starting with 0x55 0xaa on the serial line when you turn the light on or off.

I think you may be right, I did not notice at first but now I see I have 1 extra IC on the PCB so this must be it. I guess I will need to use the "startDriver TuyaMCU" to get this to work, am I right?

I am very new to this so how exactly would I look for codes on the serial line? Do you mean connecting to same TX RX as I did to flash the device? And if so how do I do it?

I hope to crack this and share this device as it is a low cost device that works well if only I can get the "smart" aspect to work...

blind-coder commented 2 years ago

I haven't used TuyaMCU with OpenBK yet, I'm new to this myself.

liamstears commented 2 years ago

I haven't used TuyaMCU with OpenBK yet, I'm new to this myself.

No problem at all, thanks for all the help, hopefully openshwprojects can help some more

liamstears commented 2 years ago

As an update I've added the TuyaMCU driver and made toggle switches from 1 to 30 and none of them do anything. I have seen the following in logs when buttons on the switch are pressed:

Skipped data (part) 02 FE 2B FF 4A FA 56 FF 40 44 FE

Seems like its receiving some data but ignoring it and not sending any data maybe? Certainly going to need more help to get this one working...

openshwprojects commented 2 years ago

where did you buy this switch?

try following: https://www.elektroda.com/rtvforum/topic3904845.html

openshwprojects commented 2 years ago

"I've added the TuyaMCU driver and made toggle switches from 1 to 30 and none of them do anything" in order for toggles to work with tuyaMCU, you must link channels to tuyaMCU driver

liamstears commented 2 years ago

"I've added the TuyaMCU driver and made toggle switches from 1 to 30 and none of them do anything" in order for toggles to work with tuyaMCU, you must link channels to tuyaMCU driver

I bought on Amazon in the UK, listed as BSEED Smart Dimmer 1 Gang

This is what I did:

startDriver TuyaMCU setChannelType 1 toggle linkTuyaMCUOutputToChannel 1 1 1 setChannelType 2 toggle linkTuyaMCUOutputToChannel 2 1 2 setChannelType 3 toggle linkTuyaMCUOutputToChannel 3 1 3

But I went all the way up to channel 30 (linkTuyaMCUOutputToChannel 30 1 30)

But still nothing, do I need to do something else or I missed something?

I have USB TTL and happy to try and catch the codes but I wouldn't know how to do this and would need help....

EDIT: I know tamota has a way to capture dpid using tasmota log itself, maybe this is a feature that could be added in the future to make this process easier?

liamstears commented 2 years ago

"I've added the TuyaMCU driver and made toggle switches from 1 to 30 and none of them do anything" in order for toggles to work with tuyaMCU, you must link channels to tuyaMCU driver

I hope you can help further because at the moment I am stuck...

openshwprojects commented 2 years ago

I can add a debug flag for that tomorrow. Remind me if I forget.

but... are you sure that it's a TuyaMCU? Have you tried powering the module from external 3.3V power supply (or 5V if you connect it to the input of AMS1117) and then sniffing packets from RX/TX line (get 3.3V USB to UART converter, connect its TX to TX or RX line, ground to ground, set the baud rate to 9600, press buttons and see if something is received in terminal, repeat the same for second communication line)?

Of course, never try connecting anything to device that is mains powered. That's why you need external 3.3V or 5V power supply.

liamstears commented 2 years ago

I can add a debug flag for that tomorrow. Remind me if I forget.

but... are you sure that it's a TuyaMCU? Have you tried powering the module from external 3.3V power supply (or 5V if you connect it to the input of AMS1117) and then sniffing packets from RX/TX line (get 3.3V USB to UART converter, connect its TX to TX or RX line, ground to ground, set the baud rate to 9600, press buttons and see if something is received in terminal, repeat the same for second communication line)?

Of course, never try connecting anything to device that is mains powered. That's why you need external 3.3V or 5V power supply.

Ok so I used putty on windows and found a few things. If I connect to P0/UART2_TXD and P1/UART2_RXD on the board with baud of 115200 I get the same log output as I get on the UI of your firmware. If I connect to P10/DL_RX/UART1_RXD and P11/DL_TX/UART1_TXD (these are the ones I used to flash firmware) no matter what baud I select the output is gibberish

Examples: ▒▒▒▒▒

f▒▒f▒▒▒▒f▒f▒f▒▒▒

▒B▒▒▒▒ ?▒▒▒B▒▒▒F▒▒▒▒B▒▒▒B 8▒▒▒B▒▒▒▒B▒▒B▒▒▒F 8▒J▒▒B▒▒▒▒B▒▒B▒▒▒FL?▒J▒▒B▒▒▒▒▒▒▒B▒▒▒▒L8▒J▒▒B▒▒▒▒▒▒▒▒▒▒L8▒J▒▒B▒▒▒▒▒▒▒X

Z▒ ▒ ▒Z▒ ▒DZ▒ ▒ ▒Z▒ ▒D

But what I can see is a very clear command each time I press a button on the device so something is being sent each time I press a button on these pins

I hope this can be of some help to working this out and I am happy to try any other suggestions (although I think the device may end up failing if I keep connecting to P10 as I have to connect directly to the pin on the IC as the pad is covered by a button)

Thanks in advnace

liamstears commented 2 years ago

Please help, I would be so grateful...

openshwprojects commented 2 years ago

@liamstears I would need to get that device. Can you show me where have you bought it? Can I find it on ebay with international shipping?

Do you have a scope to check how the communication looks like and maybe determine correct baud?

liamstears commented 2 years ago

@liamstears I would need to get that device. Can you show me where have you bought it? Can I find it on ebay with international shipping?

Do you have a scope to check how the communication looks like and maybe determine correct baud?

Unfortunately I do not have a scope, I bought this device on Amazon here: https://www.amazon.co.uk/BSEED-Compatible-TUYA%EF%BC%8CAlexa-Assistant-Wireless/dp/B07WTCMLDJ/ref=sr_1_1?crid=1F8LJH3HB76K1&keywords=BSEED+Smart+Dimmer+Switch+1+Gang+1+Way%2CWiFi+Dimmer+Switch+Compatible+with+Alexa+and+Google+Home%2C500W+Smart+Light+Switch+White+with+Smart+Life+APP+Control+and+Timing+Function+%28Neutral+Wire+Need%29&qid=1660239014&sprefix=bseed+smart+dimmer+switch+1+gang+1+way+wifi+dimmer+switch+compatible+with+alexa+and+google+home+500w+smart+light+switch+white+with+smart+life+app+control+and+timing+function+neutral+wire+need+%2Caps%2C151&sr=8-1

blind-coder commented 1 year ago

There's a Windows program called Termite that can convert to hexadecimal code directly. Try that, and if the codes you see start with 55 aa then it's certainly a TuyaMCU on those pins.

HobboRobin commented 1 year ago

Hey together, I have the same device as @liamstears. Is there any progress ? I know that the extra IC is a standard TuyaMCU but i didnt got also the DPID´s

What would you need to help us ? :)

Jonsaes commented 1 year ago

Good afternoon. First of all, I want to congratulate you on the wonderful work you do for the community. I have a BSEED with the bk7231N chip. I have integrated it with ESPHome, and thanks to blind-coder's pinout diagram, I have been able to turn on and off the red LED, but I can't seem to use the blue LED in PWM mode. The most I've been able to do is turn on and off the LED in low-intensity mode, but I can never make it change its brightness, and when the relay is activated, the strong blue mode is triggered by default, and I have no control over it. Thank you very much for everything, regards.