Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By scargill
#19726 Cal

That seems better and thank you for that - amazingly in 2 revisions of that software no-one seemed to spot it...

Get temperature and pressure...
Temperature: 26.3 *C
Temperature: 79.3 *F
Pressure: 763 mm rt.st.
Pressure: 10 m water.st.
Pressure: 1018.57 mbar
Pressure: 763.9 mmHg
Altitude: 103717

Working back from mmHG that seems right and the maths looks right so there's a good chance that's a fix.

The altitude however remains an enigna - what's that - metres from the centre of the earth? Any ideas anyone?

According to Google, where I am in Wark, in Northumberland is 93 metres or 307ft above sea level.

Here's the function in the original code - I've no idea what that F is for....


int32_t ICACHE_FLASH_ATTR BMP180_CalcAltitude(int32_t pressure)
{
return (int32_t)(pow(((float)MYALTITUDE/44330)+1,5.255F)*pressure);
}

Thoughts anyone?


cal wrote:Moin,

looking at the spec http://www.adafruit.com/datasheets/BST- ... 000-09.pdf they used the standard
formula in BMP180_GetPressure which returns Pa.
Wikipedia tells us:
Code: Select allCommon multiple units of the pascal are the hectopascal (1 hPa ≡ 100 Pa) which is equal to 1 mbar, the kilopascal (1 kPa ≡ 1000 Pa), the megapascal (1 MPa ≡ 1,000,000 Pa), and the gigapascal (1 GPa ≡ 1,000,000,000 Pa).


So to get from Pa to mbar you have to divide by 100.
That means the line
Code: Select allconsole_printf("Pressure: %d.%d mbar\r\n", (int)(pressure), (int)(pressure%100));

must read
Code: Select allconsole_printf("Pressure: %d.%d mbar\r\n", (int)(pressure/100), (int)(pressure%100));


Cal