Reverse engineering a BLE CO₂ sensor part II

<Back

2025-03-12

This is part II, see part I for context

I last stopped when getting my BLE network logs with wireshark. I had immediately spent some time trying to find patterns to decode the environment data, and I did find ways to decode the temperature, humidity and CO₂ level.

Then I forgot about this project and moved on with my life until tonight, when I decided to point Claude Code at the directory and tell it to finish the project.

And boy did it deliver! Here's more or less how the 1 hour experiment went:

  1. It first started by re-running some script I had (and didn't work) to connect to the device.
  2. It fixed the scripts, and wrote a new one that enumerated all the BLE commands.
  3. Then honestly I lost track of what it did. I decided to give it the BLE log file.
  4. It said "oh yeah that's useful" then wrote a python script to actually parse the file and deduce the patterns autonomously
  5. Found all the patterns and wrote a scipt that polls the device

During that time I turned the device on and off to make sure it was in pairing mode before Claude ran the scripts. Then I saw this in my terminal:

===== PACKET ANALYSIS =====
Raw data (hex): 7b 41 00 0c 41 44 02 03 b6 15 3c 01 01 2a fc 7d
Raw data (bytes): bytearray(b'{A\x00\x0cAD\x02\x03\xb6\x15<\x01\x01*\xfc}')
Packet type: 0x0c (position 3-4)

Detailed packet breakdown:
  Header: 0x7b4100 (position 0-3)
  Type:   0x0c (position 3-4)
  Subtype: 0x414402 (position 4-7)
  🌡️ ENVIRONMENTAL DATA PACKET
  CO2 data: 0x03b6 (position 7-9)
  Temp data: 0x15 (position 9-10)
  Humidity data: 0x3c (position 10-11)
  Additional data: 0x01012afc

📊 DECODED VALUES:
  CO2: 950 ppm ✅
  Temperature: 21°C ✅
  Humidity: 60% ✅
  ✅ Valid environmental reading

✅ VALID READINGS SUMMARY:
Reading 1: CO2: 950 ppm, Temperature: 21°C, Humidity: 60%

Honestly I wasn't far from hyperventilating, and I'm not sure if it was due to the high CO₂ level or the fact I just realised the world will never be the same.

Next step I'll be asking it to make it a Home-Assistant extension, but at this stage I might as well ask it do fill my tax return.