Govee/Arduino/ESP32

Started 15th August 2024

I set out to use an ESP32 to read the data broadcast from my Govee Bluetooth temperature/humidity sensors. In the Bluetooth jargon these regular transmission are called 'adverts'.

In the Arduino environment there is an example 'sketch' "Beacon Scanner", this uses the Arduino BLE library.

I found that my H5075 sensors were recognised as 'iBeacons' but the temperature/humidity data did not appear in the sketch.

The problem is that the H5075 transmits two sets of manufacturer specific data in its advertisement and only the second lot is fed back by the library function advertisedDevice.getManufacturerData();. The H5074 sends the two sets of data in separate advertisements - as long as an active scan is taking place - otherwise the H5074 only sends an iBeacon advert.

The solution is to parse the 'payload' data rather than rely on the manufacturers data. Code suitable to go in class MyAdvertisedDeviceCallbacks in the example sketch.


    int len=advertisedDevice.getPayloadLength();
    uint8_t* dp=advertisedDevice.getPayload();
    for (int i = 0; i < len; i++) 
    {
     int flen,ftype;
     flen=dp[i++]-1;
     ftype=dp[i++];
     // fdata at dp[i], size flen
     for(int j=0;j<flen;j++)
     {
       if((j+i)>=len) break; 
       Serial.printf("[%X]", dp[j+i]);
     }
     i+=flen-1;
    }

A complete sketch that prints out temperature and humidity values from Govee H5075 and H5074 sensors is available below.

Downloads:

Comments

Page last modified on August 16, 2024, at 12:16 AM
Powered by PmWiki