logo elektroda
logo elektroda
X
logo elektroda

[BK7231N/CB2S] solaire photovoltaïque bidirectionnel. TuyaMCU

Eucli 1305 9
ADVERTISEMENT
  • Helpful post
    #1 21087170
    Eucli
    Level 3  

    Ola, I share the software modification for a bidirectional solar photovoltaic. TuyaMCU
    buy on aliexpress

    Diagram of a bidirectional meter installation with its components. Bidirectional meter module with a label detailing technical specifications.

    Link

    The module uses a CB2S chip
    Flashing is simple VCC GND TX RX I did not need to remove the module.

    Here is the autoexec

    startDriver TuyaMCU
    tuyaMcu_setBaudRate
    //tuyaMcu_defWiFiState 4
    setChannelType 1 ReadOnly
    linkTuyaMCUOutputToChannel 1 val 1
    setChannelType 2 ReadOnly
    linkTuyaMCUOutputToChannel 2 val 2
    setChannelType 3 ReadOnly
    linkTuyaMCUOutputToChannel 101 val 3
    setChannelType 4 ReadOnly
    linkTuyaMCUOutputToChannel 102 val 4
    setChannelType 6 ReadOnly
    linkTuyaMCUOutputToChannel 6 val 6
    


    Values 1 and 2 are the total counters of each direction.

    Direction 1 consumption
    Direction 2 production (reinjection)

    The 101 (val 3) gives the power in W The 102 (val 4) Gives the direction of the current 0 consumption 1 reinjection (or the opposite it will depend on the direction of your clamp)

    I still added the value 6 theoretically it is a value in hexadecimal but I cannot use it with OPK
  • ADVERTISEMENT
  • #2 21087249
    p.kaczmarek2
    Moderator Smart Home
    Thanks for sharing. So what is the dpID 6? I think you still can use it with OBK, for example with custom REST page... https://www.elektroda.com/rtvforum/topic3971355.html
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 21087407
    Eucli
    Level 3  
    I use node red a lot
    It is necessary to adapt


    // Vérifier si le message est undefined
    if (msg.payload === undefined) {
      // Bloquer le message
      return null;
    }
    
    // Traiter le message ici si nécessaire
    
    // Entrée : msg.payload contient la chaîne Base64
    
    // Convertir Base64 en hexadécimal
    var base64String = msg.payload;
    var hexString = Buffer.from(base64String, 'base64').toString('hex');
    
    // Sortie : msg.payload contient la chaîne hexadécimale
    msg.payload = hexString;
    
    
    
    
    // Entrée : msg.payload contient la chaîne de caractères "08d3000a780001bd"
    
    // Extraire les 4 premiers caractères
    var extractedBlockvolt = hexString.substr(0, 4);
    
    // Extraire les 6 Autres caractères
    var extractedBlockamp = hexString.substr(4, 6);
    
    // Extraire les 6 Autres caractères
    var extractedBlockpow = hexString.substr(10, 6);
    
    
    // Entrée : msg.payload contient la valeur hexadécimale
    
    // Convertir hexadécimal en décimal
    var decimalValuevolt = parseInt(extractedBlockvolt, 16);
    
    // Convertir hexadécimal en décimal
    var decimalValueamp = parseInt(extractedBlockamp, 16);
    
    // Convertir hexadécimal en décimal
    var decimalValuepow = parseInt(extractedBlockpow, 16);
    
    
    
    // Sortie : msg.payload contient les 4 premiers caractères extraits
    msg.payloadvolt = decimalValuevolt / 10;
    msg.payloadamp = decimalValueamp / 1000;
    msg.payloadpow = decimalValuepow / 1000;
    
    
    
    
    
    
    return msg;
    


    Added after 33 [minutes]:

    We can add it here ?

    https://openbekeniot.github.io/webapp/devicesList.html
  • ADVERTISEMENT
  • #6 21092624
    divadiow
    Level 34  
    cool

    Code: Text
    Log in, to see the code


    Added after 3 [minutes]:

    from that file

    Code: JSON
    Log in, to see the code


    device has a model too: PJ2101A. Googling that brings up the same device in some results

    Added after 2 [minutes]:

    https://github.com/OpenBekenIOT/webapp/pull/115
  • #7 21092635
    Eucli
    Level 3  

    Very good. What software did you use to get the id with the bin?

    Added after 39 [seconds]:

    I try JSON tomorrow. Thanks.
  • ADVERTISEMENT
  • #8 21092991
    p.kaczmarek2
    Moderator Smart Home
    This JSON looks like extracted via TuyaAPI:
    Extracting DpIDs for TUYA MCU devices
    Thank you for submitting model, this makes this teardown compleet.
    Helpful post? Buy me a coffee.
  • #9 21179720
    dicamarques
    Level 5  
    >>21092991 hello, I'm sorry but this is my first device, which JSON should I submit to the webapp to configure and get the power meter over MQTT?
  • #10 21189478
    dicamarques
    Level 5  
    @p.kaczmarek2 >>21179720
    Sorry for double posting. I have some more relevant information about this device.
    It has two more MCUs, a Nationstech: N32G430 C8L7 (controlling the wifi board and receiving data from the other MCU I suppose) and a STM32G030F6 for reading the current coil
    Circuit board with visible microchips and capacitors.
    Image of a printed circuit board with visible electronic components, including two microcontrollers, capacitors, and a button.

Topic summary

The discussion revolves around the software modification of a bidirectional solar photovoltaic system utilizing the TuyaMCU and the CB2S chip, purchased from AliExpress. The author shares a flashing procedure that does not require module removal and provides an autoexec script for configuring various data points (DPIDs) related to energy consumption and production. Participants inquire about specific DPID functionalities, suggest using Node-RED for data processing, and discuss extracting DPID information via TuyaAPI. Additional insights reveal the presence of two other MCUs in the device, enhancing its functionality.
Summary generated by the language model.
ADVERTISEMENT