1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

SPI Code for BME280

Discussion in 'Oshonsoft' started by Superdat, Nov 29, 2017.

  1. Superdat

    Superdat Member

    Mar 3, 2015
    This a partial solution for anyone who is trying to use the BMe280. The Pressure/ Temperature part is very similar if not identical for BMP180/280.

    With reference to the Datahseet there are two problems within the code:
    Most of the data uses signed 32 and 16 bit variables which Oshonsoft does not have.
    It also uses Floats(Single) whivh Oshonsoft does have but I didn't find this very helpful.
    I've also been trying GCB which has 16 bit signed but no Floats, again with limited success.
    2: The equations used to calculated Pressure/Temp and Hum are horrendously complex, especially Pressure.
    This makes it extremely difficult to figure out a work around for the variables issue.

    The attacked code achieves the following:
    Writes Configuration data
    Can Read all Registers
    Chip id, Calibration and P,T & H data etc.
    Temperature works for + numbers (thanks to MMotte on the GCB forum for the Temp equation).
    Humidity works but is wildly inaccurate, it shows 10% when it is about 42%
    I've not done anything with Pressure (MMotte is working on it) because the calculations won't fit on a 16f887.
    This was done initally with GCB and converted to Oshonsoft.

    Proton Basic as all the required variables, has working I2C code which I've modified for SPI, it does everything but won't read PT & H data so another brick wall.

    Good Luck

    Attached Files:

Share This Page