Origin of raw temperature conversion formula

Hi,

Thanks Parrot for making these awesome products and releasing all this development info.

I’m playing around with using BLE to retrieve information from the flower power. It took me a while to figure out how to get from the raw 16 bit little endian air temperature value (as described in the flower power technical documentation) to a human readable temperature value in degrees Celsius.

Turns out this formula is used:
var temperature = 0.00000003044 * Math.pow(rawValue, 3.0) - 0.00008038 * Math.pow(rawValue, 2.0) + rawValue * 0.1149 - 30.449999999999999;

from https://github.com/sandeepmistry/node-flower-power/blob/master/index.js#L159

Where does this formula come from? Is this a common way to convert temperatures from 16 bit unsigned integers? I googled around for this but I couldn’t quite find out how or why one gets to this kind of conversion.

Many thanks,

Michael

PS: It’s worth mentioning this question pertains to the < 1.1.0 firmware “Air temperature” field, not the >= 1.1.0 “Calibrated air temperature” field, which is a 32 bit float and didn’t need any conversion mentioned above.

PPS: Further investigation leads me to believe that this formula applies a “scale factor” ( https://en.wikipedia.org/wiki/Scale_factor_(computer_science) ). I’m now wondering where this particular scaling formula, used by the flower power firmware, comes from.

Hi @michaelshmitty

Parrot have to keep his formulas private. Those used by Sandeepmistry are only approximations and I don’t know where they come from.

Bruno

Thanks Bruno,

That makes sense, cheers!

Michael