+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2013
    Posts
    11

    Default Interfacing a BME280 on a PIC18F2431

    Hello Everyone,

    I'm currently interfacing a BME280 digital humidity, pressure and temperature sensor (IC) with a 18F2431:
    https://www.bosch-sensortec.com/bst/...roducts/bme280

    I have it up and communicating, however I've come to the temperature/pressure/humidity calculations. They seem quite complex and I was hoping that someone has some experience using them with PBP?

    Do you know if the calculations are even possible with PBP?
    Does anyone have some sample code I could have a look at?

    Thanks,

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Interfacing a BME280 on a PIC18F2431

    a quick look at the data sheet yields :-
    temperature would be ok using longs
    humidity might be awkward since it uses unsigned longs that pbp cannot
    pressure would be a challenge since its done with signed 64 bit math


    options would be to use n-bit math or fire up the fp module all hard work. nice of them to not give the actual formula used just a bit of C code
    makes it difficult to assess if much accuracy would be lost using 32bit fp math.
    my solution was to use an esp8266 loaded up with the arduino esp lib and bme280 lib, find an excuse to glue one into your project
    why struggle?
    This is more entertaining than Free to Air TV

  3. #3
    Join Date
    Mar 2013
    Posts
    11

    Default Re: Interfacing a BME280 on a PIC18F2431

    Hi Richard,

    Thanks for your reply, and I do agree (I thought I'd check first!).

    This would have been used in an existing project as an upgrade to replace a DS18B20 - it looks like a good sensor just difficult to implement. I don't need the accuracy, 0.5 degree steps is all I need for temperature - but it would have been nice to have pressure and humidity.

    Some of their other sensor datasheets have better code (BMP180, BMP280), but not sure how relevant it is.
    If anyone else has some good advice using this sensor it would be welcome, however I might look into using a different platform.

    Thanks,

  4. #4
    Join Date
    Mar 2013
    Posts
    11

    Default Re: Interfacing a BME280 on a PIC18F2431

    So.. I've had a go at converting the temperature as it seems doable, I've used the equation from the datasheet (page 23).
    Unfortunately it does not work - my maths isn't great, could someone have a look and see what I've done wrong?

    I've posted the code below, and it also shows the calibration data and the raw output so you should be able to test it yourself - hint it's a bit warm in the UK at the moment


    Code:
    ' DEVICE CONFIGURATION
    
    #CONFIG
        CONFIG  OSC = IRCIO
        CONFIG  FCMEN = OFF
        CONFIG  IESO = OFF
        CONFIG  PWRTEN = OFF
        CONFIG  BOREN = OFF
        CONFIG  BORV = 20
        CONFIG  WDTEN = OFF
        CONFIG  WDPS = 512
        CONFIG  WINEN = OFF
        CONFIG  PWMPIN = OFF
        CONFIG  LPOL = HIGH           ; PWM0, 2, 4 and 6 are active-high
        CONFIG  HPOL = HIGH           ; PWM1, 3, 5 and 7 are active-high
        CONFIG  T1OSCMX = ON          ; Low-power Timer1 operation when microcontroller is in Sleep mode
        CONFIG  MCLRE = OFF
        CONFIG  STVREN = ON           ; Stack full/underflow will cause Reset
        CONFIG  LVP = OFF             ; Low-voltage ICSP disabled
        CONFIG  DEBUG = OFF           ; Background debugger disabled; RB6 and RB7 configured as general purpose I/O pins
        CONFIG  CP0 = OFF             ; Block 0 (000200-000FFFh) not code-protected
        CONFIG  CP1 = OFF             ; Block 1 (001000-001FFF) not code-protected
        CONFIG  CP2 = OFF             ; Block 2 (002000-002FFFh) not code-protected
        CONFIG  CP3 = OFF             ; Block 3 (003000-003FFFh) not code-protected
        CONFIG  CPB = OFF             ; Boot Block (000000-0001FFh) not code-protected
        CONFIG  CPD = OFF             ; Data EEPROM not code-protected
        CONFIG  WRT0 = OFF            ; Block 0 (000200-000FFFh) not write-protected
        CONFIG  WRT1 = OFF            ; Block 1 (001000-001FFF) not write-protected
        CONFIG  WRT2 = OFF            ; Block 2 (002000-002FFFh) not write-protected
        CONFIG  WRT3 = OFF            ; Block 3 (003000-003FFFh) not write-protected
        CONFIG  WRTC = OFF            ; Configuration registers (300000-3000FFh) not write-protected
        CONFIG  WRTB = OFF            ; Boot Block (000000-0001FFh) not write-protected
        CONFIG  WRTD = OFF            ; Data EEPROM not write-protected
        CONFIG  EBTR0 = OFF           ; Block 0 (000200-000FFFh) not protected from table reads executed in other blocks
        CONFIG  EBTR1 = OFF           ; Block 1 (001000-001FFF) not protected from table reads executed in other blocks
        CONFIG  EBTR2 = OFF           ; Block 2 (002000-002FFFh) not protected from table reads executed in other blocks
        CONFIG  EBTR3 = OFF           ; Block 3 (003000-003FFFh) not protected from table reads executed in other blocks
        CONFIG  EBTRB = OFF           ; Boot Block (000000-0001FFh) not protected from table reads executed in other blocks
    #ENDCONFIG
    
    ' DEFINEs
    	DEFINE	OSC	8							' Internal 8MHz
    
    
    ' Pin ALIASES
    	LED1			VAR	PORTB.0					' Orange Lights
    	GRNLED			VAR	PORTB.4					'
    	ClockPin		VAR	PORTA.6					' IIC BME280
    	DataPin			VAR	PORTA.7					' IIC BME280
    
      
    ' CONSTANTS
    
    	' --- BME280 Registers---
    	BMEADDR			CON	$EC					' Chip Address
    	ID			CON	$D0					' Chip ID (0x60)
    	ctrl_hum		CON	$F2					' Humidity Control Register
    	stat			CON	$F3					' Status Register
    	ctrl_meas		CON	$F4					' Temperature/Pressure Control Register
    	config			CON	$F5					' Cofiguration
    	cal_st_addr		CON	$88					' Calibration Start Address
    
    
    ' VARIABLES
    	FLAG			VAR	BYTE
    	IIC_RX			VAR	BYTE[8]					' IIC Received Data BME280
    
    	T1			VAR	WORD
    	T2			VAR	LONG
    	T3			VAR	LONG
    	adc_T			VAR	LONG
    	var1			VAR	LONG
    	var2			VAR	LONG
    	T			VAR	LONG
    	adc_Tr3			VAR	LONG
    	T1l1			VAR	LONG
    	T2r11			VAR	LONG
    	adc_Tr4			VAR	LONG
    	T1r12			VAR	LONG
    	T3r14			VAR	LONG
    	t_fine			VAR	LONG
    	TT			VAR	LONG
    
    
    ' INITIALIZE REGISTERS
    	OSCCON = %01110000							' Set internal osc to 8MHZ
    	ANSEL0 = %00000000							' Set to Digital PortA
    										' -HW RS232 Setup-
    	TXSTA = %00100000							' Set Transmit Register (Transmit Enabled) EUSART
    	SPBRG = %00001100							' Set Baud Rate (Dec 12) 9600 (9615 Calculated 0.16 % Error)
    										' -HW Timer Setup-
    	TMR0H = 0								' HighByte of preload value
        	TMR0L = 0								' LowByte of preload value (the order is important!)
        	INTCON.2 = 0                                				' Clear the flag bit
    	T0CON = %10000111							' Setup and Enable TMR0 (8.388s)
    	
    
    	TRISA = %00000000							' Set ports as outputs (2-4 I/P)
    	TRISB = %00000000
    	TRISC = %00000000							' Set ports as outputs
    
    
    ' PROGRAM Start
    
    	PORTA = 0								' Clear PORTA
    	PORTB = 0
    	PORTC = 0
    
    	IIC_RX = 0
    
    Init:
    	GOSUB P500								' Let everything settle
    	GOSUB VER_BME								' Is the BME280 Connected. Verify
    
    
    MAIN:
    	GOSUB GETTEMPBME							' Get the temperature reading from BME280
    	GOSUB P1
    
    	GOTO MAIN
    										' Go back to mainloop
    END
    
    
    GETTEMPBME: 
    	'I2CREAD DataPin, ClockPin, BMEADDR, stat ,[IIC_RX]			' Check to see if busy Converting Measurements, or writing data		
    	'If IIC_RX[0] != 0 THEN 						' If not, it should read as 0
    	'	GOSUB P100
    	'	GOSUB GETTEMPBME
    	'ENDIF
    
    	DO
    		IF FLAG.0 = 1 THEN GOSUB P100					' If flag is set the BME280 was not ready (Try again)
    		TOGGLE LED1
    		I2CREAD DataPin, ClockPin, BMEADDR, stat ,[IIC_RX]		' Check to see if busy Converting Measurements, or writing data	
    		FLAG.0 = 1
    	LOOP WHILE IIC_RX[0] != 0						' 
    	FLAG.0 = 0								' Clear Flag
    
    	I2CREAD DataPin, ClockPin, BMEADDR, $F7 ,[STR IIC_RX\8]			' Read Temp/Hum/Press registers
    	HSEROUT[STR IIC_RX\8,13,10]						' Data from BME280 -> 55 2F D0 82 D7 90 85 A6 0D 0A 
    	GOSUB P1
    
    	adc_T.Byte0 = IIC_RX[5]							' Store Raw Temerature data
    	adc_T.Byte1 = IIC_RX[4]
    	adc_T.Byte2 = IIC_RX[3]
    	HSEROUT[adc_T.Byte2,adc_T.Byte1,adc_T.Byte0,13,10]			' Raw Temp data -> 82 D7 90 0D 0A
    	GOSUB P1
    
    	adc_Tr3 = adc_T >> 3							' Right Shift 3
    	T1l1 = T1 << 1
    	T2r11 = T2 >> 11
    	adc_Tr4 = adc_T >> 4
    	T1r12 = T1 >>12
    	T3r14 = T3 >> 14
    
    	var1 = (adc_Tr3 - T1l1) * T2r11
    	var2 = ((adc_Tr4 - T1) * (adc_Tr4 - T1r12)) * T3r14
    	t_fine = (var1 + var2)
    	T = ((t_fine * 5) + 128)
    	TT = T >> 8
    
    	'HSEROUT[DEC TT,13,10]
    
    
    	RETURN
    
    VER_BME:
    	I2CREAD DataPin, ClockPin, BMEADDR, ID ,[IIC_RX]			' Read the BME's ID
    	IF IIC_RX[0] != $60 THEN ERROR2						' Cannot Connect to the BME280
    
    										' -Read Calibration Data for Temperature-
    	I2CREAD DataPin, ClockPin, BMEADDR, cal_st_addr ,[STR IIC_RX\6]		'
    	HSEROUT[STR IIC_RX\6,13,10]						' Display -> 6C 6E 77 66 32 00 0D 0A
    
    	T1.Byte0 = IIC_RX[0]							' Calibration data into Unsigned Word
       	T1.Byte1 = IIC_RX[1]
    	T2.Byte0 = IIC_RX[2]							' Calibration data into Signed Long
       	T2.Byte1 = IIC_RX[3]
    	T3.Byte0 = IIC_RX[4]							' Calibration data into Signed Long
       	T3.Byte1 = IIC_RX[5]
    
    										' -Initialise the Sensor-	
    	I2CWRITE DataPin, ClockPin, BMEADDR, config ,[%10101000]		' Config Setting (1000ms Standby, IIR Filter @ 4)
    	I2CWRITE DataPin, ClockPin, BMEADDR, ctrl_hum ,[%00000010]		' Humidity Setting (x2 Oversampling)
    	I2CWRITE DataPin, ClockPin, BMEADDR, ctrl_meas ,[%01001011]		' Temp/Pres Settings (x2 Oversampling, Normal Mode)
    
    	GOSUB P250
    	RETURN
    
    ERROR1:
    	DO
    		TOGGLE LED1							' Flash the Orange LED every 1/2 second
    		GOSUB P500
    	LOOP
    
    ERROR2:										' BME280 Connection Error
    	LED1 = 1
    	GOSUB P250
    	LED1 = 0
    	GOSUB P250
    	LED1 = 1
    	GOSUB P250
    	LED1 = 0
    	GOSUB P1
    	GOTO ERROR2
    
    P100:
    	PAUSE 100								' Just a pause..
    	RETURN
    
    P250:
    	PAUSE 250								' Just a pause..
    	RETURN
    
    P500:
    	PAUSE 500								' Just a pause..
    	RETURN
    
    P1:
    	PAUSE 1000								' Just a pause..
    	RETURN
    I've also taken a screenshot of the data output:
    Capture.PNG

    Thanks for having a look!

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Interfacing a BME280 on a PIC18F2431

    Not having a chip at hand to play with , substituting arraywrite for i2creads and using your figures i get
    26.12 deg with my modified code , how does this hold with reality ?



    Code:
    ' DEVICE CONFIGURATION
    
    #CONFIG
        CONFIG  OSC = IRCIO
        CONFIG  FCMEN = OFF
        CONFIG  IESO = OFF
        CONFIG  PWRTEN = OFF
        CONFIG  BOREN = OFF
        CONFIG  BORV = 20
        CONFIG  WDTEN = OFF
        CONFIG  WDPS = 512
        CONFIG  WINEN = OFF
        CONFIG  PWMPIN = OFF
        CONFIG  LPOL = HIGH           ; PWM0, 2, 4 and 6 are active-high
        CONFIG  HPOL = HIGH           ; PWM1, 3, 5 and 7 are active-high
        CONFIG  T1OSCMX = ON          ; Low-power Timer1 operation when microcontroller is in Sleep mode
        CONFIG  MCLRE = OFF
        CONFIG  STVREN = ON           ; Stack full/underflow will cause Reset
        CONFIG  LVP = OFF             ; Low-voltage ICSP disabled
        CONFIG  DEBUG = OFF           ; Background debugger disabled; RB6 and RB7 configured as general purpose I/O pins
        CONFIG  CP0 = OFF             ; Block 0 (000200-000FFFh) not code-protected
        CONFIG  CP1 = OFF             ; Block 1 (001000-001FFF) not code-protected
        CONFIG  CP2 = OFF             ; Block 2 (002000-002FFFh) not code-protected
        CONFIG  CP3 = OFF             ; Block 3 (003000-003FFFh) not code-protected
        CONFIG  CPB = OFF             ; Boot Block (000000-0001FFh) not code-protected
        CONFIG  CPD = OFF             ; Data EEPROM not code-protected
        CONFIG  WRT0 = OFF            ; Block 0 (000200-000FFFh) not write-protected
        CONFIG  WRT1 = OFF            ; Block 1 (001000-001FFF) not write-protected
        CONFIG  WRT2 = OFF            ; Block 2 (002000-002FFFh) not write-protected
        CONFIG  WRT3 = OFF            ; Block 3 (003000-003FFFh) not write-protected
        CONFIG  WRTC = OFF            ; Configuration registers (300000-3000FFh) not write-protected
        CONFIG  WRTB = OFF            ; Boot Block (000000-0001FFh) not write-protected
        CONFIG  WRTD = OFF            ; Data EEPROM not write-protected
        CONFIG  EBTR0 = OFF           ; Block 0 (000200-000FFFh) not protected from table reads executed in other blocks
        CONFIG  EBTR1 = OFF           ; Block 1 (001000-001FFF) not protected from table reads executed in other blocks
        CONFIG  EBTR2 = OFF           ; Block 2 (002000-002FFFh) not protected from table reads executed in other blocks
        CONFIG  EBTR3 = OFF           ; Block 3 (003000-003FFFh) not protected from table reads executed in other blocks
        CONFIG  EBTRB = OFF           ; Boot Block (000000-0001FFh) not protected from table reads executed in other blocks
    #ENDCONFIG
    
    ' DEFINEs
    	DEFINE	OSC	8							' Internal 8MHz
    
    
    ' Pin ALIASES
    	LED1			VAR	PORTB.0					' Orange Lights
    	GRNLED			VAR	PORTB.4					'
    	ClockPin		VAR	PORTA.6					' IIC BME280
    	DataPin			VAR	PORTA.7					' IIC BME280
    
      
    ' CONSTANTS
    
    	' --- BME280 Registers---
    	BMEADDR			CON	$EC					' Chip Address
    	ID			CON	$D0					' Chip ID (0x60)
    	ctrl_hum		CON	$F2					' Humidity Control Register
    	stat			CON	$F3					' Status Register
    	ctrl_meas		CON	$F4					' Temperature/Pressure Control Register
    	config			CON	$F5					' Cofiguration
    	cal_st_addr		CON	$88					' Calibration Start Address
    
    
    ' VARIABLES
    	FLAG			VAR	BYTE
    	IIC_RX			VAR	BYTE[8]					' IIC Received Data BME280
       i var byte
    	T1			VAR	LONG
    	T2			VAR	LONG
    	T3			VAR	LONG
    	adc_T			VAR	LONG
    	var1			VAR	LONG
    	var2			VAR	LONG
    	T			VAR	LONG
    	adc_Tr3			VAR	LONG
    '	T1l1			VAR	LONG
    '	T2r11			VAR	LONG
    '	adc_Tr4			VAR	LONG
    '	T1r12			VAR	LONG
    '	T3r14			VAR	LONG
    	t_fine			VAR	LONG
    '	TT			VAR	LONG
    
    
    ' INITIALIZE REGISTERS
    	OSCCON = %01110000							' Set internal osc to 8MHZ
    	ANSEL0 = %00000000							' Set to Digital PortA
    										' -HW RS232 Setup-
    
        
    TXSTA = $20   ' Enable transmit, BRGH = 0
    SPBRG = 51    ' 9600 Baud @ 8MHz, 0.16%
    SPBRGH = 0
    BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
    
        
        
        
        									' -HW Timer Setup-
    	TMR0H = 0								' HighByte of preload value
        	TMR0L = 0								' LowByte of preload value (the order is important!)
        	INTCON.2 = 0                                				' Clear the flag bit
    	T0CON = %10000111							' Setup and Enable TMR0 (8.388s)
    	
    
    	TRISA = %00000000							' Set ports as outputs (2-4 I/P)
    	TRISB = %00000000
    	TRISC = %00000000							' Set ports as outputs
    
    CLEAR
    ' PROGRAM Start
    
    	PORTA = 0								' Clear PORTA
    	PORTB = 0
    	PORTC = 0
    
    	IIC_RX = 0
    Init:
    	GOSUB P500								' Let everything settle
    	GOSUB VER_BME								' Is the BME280 Connected. Verify
    
    
    MAIN:
    	GOSUB GETTEMPBME							' Get the temperature reading from BME280
    	GOSUB P1
    
    	GOTO MAIN
    										' Go back to mainloop
    END
    
    
    GETTEMPBME: 
    	'I2CREAD DataPin, ClockPin, BMEADDR, stat ,[IIC_RX]			' Check to see if busy Converting Measurements, or writing data		
    	'If IIC_RX[0] != 0 THEN 						' If not, it should read as 0
    	'	GOSUB P100
    	'	GOSUB GETTEMPBME
    	'ENDIF
    
    '	DO
    '		IF FLAG.0 = 1 THEN GOSUB P100					' If flag is set the BME280 was not ready (Try again)
    '		TOGGLE LED1
    '		I2CREAD DataPin, ClockPin, BMEADDR, stat ,[IIC_RX]		' Check to see if busy Converting Measurements, or writing data	
    '		FLAG.0 = 1
    '	LOOP WHILE IIC_RX[0] != 0						' 
    '	FLAG.0 = 0								' Clear Flag
    
    '	I2CREAD DataPin, ClockPin, BMEADDR, $F7 ,[STR IIC_RX\8]			' Read Temp/Hum/Press registers
    arraywrite  IIC_RX,[ $55 ,$2F ,$D0 ,$82 ,$D7 ,$90 ,$85 ,$A6 ]
        for i=0 to  6
    	HSEROUT[hex2  IIC_RX[i],","]					
    next
        HSEROUT[hex2  IIC_RX[i],13,10]
    	GOSUB P1
    
    	
        adc_T.Byte0 = IIC_RX[5]							' Store Raw Temerature data
    	adc_T.Byte1 = IIC_RX[4]
    	adc_T.Byte2 = IIC_RX[3]
    	GOSUB P1
    
    
        
        adc_T=adc_T >> 4   'ASSUME X16 OVERSAMPLING TO MAKE SENSE OF READINGS ?
        var1 = ((((adc_T >> 3) - (T1 << 1))) * (T2)) >> 11
        var2 = (((((adc_T >> 4) - (T1)) *((adc_T >> 4) - (T1))) >>12) *(T3)) >>14
        t_fine = var1 + var2
        T = ((t_fine * 5) + 128)>>8
        HSEROUT["T " ,#T/100,".",#T//100,13,10]
       
    
    
    	
    
    
    	RETURN
    
    VER_BME:
    '	I2CREAD DataPin, ClockPin, BMEADDR, ID ,[IIC_RX]			' Read the BME's ID
    '	IF IIC_RX[0] != $60 THEN ERROR2						' Cannot Connect to the BME280
    
    '										' -Read Calibration Data for Temperature-
    '	I2CREAD DataPin, ClockPin, BMEADDR, cal_st_addr ,[STR IIC_RX\6]		'
    arraywrite  IIC_RX,[$6C ,$6E ,$77 ,$66 ,$32 ,$00] 
    for i=0 to  4
    	HSEROUT[hex2  IIC_RX[i],","]						' Display -> 6C 6E 77 66 32 00 0D 0A
    next
        HSEROUT[hex2  IIC_RX[i],13,10]
        
    	T1.Byte0 = IIC_RX[0]							' Calibration data into Unsigned Word
       	T1.Byte1 = IIC_RX[1]
    	T2.Byte0 = IIC_RX[2]							' Calibration data into Signed Long
       	T2.Byte1 = IIC_RX[3]
    	T3.Byte0 = IIC_RX[4]							' Calibration data into Signed Long
       	T3.Byte1 = IIC_RX[5]
    
    
    										' -Initialise the Sensor-	
    '	I2CWRITE DataPin, ClockPin, BMEADDR, config ,[%10101000]		' Config Setting (1000ms Standby, IIR Filter @ 4)
    '	I2CWRITE DataPin, ClockPin, BMEADDR, ctrl_hum ,[%00000010]		' Humidity Setting (x2 Oversampling)
    '	I2CWRITE DataPin, ClockPin, BMEADDR, ctrl_meas ,[%01001011]		' Temp/Pres Settings (x2 Oversampling, Normal Mode)
    
    	GOSUB P250
    	RETURN
    
    ERROR1:
    	DO
    		TOGGLE LED1							' Flash the Orange LED every 1/2 second
    		GOSUB P500
    	LOOP
    
    ERROR2:										' BME280 Connection Error
    	LED1 = 1
    	GOSUB P250
    	LED1 = 0
    	GOSUB P250
    	LED1 = 1
    	GOSUB P250
    	LED1 = 0
    	GOSUB P1
    	GOTO ERROR2
    
    P100:
    	PAUSE 100								' Just a pause..
    	RETURN
    
    P250:
    	PAUSE 250								' Just a pause..
    	RETURN
    
    P500:
    	PAUSE 500								' Just a pause..
    	RETURN
    
    P1:
    	PAUSE 1000								' Just a pause..
    	RETURN
    This is more entertaining than Free to Air TV

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Interfacing a BME280 on a PIC18F2431

    adc_T=adc_T >> 4 'ASSUME X16 OVERSAMPLING TO MAKE SENSE OF READINGS ?


    duh! now i get it, see 5.4.8 table 30 in ds
    adc_T result needs to shifted 4 bits right when read its not the oversampling
    This is more entertaining than Free to Air TV

  7. #7
    Join Date
    Mar 2013
    Posts
    11

    Default Re: Interfacing a BME280 on a PIC18F2431

    Hi Richard,

    It works really well, thanks for your help (I learned a few more tips looking through the code). I've changed the HSEROUT to use DEC and DEC2 as the decimal places were being truncated, but that is it.

    I've enabled to O/P of the DS18B20 to see what the temperature differences were as I had heard that the BME280 can have a problem with self heating:

    BME
    100100000101
    T 23.09
    DS in 9-Bit mode
    101110000
    T 23.00

    They seem quite close to me!

    I only need to convert the BME280's O/P value to 9-Bit (0.5 degree steps), and then this part is complete!

    Thanks again

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Interfacing a BME280 on a PIC18F2431

    nice to hear its a working thing ,are you using 3v vcc for bme280 ?

    I've enabled to O/P of the DS18B20 to see what the temperature differences were as I had heard that the BME280 can have a problem with self heating:
    i think they all self heat if permanently powered. mine is in an enclosure with a nodemcu ,all well ventilated yet the nodemcu affects the reading, so far it seems plausible to just calibrate the effect out.

    it should be possible to measure the self heat by
    cooling device to room temp.
    then measure temp as quickly as you can from power up for a few minutes and log results [assume rt is relatively constant]
    if it self heats you would expect a steady rise that eventually plateaus to a rt+selfheat level
    This is more entertaining than Free to Air TV

  9. #9
    Join Date
    Mar 2013
    Posts
    11

    Default Re: Interfacing a BME280 on a PIC18F2431

    Yes, everything is running at 3.3v, and the BME is set up to read the Temp/Humidity/Pressure internally every 1 second, I'll read those registers every approx 30 seconds.

    It's been running for quite a while now with is no real difference between the two sensors, so I consider that a success.
    I had read that the BME280 could be ~1 degrees out due to self heating, but that is not what I have seen here.

    Your test is something I've considered doing, especially now as everything is stable and easy to log (need to find a stable room temp..)

    duh! now i get it, see 5.4.8 table 30 in ds
    adc_T result needs to shifted 4 bits right when read its not the oversampling
    I forgot to say, nice find on the datasheet. I had read that many times, and it still didn't sink in!

Similar Threads

  1. ADC PIC18F2431 or PIC18F4431
    By mark_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th December 2010, 20:24
  2. Pcpwm pic18f2431
    By BH_epuk in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 19th May 2010, 22:36
  3. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  4. Declaring word-variables in bank15 on a pic18f2431 ?
    By BigWumpus in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 25th October 2006, 22:32
  5. PIC18F2431 Running Super SLow!!
    By Philip Biebach in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 26th July 2006, 12:03

Members who have read this thread : 14

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts