BME280 sensor.


Closed Thread
Results 1 to 20 of 20

Thread: BME280 sensor.

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: BME280 sensor.

    henrik here is a json dump from my nodemcu/bme280 regs from 0x80 to 0xff
    {"bme":144,111,137,51,54,42,151,6,185,109,247,104, 50,0,61,148,200,214,208,11,181,32,73,255,249,255,1 72,38,10,216,189,16,0,75,61,0,0,0,0,0,0,0,0,0,51,0 ,0,192,0,84,0,0,0,0,96,2,0,1,255,255,31,78,8,0,0,6 4,183,255,0,0,0,0,5,0,0,0,0,0,0,0,96,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,101,1,0,20,43,3,30,189,65,255,2 55,255,255,255,255,255,0,5,12,183,0,0,72,115,224,1 26,150,48,112,242,128} and the highlighted corresponding readings
    {"pressure":1011,"roomt":22.06,"humidity":42,"setpoint":27,"damper":1800,"state":1,"fire":21," bv":1340}

    ps
    hope it's ok looks like forum is not json friendly
    Last edited by richard; - 5th October 2020 at 03:47.
    Warning I'm not a teacher

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: BME280 sensor.

    Thank you Richard, that did help.

    I've got pressure working as well.
    Temperature is within 0.05°C and pressure is within 1Pa compared to a commercially available BME280 based sensor module.
    I thought I had humidity working although it read about 7% off compared to "real" one but today the difference is 30% so there must be something wrong still.

    Will look at that later and hopefully be able to post some code.

    But geez, these LONG math operatations eats away code space, 8k at the moment.

    /Henrik.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: BME280 sensor.

    There is always the possibility that humidity sensor may not had time to sense the environment. Or the other reference sensor is in a bit different position and gives wrong measures.

    In my experience, humidity sensors are not very trusty.

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


    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.

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


    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

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


    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

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    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.

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 : 2

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