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

User avatar
By kolalde
#19702 Yeah, I used reaper7 too. And printed as:

os_printf("The BMP real, rela, temp is: %lu, %lu, %lu\n",
BMP180_GetVal(GET_BMP_REAL_PRESSURE) / 100,
BMP180_GetVal(GET_BMP_RELATIVE_PRESSURE) / 100,
BMP180_GetVal(GET_BMP_TEMPERATURE)/10 * 9/5 + 32);
bmp_inch = BMP180_GetVal(GET_BMP_REAL_PRESSURE) * 100 * 300 / 10000;
os_printf("The BMP inch is: %d.%d \n", bmp_inch / 10000, bmp_inch % 10000);

I vaguely remember needing to do a little research on pressure, which led me to the above adjustments. I'll see if I can find that.
User avatar
By scargill
#19716 Thanks Cal

The only difference between your code and the printout code I have is a divide by 10 on the altitude and that still doesn't make sense.

void sensor_timerfunc(void *arg)
{
int32_t temperature;
int32_t pressure;
char buff[20];
ets_uart_printf("Get temperature and pressure...\r\n");
temperature = BMP180_GetTemperature();
pressure = BMP180_GetPressure(OSS_0);
console_printf("Temperature: %s *C\r\n", BMP180_Int2String(buff, temperature));
console_printf("Temperature: %d.%d *F\r\n", (int)(9 * temperature / 50 + 32), (int)(9 * temperature / 5 % 10));
console_printf("Pressure: %d mm rt.st.\r\n", (int)(pressure/133.322368));
console_printf("Pressure: %d m water.st.\r\n", (int)(pressure/9806.65));
console_printf("Pressure: %d.%d mbar\r\n", (int)(pressure), (int)(pressure%100));
console_printf("Pressure: %d.%d mmHg\r\n", (int)(pressure * 75 / 10000), (int)((pressure * 75 % 10000) / 1000));
console_printf("Altitude: %d\r\n", BMP180_CalcAltitude(pressure));
}


So that's the code I have - which produces an output of 101,699 mBar - which to my way of thinking is 100 * too much... and altitude of 103560 - it doesn't say WHAT unit of measure but assuming your cod is later, that would be 10, 356 - one has to assume that's 10,000 metres and that is just way out of order...

I could of course just divide the whole lot by 10,000 and get something that looks half reasonable but I'm assuming the reading is miles out for a reason?

cal wrote:But thats only the reading of the values not the printing.
Following the link in the source code lead me to

https://github.com/CHERTS/esp8266-i2c_b ... ser_main.c

Which prints the pressure in Pa which should be your 100.000 value.
Please look at your code that prints the pressure.

Cal
User avatar
By cal
#19720 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
User avatar
By torntrousers
#19723 WIth the Sparkfun BMP180 Arduino library code running on an ESP-12 with BMP180 i get a temp of 20c and pressure of 1030mb which seems about right. There are some debug printouts in the library i could uncomment if that would help show how it works out those values but i don't know how close this Arduino code compares to yours?