2024-11-01 05:02 AM
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).
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:
And here's a screenshot of my network settings in ZHA (I don't know if this helps):
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