def main(): # Instantiate a BME280 instance using default i2c bus and address sensor = sensorObj.BME280() # For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS: # BME280(0, -1, 10); ## Exit handlers ## # This function stops python from printing a stacktrace when you hit control-C def SIGINTHandler(signum, frame): raise SystemExit # This function lets you run code on exit def exitHandler(): print "Exiting" sys.exit(0) # Register exit handlers atexit.register(exitHandler) signal.signal(signal.SIGINT, SIGINTHandler) while (1): sensor.update() print "Compensation Temperature:", sensor.getTemperature(), "C /", print sensor.getTemperature(True), "F" print "Pressure: ", sensor.getPressure(), "Pa" print "Computed Altitude:", sensor.getAltitude(), "m" print "Humidity:", sensor.getHumidity(), "%RH" print time.sleep(1)
bmeAddr = 0x77 # i2c bus 6 on mini breakout bus6 = 6 mplAddr = 0x60 bmpAddr = 0x77 localAlt = 189.5 UPPER_TEMP = 0x02 LOWER_TEMP = 0x03 CRIT_TEMP = 0x04 # create sensors on the bus 1 si = pyupm_si114x.SI114X(bus1) mcp = pyupm_mcp9808.MCP9808(bus1) bme = pyupm_bmp280.BME280(bus1) #si = pyupm_si114x.SI114X(bus1, siAddr) #mcp = pyupm_mcp9808.MCP9808(bus1, mcpAddr) #bme = pyupm_bmp280.BME280(bus1, bmeAddr) # create sensors on the bus 6 mpl = pyupm_mpl3115a2.MPL3115A2(bus6) bmp = pyupm_bmp280.BMP280(bus6) #mpl = pyupm_mpl3115a2.MPL3115A2(bus6, mplAddr) #bmp = pyupm_bmp280.BMP280(bus6, bmpAddr) #Activate some sensors #--------------------- mcp.shutDown(False) si.initialize()
# The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import time, sys, signal, atexit import pyupm_bmp280 as sensorObj # Instantiate a BME280 instance using default i2c bus and address sensor = sensorObj.BME280() # For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS: # BME280(0, -1, 10); ## Exit handlers ## # This function stops python from printing a stacktrace when you hit control-C def SIGINTHandler(signum, frame): raise SystemExit # This function lets you run code on exit def exitHandler(): print "Exiting" sys.exit(0)