Code Monkey home page Code Monkey logo

bme680-micropython's Introduction

Micropython Driver for a BME680 breakout

This a port of an Adafruit driver for use with micropython.org based and Pycom.io devices using the respecitve MicroPython variant.

The driver uses the I2C interface. The sensor also supports SPI mode, which is not supported by this driver yet, but can easily be extended.

Sample usage files:

# I2C Interface, genuine Micropython

from bme680 import *
from machine import I2C, Pin
import time
bme = BME680_I2C(I2C(-1, Pin(13), Pin(12)))

for _ in range(3):
    print(bme.temperature, bme.humidity, bme.pressure, bme.gas)
    time.sleep(1)
# SPI Interface, genuine Micropython

from bme680 import *
from machine import SPI, Pin
import time

cs = Pin(15, Pin.OUT, value=1)
spi = SPI(-1, baudrate=400000, sck=Pin(12), mosi=Pin(13), miso=Pin(14))
bme = BME680_SPI(spi, cs)

for _ in range(3):
    print(bme.temperature, bme.humidity, bme.pressure, bme.gas)
    time.sleep(1)
# I2C Interface, Pycom devices
# Using the default Pins P9 for sda and P10 for scl

from bme680 import *
from machine import I2C, Pin
import time
cs=Pin("P11", Pin.OUT, value=1)
bme = BME680_I2C(I2C())

for _ in range(3):
    print(bme.temperature, bme.humidity, bme.pressure, bme.gas)
    time.sleep(1)
# SPI Interface, Pycom devices

from bme680 import *
from machine import SPI, Pin
import time

cs = Pin("P11", Pin.OUT, value=1)
spi = SPI(0, mode=SPI.MASTER, baudrate=400000, pins=("P10", "P9", "P8"))
bme = BME680_SPI(spi, cs)

for _ in range(3):
    print(bme.temperature, bme.humidity, bme.pressure, bme.gas)
    time.sleep(1)

Files:

bme680.py: Drivers using floating point arithmetic
bme680i.py: Driver using integer arithmentic for the internal calculations according to the BOSCH datasheet. Only for the final result floating point operations are used.
bmetest.py: Sample test script
readme.md: This file

bme680-micropython's People

Contributors

robert-hh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.