OpenBK7231T_App icon indicating copy to clipboard operation
OpenBK7231T_App copied to clipboard

TuyaMCU on UART2 (BK7231N)

Open DJVirus1980 opened this issue 1 year ago • 11 comments

How to connect the TuyaMCU driver to the UART2 on BK7231N.

DJVirus1980 avatar Jun 04 '24 09:06 DJVirus1980

Enable flag 26 ([UART] Use alternate UART for BL0942, CSE, TuyaMCU, etc).

NonPIayerCharacter avatar Jun 04 '24 10:06 NonPIayerCharacter

Interesting, it's the first time I see that. Is there really a device with TuyaMCU on log port?

openshwprojects avatar Jun 04 '24 21:06 openshwprojects

This termostat Screenshot_20240605-122144_3

DJVirus1980 avatar Jun 05 '24 09:06 DJVirus1980

photo_2024-06-05_21-39-25

DJVirus1980 avatar Jun 05 '24 18:06 DJVirus1980

module not receive data from mcu on uart2, if i am conect mcu to uart1 all data received.

DJVirus1980 avatar Jun 14 '24 18:06 DJVirus1980

hello. I purchased the same thermostat. how can I make it work with OpenBK?

Hard-3d avatar Jul 07 '24 22:07 Hard-3d

IMG_20240705_235808

Hard-3d avatar Jul 07 '24 22:07 Hard-3d

Hi. I don’t have time to fully understand it yet, but there is no response from MCU regarding UART2. I am connected MCU to UART1, baud rate 38400.

DJVirus1980 avatar Jul 08 '24 18:07 DJVirus1980

Please send your own /autoexec.bat

Hard-3d avatar Jul 09 '24 18:07 Hard-3d

startDriver TuyaMCU startDriver NTP ntp_timeZoneOfs 3 tuyaMcu_setBaudRate 38400 uartSendHex 55AA000300010306 delay_s 20 tuyaMcu_sendCurTime

DJVirus1980 avatar Jul 09 '24 18:07 DJVirus1980

Hello; I have a the same issue, tring to use the UART2: I have an energy power meter with 2 BL0942 chips : one over UART 1 and an other over UART2: I can send data command by UART2 but I cannot receive data: did you solved ?

LucaArena avatar Sep 13 '24 17:09 LucaArena

@LucaArena Hi, I have same device energy power meter with 2 BL0942 chips : one over UART 1 and an other over UART 2. Did You find the solution? On second uart i'm getting just zeroes.

xjikka avatar Nov 11 '24 18:11 xjikka

Hi,

Yes I modified the driver to support both chips:

Actually I’m testing the solution over 3 devices: it works with good precision (< 1% ) of total energy accumulated:

Just a note about software driver implementation:

The Interrupt Service Routine over the 2nd UART does not correctly run, so I apply a patch with polling request a 1ms.

Cheers

