Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

These units do work with negative (freezing) temps, correct decoding algorithm #2

Open
eharris opened this issue Jun 4, 2020 · 2 comments

Comments

@eharris
Copy link

eharris commented Jun 4, 2020

I tested with a unit and have verified that these do work and read negative temps. According to their marketing materials, they only claim the device supports 0-50 degrees C, but the mobile app shows the range as -20C to 60C. I have personally verified that my unit reads sub-freezing temps (although I didn't have a way to test all the way down to -20C).

The decoding algorithm description could use updating to be less complicated and more accurate. Converting to a binary string isn't needed. The algorithm I used is (pseudocode):

Join the 3 data bytes together and convert to an integer, then:

if (val & 0x800000) {
    is_negative = true;
    val = val ^ 0x800000;
}
humidity = (val % 1000) / 10;
temp = int(val / 1000) / 10;
if (is_negative) {
    temp = 0 - temp;
}
# If desire Farenheit
temp = temp * 9 / 5 + 32;
@Thrilleratplay
Copy link
Owner

The official operating temperature range, according to Govee, for the H5075 is 0°C - 50°C (32°F - 122°F). It may display and send negative temperatures but I would be suspicious of those values. Also standard LCDs do not do well in freezing temperatures.

@JZ-SmartThings
Copy link

JZ-SmartThings commented Nov 29, 2020

I see that there has bee some discussion about negative temperature... the below seems to work for me and reports pretty accurately in tests with my fridge & freezer...


    - lambda: |-
        for (auto data : x.get_manufacturer_datas()) {
            if(data.data.size()==6) {
              const int basenum = (int16_t(data.data[1]) << 16) + (int16_t(data.data[2]) << 8) + int16_t(data.data[3]);
              float temperature = (basenum / 10000.0f);
              ESP_LOGD("custom", "Govee Two Reported Temp: %f", temperature);
              if(temperature>=839.0) {
                temperature = temperature-839;
                temperature = -temperature * 9.0/5.0 + 32.0;
              } else {
                temperature = temperature * 9.0/5.0 + 32.0;
              }
           }

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

No branches or pull requests

3 participants