cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB55: How to send/update temperature reading to Home Assistant?

maestrmx19
Associate II

Hello everyone,

I'm a beginner working on a project using an STM32WB55 with a temperature sensor, and I'm trying to set it up in Zigbee mode with Home Assistant and ZHA as the coordinator. My goal is to update temperature data on Home Assistant, but I haven’t been successful so far (I’ve only managed to join the zigbee network).

I’ve tried setting up the network and using ZbZclAttrIntegerWrite to update the temperature attribute, but nothing seems to been updated in Home Assistant and the temperature is updated only when my STM32WB join again ZHA (and after that the value remains stuck at -327.7°C).

maestrmx19_0-1730461304704.pngmaestrmx19_5-1730462094431.png

Here is my code that updates the temperature (this function is called every 5 minutes by a timer and it's the only thing I've modified from app_zigbee.c after CubeMX code generation) : 

 

static void APP_ZIGBEE_Send_Temperature()
{
    printf("send Senor value\r\n");
    float temperature_lus=0.1;
    SHT35_LireTemperature(&temperature_lus);
    int16_t temperature = (int16_t)(temperature_lus * 100); 
    enum ZbStatusCodeT status;
    uint64_t epid = 0U;

    if (ZbNwkGet(zigbee_app_info.zb, ZB_NWK_NIB_ID_ExtendedPanId, &epid, sizeof(epid)) != ZB_STATUS_SUCCESS) {
        printf("Error\r\n");
        return;
    }

    if (epid == 0U) {
        printf("Error\r\n");
        return;
    }

    printf("Send temperature: %d centi-degres\r\n", temperature);

    status = ZbZclAttrIntegerWrite(zigbee_app_info.temperature_meas_server_1, ZCL_TEMP_MEAS_ATTR_MEAS_VAL, temperature);

    if (status != ZB_STATUS_SUCCESS) {
        printf("Error2\r\n");
    } else{
    	printf("Envoi reussi de la temperature\r\n");
    }


    printf("\n\n\n\n \r\n");
}

 

 

Heres  screenshots of the CubeMX configuration:  

maestrmx19_1-1730462336425.pngmaestrmx19_3-1730462384507.png

maestrmx19_4-1730462406399.png

And here's a screenshot of my network settings in ZHA (I don't know if this helps):

maestrmx19_0-1730462308668.png

Has anyone here worked on something similar, or are there any example implementations that I could refer to? I would appreciate any guidance or code examples to help me get this working.

Best regards

maestrmx19
 
1 REPLY 1
Ouadi
ST Employee