Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

ble temperature reader application gives constant readings which doesn't reflect the actual temperature variation #165

Open
kiran-g opened this issue May 21, 2019 · 0 comments

Comments

@kiran-g
Copy link

kiran-g commented May 21, 2019

I am trying to read temperature values from a BLE Temperature sensor (bluemaestro tempo disc)

I am developing in c++ using tinyb library.

Relevant code snippet:

using Iter = std::vector<std::unique_ptr<tinyb::BluetoothDevice>>::const_iterator;
while (true)
{
    for (Iter it = sensor_tag_array.begin(); it != sensor_tag_array.end(); ++it)
    {
        std::string address_ = (*it)->get_address();

        std::map<uint16_t, std::vector<uint8_t>> mfg__ = (*it)->get_manufacturer_data();
        for (auto it : mfg__)
        {
            if (it.second.empty())
                logger_->error("{}, {} :Empty mfg for : {}", __FILENAME__, __func__, bleMap[address_].sensor_name);
            else
            {
                if (it.second.front() == 23)
                {
                    battery_lvl = it.second[1];
                    first_byte = it.second[6];
                    second_byte = it.second[7];
                    temperature = convert_to_actual(first_byte, second_byte) / 10.0;
                    std::cout << "\nTemperature is for : " << bleMap[address_].sensor_name << " : " << temperature << "\n";
                }
            }
        }
}

This code was properly giving the correct relatime values until now. But suddenly it started printing a single constant reading each time the application is restarted. Whatever temperature value is first read at application startup is repeated throughout the application runtime. I used the tempo utility app to verify that the sensor is actually reporting the correct realtime values.

I tried re-installing the OS (Ubuntu 18.04.1), tried multple version of bluez ( 5.48 which is pre-installed,5.39 and 5.37) but the issue is still there. Tinyb file :libtinyb.so.0.5.1

I also changed the advertisement frequency in the bluemaestro device.

Any idea how to resolve this ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant