grafalex82 / hellozigbee

Hello NXP JN5169 Zigbee
64 stars 13 forks source link

Compatible with tuya switches? #9

Closed ferbulous closed 5 months ago

ferbulous commented 10 months ago

Hi, could I just swap the JN5169 chip over TLSR825x that’s usually on tuya switches and flash the firmware? Is it similar to swapping esp with non esp chip to install tasmota/esphome?

https://youtu.be/d_HpkIiWC3Y?si=K94S933bM8K9OCnz

grafalex82 commented 10 months ago

You cannot just simply swap chips. TLSR825x has different architecture, compiler, SDK, and the code in this project cannot be used as is for the new chip. The only (though very big) take away from this project you would have is understanding how the Zigbee works under the hood, so that you can apply this knowledge for any other chip on your choice.

As for modules pinout. I did not compare Tuya modules pinout with the EBYTE E75–2G4M10S I am using. But at the first glance the pins layout is totally different: Tuya module has pins on 2 sides, while the EBYTE has on 3 sides. Nothing is impossible, and you can solder the new module with some wiring, but definitely this is not so easy like transplantation on the video you provided. And again, you'lll have to write your own firmware.

Note, that Tuya produces Zigbee and WiFi modules with the same pinout, so there may be a higher chance for interchanging those.

ferbulous commented 10 months ago

Yes, that's what I meant, by just swapping the existing tuya chip with JN5169 like this one And I might to have solder wires to the pads if the chip pinout doesn't match as you've mentioned

Other than zigbee switches, are zigbee lights with PWM or LED drivers supported?

devbis commented 10 months ago

@ferbulous There is a zigbee SDK for Telink chips and if you're familiat with writing in C it is pretty simple, comparing to different architectures. And there are some examples in SDK and an attempt to write open-source firmware for Tuya devices based on telink. https://github.com/doctor64/tuyaZigbee/tree/master/light

grafalex82 commented 10 months ago

@ferbulous I took a more precice look at the video you posted, and realized one more thing.

Tuya modules (both WiFi and Zigbee) implement a high level communication protocol. If you take a look at the board this guy is soldering, this module is not the main chip on the board. There is a main microcontroller that implements the functionality of the device (handle buttons, LEDs, screen, relay, whatever), while the Tuya chip is just for communication.

The Tuya protocol is open and well described. Thus tasmota firmware just implements the same protocol. And that is why this guy so easily swaps the module, as the main microcontroller simple does not spot any difference. This trick will not work for devices that utilize this module not only for communication, but for the main device functionality.

It is definitely possible to make a similar module based on JN5169 chip (or use one from EBYTE with a few jumper wires), and implement the same Tuya protocol. Though I doubt this will happen as a part of this particular project:

ferbulous commented 10 months ago

There is a main microcontroller that implements the functionality of the device (handle buttons, LEDs, screen, relay, whatever), while the Tuya chip is just for communication.

From the video yes, fortunately none of my tuya devices utilize tuya mcu so the relays/led/buttons are directly controlled by the chip. I did swap a TLSR825x zigbee chip with an esp32 for tasmota because the zigbee integration was becoming unreliable.

ferbulous commented 10 months ago

Hi @grafalex82 I’ve requested access for the Beyond Studio IDE. Does it require anything else to get approved? Some form of subscription perhaps

grafalex82 commented 10 months ago

I do not remember :( I got mine a while ago. But AFAIK it should not require any approvals, I just downloaded it from their web site after registration. In any case I do not really use it as IDE, I just have a compiler, SDK, and flashing utility.

ferbulous commented 10 months ago

@grafalex82 this is what I'm getting unless there's another link to grab the IDE

image

grafalex82 commented 10 months ago

My account seems to be deleted, but I managed to register again. Try downloading software from here https://www.nxp.com/products/wireless-connectivity/zigbee/zigbee-3-0-sdk:ZIGBEE-3-0-SDK

ferbulous commented 10 months ago

@grafalex82 Thanks for the links sorry to bother you again, but each I time I tried to download the necessary files it just redirects me to this

JN516x ZigBee 3.0 SDK BeyondStudio for NXP

image

Edit --

Nevermind, found another link here

https://www.nxp.com/pages/jn516x-7x-zigbee-3-0:ZIGBEE-3-0

ferbulous commented 10 months ago

hi @grafalex82 now that I can compile it, is there a documentation how can I change the pin roles? For example DI016 as relays/button.

grafalex82 commented 10 months ago

Unfortunately I have not started porting this code to other boards. However, to unblock you I just created Configuration.h file in the xiaomi_hw_integration branch, where you can create your own configuration. Select current board in the #define on top of the file for now, later I will move this to a CMake configuration.

I am open for discussion on how to better structure the configuration settings.

ferbulous commented 10 months ago

Thanks @grafalex82 Since most of switches are using zigbee switch that’s similar to esp12 pinout. I’m trying to make an adapter for JN5169 so i don’t have to keep soldering wires to each pad. I’ve never build custom pcb so that’s gonna be a bit of a learning curve for me

Similar to this

https://www.pcbway.com/project/shareproject/wb2s_tywe2s_esp12f_adapter.html

grafalex82 commented 9 months ago

@ferbulous There is an easier option to making a custom PCB: you can mount the module on a double sided tape somewhere and solder a few wires. I used this approach for making my dev board for this project.

image