// before
void get_sensor_data(void)
{
    char buf[128] = {0};
    int offset = 0;

    offset += snprintf(buffer + offset,
                       buffer_size - offset,
                       "{\"sensors\":[");
    const float temperature = get_temperature();
    offset += snprintf(
        buffer + offset,
        128 - offset,
        "{\"name\":\"temperature\",\"value\":%.2f}",
        temperature);

    const float humidity = get_humidity();
    offset += snprintf(
        buffer + offset,
        128 - offset,
        "{\"name\":\"humidity\",\"value\":%.2f}",
        humidity);

    snprintf(buffer + offset,
            128 - offset, "]}");
}