Da: XJ @.> Inviato: lunedì 11 novembre 2024 19:56 A: openshwprojects/OpenBK7231T_App @.> Cc: LucaArena @.>; Mention @.> Oggetto: Re: [openshwprojects/OpenBK7231T_App] TuyaMCU on UART2 (BK7231N) (Issue #1258)

@LucaArena https://github.com/LucaArena Hi, I have same device energy power meter with 2 BL0942 chips : one over UART 1 and an other over UART 2. Did You find the solution? On second uart i'm getting just zeroes.

— Reply to this email directly, view it on GitHub https://github.com/openshwprojects/OpenBK7231T_App/issues/1258#issuecomment-2468835037 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BIMAVELP3FBT3PILKROFTMD2AD4UFAVCNFSM6AAAAABIYFLMF2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRYHAZTKMBTG4 . You are receiving this because you were mentioned. https://github.com/notifications/beacon/BIMAVEOIRHKZHXSRKMOAHM32AD4UFA5CNFSM6AAAAABIYFLMF2WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUTE5XN2.gif Message ID: @.*** @.***> >

LucaArena avatar Nov 12 '24 08:11 LucaArena

@LucaArena Thx, You're using uart_read_byte or test_ty_read_uart_data_to_buffer ?

xjikka avatar Nov 12 '24 15:11 xjikka

I’m using test_ty_read_uart_data_to_buffer: anyway this function calls using uart_read_byte.

The power measures are ok: there is an issue on the total energy: sometime it saved a wrong big value!

Da: XJ @.> Inviato: martedì 12 novembre 2024 16:54 A: openshwprojects/OpenBK7231T_App @.> Cc: LucaArena @.>; Mention @.> Oggetto: Re: [openshwprojects/OpenBK7231T_App] TuyaMCU on UART2 (BK7231N) (Issue #1258)

@LucaArena https://github.com/LucaArena Thx, You're using uart_read_byte or test_ty_read_uart_data_to_buffer ?

— Reply to this email directly, view it on GitHub https://github.com/openshwprojects/OpenBK7231T_App/issues/1258#issuecomment-2470905119 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BIMAVEKVTCZVVKUHGBG3AW32AIQCVAVCNFSM6AAAAABIYFLMF2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZQHEYDKMJRHE . You are receiving this because you were mentioned. https://github.com/notifications/beacon/BIMAVEO7I4ZUAOVMO5E4LOT2AIQCVA5CNFSM6AAAAABIYFLMF2WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUTI4CR6.gif Message ID: @.*** @.***> >

LucaArena avatar Nov 13 '24 08:11 LucaArena

I use test_ty_read_uart_data_to_buffer: anyway, this function calls with uart_read_byte. >

I am not able to receive any data from the UART2 using these functions (but the data on the pin is coming if I test it with an external receiver]), Can you send me the changed code? I couldn't find it in your repo branches.

xjikka avatar Nov 13 '24 08:11 xjikka

Hi,

Yes I had the same issue: the interrupt service for UART2 appends, but the data is not available in the register data input:

I changed the strategy, to read the data from UART2: instead of using interrupt, I use a polling: I check if any data is available every 1mS: is a patch ( not optimized )

Maybe you cannot find in the branch because is a part of platform ( I cannot remember )

Anyway, I ‘d like help you: how can I share the code? By Google Drive ?

I need time to create a good branch, so everyone could use.

Cheers

Da: XJ @.> Inviato: mercoledì 13 novembre 2024 09:45 A: openshwprojects/OpenBK7231T_App @.> Cc: LucaArena @.>; Mention @.> Oggetto: Re: [openshwprojects/OpenBK7231T_App] TuyaMCU on UART2 (BK7231N) (Issue #1258)

I use test_ty_read_uart_data_to_buffer: anyway, this function calls with uart_read_byte. >

I am not able to receive any data from the UART2 using these functions (but the data on the pin is coming if I test it with an external receiver]), Can you send me the changed code? I couldn't find it in your repo branches.

— Reply to this email directly, view it on GitHub https://github.com/openshwprojects/OpenBK7231T_App/issues/1258#issuecomment-2472859377 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BIMAVEOCNS3XC76EUAR45WD2AMGSBAVCNFSM6AAAAABIYFLMF2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZSHA2TSMZXG4 . You are receiving this because you were mentioned. https://github.com/notifications/beacon/BIMAVEIGB6WO3PBO7P74YXD2AMGSBA5CNFSM6AAAAABIYFLMF2WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUTMTLPC.gif Message ID: @.*** @.***> >

LucaArena avatar Nov 13 '24 09:11 LucaArena

I ‘d like help you: how can I share the code? By Google Drive ?>

Can You send me simply the changed files or code snippets? Or You can simpy use any network service like https://www.uschovna.cz/en/?set_lang=en (i'm using it fo years, no registration, just need email). Google drive is also ok.

xjikka avatar Nov 13 '24 09:11 xjikka

@LucaArena I already found the solution, you don't need to send me anything.

xjikka avatar Nov 15 '24 22:11 xjikka