BME280 sensor.


Closed Thread
Results 1 to 20 of 20

Thread: BME280 sensor.

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627


    Did you find this post helpful? Yes | No

    Default Re: BME280 sensor.

    Richard,
    Out of curiosity, have you tried the PBP code you posted with negative temperature values?

    The reason I ask is that my temperature compensation code was pretty much exactly like yours but it went belly up as soon as the temperature went below 0°C.
    Reason mainly being the shift operations where potentially negative values (T2, T3 and therfor t_fine) are involved.

    I see you're handling the compensation values quite differently, simply pushing them into the lower 16bits of a LONG no matter if they're positive or negative. With that said, both T2 and T3 are positive in my case, like in yours, but they could potentially BE negative and then I don't think simplt stuffing the "signed short" into the lower 16bits of our LONG will work properly.

    I had to replace the affected shift operations with * and / at quite some cost for the execution time and for any compensation values specified as signed I'm doing this sort of thing:
    Code:
        ' dig_T2, signed, read to temporary variable and cast to LONG to preserve sign of value
        SHIFTIN BME280_MISO, BME280_CLK, 6, [tmp_W.BYTE0, tmp_W.BYTE1]
            IF tmp_W.15 = 1 THEN
                dig_T2 = -ABS(tmp_W)
            ELSE
                dig_T2 = tmp_W
            ENDIF
    /Henrik.

    /Henrik.

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,721


    Did you find this post helpful? Yes | No

    Default Re: BME280 sensor.

    Out of curiosity, have you tried the PBP code you posted with negative temperature values?
    sorry no, i never actually used pbp for these sensors after discovering the real potential of esp chips


    if the upper word was set appropriately here maybe that would help , adc_t might need similar treatment but the calculation should be
    then ok ,i think?

    Code:
        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]
        if  IIC_RX[3].7 then 
          T2.Byte3=255
          T2.Byte4=255
        else
          T2.Byte3=0
          T2.Byte4=0
        endif
        T3.Byte0 = IIC_RX[4]                            ' Calibration data into Signed Long
           T3.Byte1 = IIC_RX[5]
        if  IIC_RX[5].7 then 
          T3.Byte3=255
         T3.Byte4=255
       else
          T3.Byte3=0
          T3.Byte4=0
       endif
    Warning I'm not a teacher

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,721


    Did you find this post helpful? Yes | No

    Default Re: BME280 sensor.

    the calculation should be
    then ok ,i think?
    nah, pbp needs a signed shift right command too. too hard me thinks. pic chip in bin, esp wins
    Warning I'm not a teacher

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627


    Did you find this post helpful? Yes | No

    Default Re: BME280 sensor.

    For anyone who are still interested in using this sensor with PBP I've posted my code as an example in the Wiki:
    http://www.picbasic.co.uk/forum/cont...BME280-Example

    If any questions or suggestions should pop up I suggest we keep them in this thread.

    /Henrik.

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,721


    Did you find this post helpful? Yes | No

    Default Re: BME280 sensor.

    excellent work henrik, way better than my fp attempt [nearly 10k in size] to get a result.
    i confirm it gets same results temp and pressure wise as arduino calcs for same input data
    not tried hum yet
    Warning I'm not a teacher

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,721


    Did you find this post helpful? Yes | No

    Default Re: BME280 sensor.

    henrik
    i made a little change

    used this style
    IF P2.15 = 1 THEN
    p2.highWORD = 65535
    ENDIF

    for all the casts to long , it saves a worthwhile bit of code space

    can't test humidity on pic yet , just discovered the dishonest ebayer has sold me 4 out of 5 bmp280's in lieu of bme280 boards.
    i can't tell them apart with naked eye, must admit the temp seems more accurate in absolute terms for the bmp boards there is nearly a 3 deg difference between bme and bmp readings in the same aircon'ed room and thats closer to the mercury bulb . are cheap ebay things always a bit dodgy?
    Warning I'm not a teacher

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: BME280 sensor.

    "are cheap ebay things always a bit dodgy?" not in my experience, most seem surprisingly interested in protecting their feedback score. Try email seller thro ebay and explain the mistake.
    George

Similar Threads

  1. MQ-7 Sensor
    By chipmaker in forum General
    Replies: 3
    Last Post: - 9th June 2017, 00:05
  2. Speed Sensor Anyone???
    By Ramius in forum General
    Replies: 19
    Last Post: - 18th May 2012, 04:37
  3. Pir Sensor
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th May 2009, 16:34
  4. Accelerometer Sensor
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 27th August 2008, 13:26
  5. Replies: 6
    Last Post: - 18th January 2008, 08:17

Members who have read this thread : 0

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