Bluetooth-Devices / bthome-ble

Parser for BTHome BLE devices
https://bthome.io/
MIT License
79 stars 16 forks source link

Electrical Conductivity (σ) #141

Closed darkfader closed 3 months ago

darkfader commented 3 months ago

I would like to see a unit for Electrical Conductivity (EC) because it's pretty important to know to let crops grow optimally (aside from temperature and moisture content).

The unit for EC is often expressed in milliSiemens/centimeter (mS/cm) or dS/m. Example list for good soil EC for crops can be found here: https://www.seeedstudio.com/blog/2022/07/15/soil-electrical-conductivity/ (showing ranges between 0.3 mS/cm between 3.5 mS/cm)

As for the encoding in the packet, I think an unsigned 16 bit and a factor of 0.0001 S/m would be good for most cases, resulting in a unit of µS/cm.

Some example conversions:

So for a crop in a soil of 0.55 mS/cm could be encoded as: (0.55 milliSiemens per centimeter) / (0.0001 Siemens per meter) = 550

Seawater/salt-aquarium at 4.8 S/m to 5.3 S/m as: (4.8 Siemens per meter) / (0.0001 Siemens per meter) = 48000

Tap water at 200 to 800 µS/cm (500 microSiemens per centimeter) / (0.0001 Siemens per meter) = 500

Demineralised water 0.1 to 1.0 μS/cm (no real use-case I think) (1.0 microSiemens per centimeter) / (0.0001 Siemens per meter) = 1

I guess the value of max uint16 will indicate out of range? Temperature correction (if wanted) could be done in post processing (depends on soil type of course) but often not needed.

darkfader commented 3 months ago

I saw that the scale was already in "µS/cm", my intended unit; so scale can just be 1. I created a PR. (Also a PR for core/bthome)

Ernst79 commented 3 months ago

Added in 3.11.0