Hi all
In the same code i face 2 issues which cannot figure it out if you can some thoughts will be appreciated. I have already implement a BMP 280 sensor and now i am trying to do the same with a BME 680 sensor. I am using the same code modyfied accordingly.
1. In the BME 680 library i have a function called void uart_print(char *name, long x) to print out the coefficients when are going to be readed first time. Compiler comes out with the following fault:
BME680_Lib.h:444:1: error: (984) type redeclared
BME680_Lib.h:444:1: error: (1098) conflicting declarations for variable "uart_print" (BME680_Lib.h:443)
2. The pressure reading also is not as should be and cannot find the reason why.
NOTICE: The library runs perfectly on BMP 280. At the moment on the BME 680 trying to read first right Humidity,Pressure and Temperature so i have no code in there for the gas sensor. The compiler is XC8. I enclose the code, the compiling fault and a snip from my terminal. The library is only a .h file.
IF SOMEONE CAN HELP THANKS.
MAIN.c
LIBRARY
COMPILING ERROR
TERMINAL
In the same code i face 2 issues which cannot figure it out if you can some thoughts will be appreciated. I have already implement a BMP 280 sensor and now i am trying to do the same with a BME 680 sensor. I am using the same code modyfied accordingly.
1. In the BME 680 library i have a function called void uart_print(char *name, long x) to print out the coefficients when are going to be readed first time. Compiler comes out with the following fault:
BME680_Lib.h:444:1: error: (984) type redeclared
BME680_Lib.h:444:1: error: (1098) conflicting declarations for variable "uart_print" (BME680_Lib.h:443)
2. The pressure reading also is not as should be and cannot find the reason why.
NOTICE: The library runs perfectly on BMP 280. At the moment on the BME 680 trying to read first right Humidity,Pressure and Temperature so i have no code in there for the gas sensor. The compiler is XC8. I enclose the code, the compiling fault and a snip from my terminal. The library is only a .h file.
IF SOMEONE CAN HELP THANKS.
MAIN.c
C:
/******************************************************************************/
/* Files to Include */
/******************************************************************************/
#if defined(__XC)
#include <xc.h> /* XC8 General Include File */
#elif defined(HI_TECH_C)
#include <htc.h> /* HiTech General Include File */
#endif
#include <stdint.h> /* For uint8_t definition */
#include <stdbool.h> /* For true/false definition */
#include "system.h" /* System funct/params, like osc/peripheral config */
#include "user.h" /* User funct/params, such as InitApp */
#include "UART_16F1829.h"
#include "I2C_Master.h"
#include "BME680_Lib.h"
/******************************************************************************/
/* User Global Variable Declaration */
/******************************************************************************/
#define _XTAL_FREQ 8000000
#define SEALEVELHPA 1026.23
#define DHT22_PIN PORTAbits.RA0
#define DHT22_PIN_DIR TRISAbits.TRISA0
/* i.e. uint8_t <variable_name>; */
long humidity,temperature;
unsigned long pressure;
char buffer[17];
float altitude;
int8_t myID;
int Humidity, Temperature;
char temp_a[8], humi_a[8];
/******************************************************************************/
/* Main Program */
/******************************************************************************/
char dht22_read_byte()
{
char i = 8, dht22_byte = 0;
while(i--)
{
while( !DHT22_PIN );
__delay_us(40);
if( DHT22_PIN )
{
dht22_byte |= (1 << i); // set bit i
while( DHT22_PIN );
}
}
return(dht22_byte);
}
// read humidity (in hundreds rH%) and temperature (in hundreds °Celsius) from sensor
void dht22_read(int *dht22_humi, int *dht22_temp)
{
// send start signal
DHT22_PIN = 0; // connection pin output low
DHT22_PIN_DIR = 0; // configure connection pin as output
__delay_ms(25); // wait 25 ms
DHT22_PIN = 1; // connection pin output high
__delay_us(30); // wait 30 us
DHT22_PIN_DIR = 1; // configure connection pin as input
// check sensor response
while( DHT22_PIN );
while(!DHT22_PIN );
while( DHT22_PIN );
// read data
*dht22_humi = dht22_read_byte(); // read humidity byte 1
*dht22_humi = (*dht22_humi << 8) | dht22_read_byte(); // read humidity byte 2
*dht22_temp = dht22_read_byte(); // read temperature byte 1
*dht22_temp = (*dht22_temp << 8) | dht22_read_byte(); // read temperature byte 2
dht22_read_byte(); // read checksum (skipped)
if(*dht22_temp & 0x8000) // if temperature is negative
{
*dht22_temp &= 0x7FFF;
*dht22_temp *= -1;
}
}
float readAltitude(float *alt)
{
float data_alt;
data_alt = 44330.0*(1.0 - pow((1023.0/SEALEVELHPA), 0.1903));
*alt = (float)data_alt;
return 0;
}
void main(void)
{
/* Configure the oscillator for the device */
ConfigureOscillator();
// NOSC HFINTOSC; NDIV 1;
OSCCON1 = 0x60;
// CSWHOLD may proceed; SOSCPWR Low power; SOSCBE crystal oscillator;
OSCCON3 = 0x00;
// LFOEN disabled; ADOEN disabled; SOSCEN disabled; EXTOEN disabled; HFOEN disabled;
OSCEN = 0x00;
// HFFRQ 8_MHz;
OSCFRQ = 0x04;
// HFTUN 0;
OSCTUNE = 0x00;
/* Initialise I/O and Peripherals for application */
InitApp();
Initialize_UART();
I2C_Master_Init();
ANSELAbits.ANSA0 = 0;
__delay_ms(100);
UART_send_string((char*)"Testing BME 680");
UART_new_line();
__delay_ms(100);
if(BME680_begin(MODE_SLEEP, BME680_OVERSAMPLING_X1, BME680_OVERSAMPLING_X1,
BME680_OVERSAMPLING_X1, BME680_FILTER_OFF) == 0)
{
// connection error or device address wrong!
while(1); // stay here
}
__delay_ms(100);
while(1)
{
BME680_ForcedMeasurement();
__delay_ms(100);
// Read temperature (in hundreds C) and pressure (in Pa)
// values from the BMP280 sensor
BME680_readTemperature(&temperature); // read temperature
BME680_readPressure(&pressure); // read pressure
BME680_readHumidity(&humidity); // read humidity
readAltitude(&altitude);
// print data on the LCD screen
// 1: print temperature
if(temperature < 0){
sprintf(buffer, "02.02f ", (float)temperature / 100.0);
UART_send_string((char*)"temperature is:");
UART_send_char('-');
UART_send_string(buffer);
UART_send_char('C');
UART_new_line();
}
else{
sprintf(buffer, "%02.02f", (float)temperature /100.0);
UART_send_string((char*)" Temperature is:");
UART_send_string(buffer);
UART_send_char('C');
UART_new_line();
}
// 1: print pressure
sprintf(buffer, "%04.02f", (float)pressure / 100.0);
UART_send_string((char*)" Pressure is:");
UART_send_string(buffer);
UART_send_string((char*)" hPa");
UART_new_line();
// 2: print humidity
sprintf(buffer, "%04.02f", ((float)humidity/256.0)/10);
UART_send_string((char*)" Humidity is:");
UART_send_string(buffer);
UART_send_string((char*)" %");
UART_new_line();
// 3: print altitude
sprintf(buffer, "%04.02f", (float)altitude);
UART_send_string((char*)" Altitude is:");
UART_send_string(buffer);
UART_send_string((char*)" m");
UART_new_line();
// read humidity (in hundreds rH%) and temperature (in hundreds °C) from the DHT22 sensor
dht22_read(&Humidity, &Temperature);
if(Temperature < 0)
sprintf(temp_a, "-%02u.%01u%cC", abs(Temperature)/10, abs(Temperature) % 10, 223);
else
sprintf(temp_a, " %02u.%01u%cC", Temperature/10, Temperature % 10, 223);
if(Humidity >= 1000) // if humidity >= 100.0 rH%
sprintf(humi_a, "%03u.%01u %%", Humidity/10, Humidity % 10);
else
sprintf(humi_a, " %02u.%01u %%", Humidity/10, Humidity % 10);
UART_send_string((char*)" DHT22 Temperature: ");
UART_send_string(temp_a);
UART_new_line();
UART_send_string((char*)" DHT22 Humidity: ");
UART_send_string(humi_a);
__delay_ms(100);
// pause for 60 seconds then do it again...
for(int j = 0; j < 12; j++){
for(int k =0; k < 100; k++){
__delay_ms(50);
}
}
}
}
Code:
/* FILE: BME680_Lib.h */
#include "UART_16F1829.h"
#include "I2C_Master.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#if !defined BME680_I2C1 && !defined BME680_I2C2
#define BME680_I2C1
#endif
#if defined BME680_I2C1 && defined BME680_I2C2
#undef BME680_I2C2
#endif
#ifdef BME680_I2C1
#define BME680_Start I2C_Master_Start
#define BME680_Write I2C_Master_Write
#define BME680_Read I2C_Master_Read
#define BME680_Stop I2C_Master_Stop
#endif
#ifdef BME680_I2C2
#define BME680_Start I2C2_Start
#define BME680_Write I2C2_Wr
#define BME680_Read I2C2_Rd
#define BME680_Stop I2C2_Stop
#endif
#ifndef BME680_I2C_ADDRESS
#define BME680_I2C_ADDRESS (0x77 <<1)
#endif
#define BME680_CHIP_ID 0x61
#define BME680_REG_DIG_T1 0xE9
#define BME680_REG_DIG_T2 0x8A
#define BME680_REG_DIG_T3 0x8C
#define BME680_REG_DIG_P1 0x8E
#define BME680_REG_DIG_P2 0x90
#define BME680_REG_DIG_P3 0x92
#define BME680_REG_DIG_P4 0x94
#define BME680_REG_DIG_P5 0x96
#define BME680_REG_DIG_P6 0x99
#define BME680_REG_DIG_P7 0x98
#define BME680_REG_DIG_P8 0x9C
#define BME680_REG_DIG_P9 0x9E
#define BME680_REG_DIG_P10 0xA0
#define BME680_REG_DIG_H1_LSB 0xE2
#define BME680_REG_DIG_H1_MSB 0xE3
#define BME680_REG_DIG_H2_LSB 0xE2
#define BME680_REG_DIG_H2_MSB 0xE1
#define BME680_REG_DIG_H3 0xE4
#define BME680_REG_DIG_H4 0xE5
#define BME680_REG_DIG_H5 0xE6
#define BME680_REG_DIG_H6 0xE7
#define BME680_REG_DIG_H7 0xE8
#define BME680_REG_DIG_G1 0xED
#define BME680_REG_DIG_G2 0xEB
#define BME680_REG_DIG_G3 0xEE
#define BME680_REG_CHIPID 0xD0
#define BME680_REG_SOFTRESET 0xE0
#define BME680_REG_STATUS 0x73
#define BME680_REG_CTRL_HUMI 0x72
#define BME680_REG_CTRL_MEAS 0x74
#define BME680_REG_CTRL_CONFIG 0x75
#define BME680_REG_PRESS_MSB 0x1F
#define BME680_REG_RES_HEAT_RANGE 0x02
#define BME680_REG_RES_HEAT_VAL 0x00
#define BME680_REG_RANGE_ERR 0x04
int32_t adc_H, adc_T, adc_P, t_fine;
uint8_t _ctrl_meas, _ctrl_hum, _config;
char debug_buffer[10];
// BME680 sensor modes, register ctrl_meas mode[1:0]
typedef enum
{
MODE_SLEEP = 0x00, // sleep mode
MODE_FORCED = 0x01, // forced mode
} BME680_mode;
// oversampling setting. osrs_t[2:0], osrs_p[2:0]
typedef enum
{
BME680_OVERSAMPLING_SKIP = 0,
BME680_OVERSAMPLING_X1 = 1,
BME680_OVERSAMPLING_X2 = 2,
BME680_OVERSAMPLING_X4 = 3,
BME680_OVERSAMPLING_X8 = 4,
BME680_OVERSAMPLING_X16 = 5,
} BME680_sampling;
typedef enum
{
BME680_FILTER_OFF = 0,
BME680_FILTER_X1 = 1,
BME680_FILTER_X3 = 2,
BME680_FILTER_X7 = 3,
BME680_FILTER_X15 = 4,
BME680_FILTER_X31 = 5,
BME680_FILTER_X63 = 6,
BME680_FILTER_X127 = 7,
} BME680_filter;
typedef enum {
BME680_HEATER_PROFILE_0 = 0,
BME680_HEATER_PROFILE_1 = 1,
BME680_HEATER_PROFILE_2 = 2,
BME680_HEATER_PROFILE_3 = 3,
BME680_HEATER_PROFILE_4 = 4,
BME680_HEATER_PROFILE_5 = 5,
BME680_HEATER_PROFILE_6 = 6,
BME680_HEATER_PROFILE_7 = 7,
BME680_HEATER_PROFILE_8 = 8,
BME680_HEATER_PROFILE_9 = 9,
} bme680_heater_profile_t;
typedef enum {
BME680_GAS_WAIT_FACTOR_1 = 0,
BME680_GAS_WAIT_FACTOR_4 = 1,
BME680_GAS_WAIT_FACTOR_16 = 2,
BME680_GAS_WAIT_FACTOR_64 = 3,
} bme680_gas_wait_factor_t;
struct
{
uint16_t dig_T1;
uint16_t dig_T2;
uint8_t dig_T3;
uint16_t dig_P1;
uint16_t dig_P2;
uint8_t dig_P3;
uint16_t dig_P4;
uint16_t dig_P5;
uint8_t dig_P6;
uint8_t dig_P7;
uint16_t dig_P8;
uint16_t dig_P9;
uint8_t dig_P10;
uint16_t dig_H1;
uint16_t dig_H2;
uint8_t dig_H3;
uint8_t dig_H4;
uint8_t dig_H5;
uint8_t dig_H6;
uint8_t dig_H7;
uint8_t dig_G1;
uint16_t dig_G2;
uint8_t dig_G3;
uint8_t res_heat_range;
uint8_t res_heat_val;
} BME680_calib;
// writes 1 byte '_data' to register 'reg_addr'
void BME680_Write8(uint8_t reg_addr, uint8_t _data)
{
BME680_Start();
BME680_Write(BME680_I2C_ADDRESS);
BME680_Write(reg_addr);
BME680_Write(_data);
BME680_Stop();
}
// reads 8 bits from register 'reg_addr'
uint8_t BME680_Read8(uint8_t reg_addr)
{
uint8_t ret;
BME680_Start();
BME680_Write(BME680_I2C_ADDRESS);
BME680_Write(reg_addr);
BME680_Start();
BME680_Write(BME680_I2C_ADDRESS | 1);
ret = BME680_Read(0);
BME680_Stop();
return ret;
}
// reads 16 bits from register 'reg_addr'
uint16_t BME680_Read16(uint8_t reg_addr)
{
union
{
uint8_t b[2];
uint16_t w;
} ret;
BME680_Start();
BME680_Write(BME680_I2C_ADDRESS);
BME680_Write(reg_addr);
BME680_Start();
BME680_Write(BME680_I2C_ADDRESS | 1);
ret.b[0] = BME680_Read(1);
ret.b[1] = BME680_Read(0);
BME680_Stop();
return(ret.w);
}
// BME680 sensor configuration function
void BME680_Configure(BME680_mode mode, BME680_sampling H_sampling, BME680_sampling T_sampling,
BME680_sampling P_sampling, BME680_filter filter)
{
//uint8_t _ctrl_meas, _config, _ctrl_hum;
_ctrl_hum = (BME680_Read8(BME680_REG_CTRL_HUMI) | H_sampling);
_config = ((BME680_Read8(BME680_REG_CTRL_CONFIG) | filter << 2) & 0xFC);
_ctrl_meas = (T_sampling << 5) | (P_sampling << 2) | mode;
BME680_Write8(BME680_REG_CTRL_CONFIG, _config);
BME680_Write8(BME680_REG_CTRL_MEAS, _ctrl_meas);
BME680_Write8(BME680_REG_CTRL_HUMI, _ctrl_hum);
}
// initialises the BME680 sensor, returns 1 if OK and 0 if error
uint8_t BME680_begin(BME680_mode mode,
BME680_sampling H_sampling,
BME680_sampling T_sampling,
BME680_sampling P_sampling,
BME680_filter filter)
{
if(BME680_Read8(BME680_REG_CHIPID) != BME680_CHIP_ID){
UART_send_string((char*)"No sensor presence");
UART_new_line();
return 0;
}
else{
char ID_buf[20];
int8_t myID = BME680_Read8(BME680_REG_CHIPID);
sprintf(ID_buf," Sensor with ID: %X ",myID);
UART_send_string(ID_buf);
UART_send_string((char*)"is connected");
__delay_us(500);
UART_new_line();
}
// reset the BME680 with soft reset
BME680_Write8(BME680_REG_SOFTRESET, 0xB6);
__delay_ms(100);
// if NVM data are being copied to image registers, wait 100 ms
while ( (BME680_Read8(BME680_REG_STATUS) & 0x01) == 0x01 )
__delay_ms(100);
BME680_calib.dig_T1 = BME680_Read16(BME680_REG_DIG_T1);
BME680_calib.dig_T2 = BME680_Read16(BME680_REG_DIG_T2);
BME680_calib.dig_T3 = BME680_Read8(BME680_REG_DIG_T3);
BME680_calib.dig_P1 = BME680_Read16(BME680_REG_DIG_P1);
BME680_calib.dig_P2 = BME680_Read16(BME680_REG_DIG_P2);
BME680_calib.dig_P3 = BME680_Read8(BME680_REG_DIG_P3);
BME680_calib.dig_P4 = BME680_Read16(BME680_REG_DIG_P4);
BME680_calib.dig_P5 = BME680_Read16(BME680_REG_DIG_P5);
BME680_calib.dig_P6 = BME680_Read8(BME680_REG_DIG_P6);
BME680_calib.dig_P7 = BME680_Read8(BME680_REG_DIG_P7);
BME680_calib.dig_P8 = BME680_Read16(BME680_REG_DIG_P8);
BME680_calib.dig_P9 = BME680_Read16(BME680_REG_DIG_P9);
BME680_calib.dig_P10 = BME680_Read8(BME680_REG_DIG_P10);
BME680_calib.dig_H1 = ((BME680_Read8(BME680_REG_DIG_H1_MSB) <<4) | (BME680_Read8(BME680_REG_DIG_H1_LSB) & 0b00001111));
BME680_calib.dig_H2 = ((BME680_Read8(BME680_REG_DIG_H2_MSB) <<4) | (BME680_Read8(BME680_REG_DIG_H1_LSB) >>4));
BME680_calib.dig_H3 = BME680_Read8(BME680_REG_DIG_H3);
BME680_calib.dig_H4 = BME680_Read8(BME680_REG_DIG_H4);
BME680_calib.dig_H5 = BME680_Read8(BME680_REG_DIG_H5);
BME680_calib.dig_H6 = BME680_Read8(BME680_REG_DIG_H6);
BME680_calib.dig_H7 = BME680_Read8(BME680_REG_DIG_H7);
// Display calibration coefficients
uart_print("T1", BME680_calib.dig_T1);
uart_print("T2", BME680_calib.dig_T2);
uart_print("T3", BME680_calib.dig_T3);
uart_print("P1", BME680_calib.dig_P1);
uart_print("P2", BME680_calib.dig_P2);
uart_print("P3", BME680_calib.dig_P3);
uart_print("P4", BME680_calib.dig_P4);
uart_print("P5", BME680_calib.dig_P5);
uart_print("P6", BME680_calib.dig_P6);
uart_print("P7", BME680_calib.dig_P7);
uart_print("P8", BME680_calib.dig_P8);
uart_print("P9", BME680_calib.dig_P9);
uart_print("P10", BME680_calib.dig_P10);
uart_print("H1", BME680_calib.dig_H1);
uart_print("H2", BME680_calib.dig_H2);
uart_print("H3", BME680_calib.dig_H3);
uart_print("H4", BME680_calib.dig_H4);
uart_print("H5", BME680_calib.dig_H5);
uart_print("H6", BME680_calib.dig_H6);
uart_print("H7", BME680_calib.dig_H7);
BME680_Configure(mode, H_sampling, T_sampling, P_sampling,filter);
return 1;
}
// Takes a new measurement, for forced mode only!
// Returns 1 if ok and 0 if error (sensor is not in sleep mode)
uint8_t BME680_ForcedMeasurement()
{
uint8_t ctrl_meas_reg = BME680_Read8(BME680_REG_CTRL_MEAS);
if ( (ctrl_meas_reg & 0x03) != 0x00 )
return 0; // sensor is not in sleep mode
// set sensor to forced mode
BME680_Write8(BME680_REG_CTRL_MEAS, ctrl_meas_reg | 1);
// wait for conversion complete
while (BME680_Read8(BME680_REG_STATUS) & 0x08)
__delay_ms(1);
return 1;
}
// read (updates) adc_P, adc_T and adc_H from BME680 sensor
void BME680_Update()
{
union
{
uint8_t b[4];
uint32_t dw;
} ret;
ret.b[3] = 0x00;
BME680_Start();
BME680_Write(BME680_I2C_ADDRESS);
BME680_Write(BME680_REG_PRESS_MSB);
BME680_Start();
BME680_Write(BME680_I2C_ADDRESS | 1);
ret.b[2] = BME680_Read(1); //msb
ret.b[1] = BME680_Read(1); //lsb
ret.b[0] = BME680_Read(1); //xlsb
adc_P = (ret.dw >> 4) & 0xFFFFF;
ret.b[2] = BME680_Read(1); //msb
ret.b[1] = BME680_Read(1); //lsb
ret.b[0] = BME680_Read(0); //xlsb
adc_T = (ret.dw >> 4) & 0xFFFFF;
ret.b[1] = BME680_Read(1); //msb
ret.b[0] = BME680_Read(0); //lsb
BME680_Stop();
adc_H = ret.dw & 0xffff;
}
// Returns humidity in %RH as unsigned 32 bit integer in Q22.10 format (22 integer and 10 fractional bits).
// Output value of ?47445? represents 47445/1024 = 46.333 %RH
int32_t BME680_readHumidity(int32_t *hum)
{
int32_t var1 = 0, var2 = 0, var3 = 0, var4 = 0, var5 = 0, var6 = 0, H = 0, T = 0;
T = (((int32_t) t_fine * 5) + 128) >> 8;
var1 = (int32_t) adc_H - ((int32_t) ((int32_t)BME680_calib.dig_H1 << 4)) - (((T * (int32_t) BME680_calib.dig_H3) / ((int32_t)100)) >> 1);
var2 = ((int32_t)BME680_calib.dig_H2 * (((T * (int32_t)BME680_calib.dig_H4) /
((int32_t)100)) + (((T * ((T * (int32_t)BME680_calib.dig_H5) /
((int32_t)100))) >> 6) / ((int32_t)100)) + (int32_t)(1 << 14))) >> 10;
var3 = var1 * var2;
var4 = ((((int32_t)BME680_calib.dig_H6) << 7) + ((T * (int32_t) BME680_calib.dig_H7) / ((int32_t)100))) >> 4;
var5 = ((var3 >> 14) * (var3 >> 14)) >> 10;
var6 = (var4 * var5) >> 1;
H = (((var3 + var6) >>10) * ((int32_t)1000)) >>12;
*hum = H;
return 1;
}
// Reads temperature from BME680 sensor.
// Temperature is stored in hundredths C (output value of "5123" equals 51.23 DegC).
// Temperature value is saved to *temp, returns 1 if OK and 0 if error.
uint32_t BME680_readTemperature(int32_t *temp)
{
int32_t var1, var2, var3;
char t[32];
BME680_Update();
// calculate temperature
var1 = ((int32_t)adc_T >>3) - ((int32_t)BME680_calib.dig_T1 <<1);
var2 = (var1 * (int32_t)BME680_calib.dig_T2) >>11;
var3 = ((((var1 >>1) * (var1 >>1)) >>12) * ((int32_t)BME680_calib.dig_T3 <<4)) >>14;
t_fine = var2 + var3;
*temp = ((t_fine * 5) + 128) >>8;
return 1;
}
// Reads pressure from BME680 sensor.
// Pressure is stored in Pa (output value of "96386" equals 96386 Pa = 963.86 hPa).
// Pressure value is saved to *pres, returns 1 if OK and 0 if error.
uint32_t BME680_readPressure(uint32_t *press)
{
int32_t var1 = 0, var2 = 0, var3 = 0, var4 = 0;
uint32_t P = 0;
var1 = (((int32_t) t_fine) >> 1) - 64000;
var2 = ((((var1 >> 2) * (var1 >> 2)) >> 11) * (int32_t) BME680_calib.dig_P6) >> 2;
var2 = var2 + ((var1 * (int32_t)BME680_calib.dig_P5) << 1);
var2 = (var2 >> 2) + ((int32_t) BME680_calib.dig_P4 << 16);
var1 = (((((var1 >> 2) * (var1 >> 2)) >> 13) * ((int32_t) BME680_calib.dig_P3 << 5)) >> 3) + (((int32_t) BME680_calib.dig_P2 * var1) >> 1);
var1 = var1 >> 18;
var1 = ((32768 + var1) * (int32_t) BME680_calib.dig_P1) >> 15;
P = 1048576 - adc_P;
P = (int32_t)((P - (var2 >> 12)) * ((uint32_t)3125));
var4 = (1 << 30);
if(P >= var4)
P = (( P / (uint32_t) var1) << 1);
else
P = ((P << 1) / (uint32_t) var1);
var1 = ((int32_t) BME680_calib.dig_P9 * (int32_t) (((P >> 3) * (P >> 3)) >> 13)) >> 12;
var2 = ((int32_t)(P >> 2) * (int32_t) BME680_calib.dig_P8) >> 13;
var3 = ((int32_t)(P >> 8) * (int32_t)(P >> 8) * (int32_t)(P >> 8) * (int32_t)BME680_calib.dig_P10) >> 17;
P = (uint32_t)((int32_t)(P) + ((var1 + var2 + var3 + ((int32_t)BME680_calib.dig_P7 << 7)) >> 4));
*press = P;
return 0;
}
void uart_print(char *name, long x)
{
UART_send_string(name);
UART_send_string(" = ");
sprintf(debug_buffer,"%X",x);
UART_send_string();
UART_new_line();
}
// end of driver code.
Code:
BME680_Lib.h:281:1: warning: (361) function declared implicit int
BME680_Lib.h:444:1: error: (984) type redeclared
BME680_Lib.h:444:1: error: (1098) conflicting declarations for variable "uart_print" (BME680_Lib.h:443)
(908) exit status = 1
nbproject/Makefile-XC8_PIC16F1827.mk:171: recipe for target 'build/XC8_PIC16F1827/production/main.p1' failed
make[2]: Leaving directory 'C:/Users/ouzou/MPLABXProjects/PIC_16F18346 PROJECTS/PIC_16F18346_TEST.X'
nbproject/Makefile-XC8_PIC16F1827.mk:91: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/ouzou/MPLABXProjects/PIC_16F18346 PROJECTS/PIC_16F18346_TEST.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 4s)
Pressure is:1540.91 hPa
Humidity is:47.81 %
Altitude is:26.59 m
DHT22 Temperature: 21.7ßC
DHT22 Humidity: 51.4 % Temperature is:21.96C
Pressure is:1541.76 hPa
Humidity is:47.81 %
Altitude is:26.59 m
DHT22 Temperature: 21.6ßC
DHT22 Humidity: 50.5 % Temperature is:21.97C
Pressure is:1540.98 hPa
Humidity is:47.81 %
Altitude is:26.59 m
DHT22 Temperature: 21.6ßC
DHT22 Humidity: 51.7 %