void display_BMP280()
{
BMP_PWR_RC6_SetHigh();
__delay_ms(2000);
if(BMP280_begin(MODE_FORCED, SAMPLING_X1, SAMPLING_X1, FILTER_OFF, STANDBY_0_5) == 0)
{
// connection error or device address wrong!
UART_new_line();
UART_send_string((char*)" BMP280 connection error or device address wrong!");
UART_new_line();
UART_send_string((char*)" Restart device");
}
else {
UART_new_line();
UART_send_string((char*)" BMP280 connected");
}
UART_new_line();
// Read temperature (in hundreds C) and pressure (in Pa)
if(BMP280_ForcedMeasurement())
{
// values from the BMP280 sensor
BMP280_readTemperature(&temperature); // read temperature
BMP280_readPressure(&pressure); // read pressure
// print data on the screen
// 1: print temperature
if(temperature < 0){
memset(BMP_buf, '\0', sizeof(BMP_buf));
Float2Ascii ((float)temperature / 100.0, BMP_buf, 2);
UART_send_string((char*)" Temperature is:");
EUSART_Write('-');
UART_send_string(BMP_buf);
EUSART_Write('C');
UART_new_line();
}
else{
memset(BMP_buf, '\0', sizeof(BMP_buf));
Float2Ascii ((float)temperature / 100.0, BMP_buf, 2);
UART_send_string((char*)" Temperature is:");
UART_send_string(BMP_buf);
EUSART_Write('C');
UART_new_line();
}
// 2: print pressure
memset(BMP_buf, '\0', sizeof(BMP_buf));
Float2Ascii ((float)pressure / 100.0, BMP_buf, 2);
UART_send_string((char*)" Pressure is:");
UART_send_string(BMP_buf);
UART_send_string((char*)" hPa");
UART_new_line();
}
else
{
UART_send_string((char*)" Forced measurement failed!");
UART_new_line();
}
BMP_PWR_RC6_SetLow();
}