esp32-ble2mqtt icon indicating copy to clipboard operation
esp32-ble2mqtt copied to clipboard

Airthings Wave Plus

Open DelusionalAI opened this issue 2 years ago • 1 comments

Question Can I can break a a single characteristic into multiple values?

Additional context There are a few other projects that handle reading Airthings devices over BLE on ESP32's or rPis's (ESPHome, AirthingsMQTT, WavePlus Bridge to name a few) but I'm hoping to use esp32-blemqtt as Im already using it for other BLE devices in my house.

The problem Im having is that airthings seems to spit all the information out in one Bluetooth characteristic, and I have no idea how, if I can, split that up so they each show up in MQTT as a different value.

Can this be done, or do I just need to have something else like HA/Node Red convert the string into useful values. I believe the string is is structured like so:

    uint8_t version;
    uint8_t humidity; # X/2 for humidity in % 
    uint8_t ambientLight;
    uint8_t unused01;
    uint16_t radon; # Bq/m³
    uint16_t radon_lt; # Bq/m³
    uint16_t temperature; # X/100 for C
    uint16_t pressure; #X/50 for hPa
    uint16_t co2; # ppm
    uint16_t voc; # ppm

Here the relevant parts of my current config.json

"ble": {
   "whitelist": [
     "XX:XX:XX:XX:XX:XX"
   ],
   "services": {
     "definitions": {
	"b42e1c08-ade7-11e4-89d3-123b93f75cba": {
	 "name": "Airthings"
      }
     },
     "whitelist": [
       "b42e1c08-ade7-11e4-89d3-123b93f75cba"
     ]
   },
   "characteristics": {
     "definitions": {
	"b42e2a68-ade7-11e4-89d3-123b93f75cba": {
	  "name": "Values",
         "types": [
		"uint8_t",
		"uint8_t",
		"uint8_t",
		"uint8_t",
		"uint16_t",
		"uint16_t",
		"uint16_t",
		"uint16_t",
		"uint16_t",
		"uint16_t"]
	}
     },
     "whitelist": [
       "b42e2a68-ade7-11e4-89d3-123b93f75cba"
     ]
   }
 }

And heres a sample value currently being sent over MQTT:

1,139,14,0,8,0,50,0,146,6,215,189,226,1,122,0,0,0,222,3

DelusionalAI avatar Aug 02 '22 21:08 DelusionalAI

Hey,

The configuration you're using is, pretty much, what can be done right now. I'm using Home Assistant to extract the comma-separated values with something like what's described here. I can thing of two options to make things easier. The first is to add a characteristic value type of ignore or something that will just skip that byte. An alternative is to add a split field to the characteristic definition that will tell the application to split all values to separate MQTT topic which will probable be something like <MAC Address>/<service>/<characteristic>/X where X will be 1, 2, etc. for each value that's read. Not sure how to tackle get or set requests with this method. I can get the entire characteristic and then all values will be published but I can't do a partial set...

shmuelzon avatar Aug 04 '22 10:08 shmuelzon