-
Notifications
You must be signed in to change notification settings - Fork 66
Add Govee H5140 Smart CO2 Monitor #684
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
Conversation
Adds support for the Govee H5140 Smart CO2 Monitor, which broadcasts temperature, humidity, and CO2 readings via BLE manufacturer data. Device identification: - Advertisement name pattern: GV5140XXXX - Manufacturer data: 20 hex characters (10 bytes) Data format (hex positions): - 0-7: Header (01000101) - 8-13: 24-bit combined temp/humidity value - 14-17: 16-bit CO2 in ppm (big-endian) - 18-19: Padding Decoding: - Temperature (°C): 24bit_value / 10000 - Humidity (%): (24bit_value % 1000) / 10 - CO2 (ppm): 16bit_value directly Tested with device GV5140A2D6 (MAC: 3C:DC:75:13:A2:D6) via OpenMQTTGateway on ESP32.
Add compound condition to verify: - Device name contains 'GV5140' - Manufacturer data length >= 20 hex chars - Manufacturer data starts with '01000101' header This prevents false matches against other devices' data.
The enum must match the order of entries in the devices array.
Live BLE Advertisement SamplesHere are some raw manufacturer data samples captured from a real H5140 device, along with the corresponding display readings for validation:
Decoding verificationTaking
Data captured using OpenMQTTGateway on ESP32 with raw advertisement publishing enabled. |
Related IssuesThis decoder addresses requests from the community for H5140 support:
The BLE Monitor issue contains additional reverse engineering notes and device information that informed this implementation. |
|
Many thanks @bafulton Ould you change and add the following to this PR to to allow for correct Home Assistant MQTT discovery of the CO2 value. If you are unsure about the last point I can add the test cases once you have addressed the first three points and this has been merged. |
- Change tag from 0301 to 0f02 (AIR sensor classification) - Rename co2 property to carbon_dioxide for HA MQTT discovery - Add documentation page 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
@DigiH thanks for the quick and thorough review feedback! All good callouts. I've made the following changes:
Ready for another review when you have time! |
|
|
H5140 uses a device-specific header (01000101) like H5179_N, not the standard Govee company ID (88ec). Since there's no company ID check in the condition, the decoder output doesn't include cidc. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Also, any idea when the next release will go out? I'm pretty excited to see some CO2 data in HA! 😁 |
My bad, this should actually be "tag":0f03"`, as "cidc":false, should actually still remain ;) in the regression tests as well.
What are you actually using the decoder with, OpenMQTTGateway on an ESP32 or Theengs Gateway? |
|
I took the liberty to make that last correction so I can merge your PR. It will then also be included in the latest OpenMQTTGateway nightly development build, which you can install at https://docs.openmqttgateway.com/dev/upload/web-install.html |
|
@DigiH awesome! I wondered re the cidc piece--I thought they should've been in there, but I couldn't get the tests to work with them in. Thanks for sorting it out for me!
I'm using OpenMQTTGateway on an ESP32. I bumped to develop and it all just worked. I've got sensor data now. 🥳 |
The H5140 decoder PR (theengs/decoder#684) has been merged and is now working in OpenMQTTGateway. The research and planning doc is no longer needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Description:
Adds decoder support for the Govee H5140 Smart CO2 Monitor, which broadcasts temperature, humidity, and CO2 readings via BLE manufacturer data advertisements.
Device Information
Data Format
The H5140 broadcasts 10 bytes (20 hex characters) of manufacturer data:
01000101)Decoding Formulas
24bit_value / 10000(24bit_value % 1000) / 1016bit_value(direct reading)Example
Raw data:
0100010103fcbf044c000100010103fcbf= 261311 decimal044c= 1100 ppmTesting
Tested with an H5140 device using OpenMQTTGateway on ESP32. Decoded values match the device's LCD display readings.
This device uses the same encoding scheme as other Govee temperature/humidity sensors (H5072, H5075, etc.) for the temp/humidity portion, with an additional CO2 field.
Checklist: