コード例 #1
0
## Current sea level pressure
sealevel = 1015

## END SET THESE ===============================================================

print("Starting PI drone ...")

## BMP setup
print("BMP setup ...")
bmp388_set = False
bmp388_dev = None

while not bmp388_set:
    try:
        bmp388_dev = bmp388.DFRobot_BMP388_I2C()
        bmp388_set = True
        time.sleep(3)
    except IOError:
        print("Retrying BMP setup ...")

## ATmega setup
print("ATmega setup ...")
atmega = atmega.atmega()

## IMU setup
print("IMU setup ...")
i2c_imu = None
sensor = None
imu_set = False
コード例 #2
0
#通过I2C连接bmp388和esp32
#download bmp388.py and downloadAndRun this demo

import bmp388
import time
from machine import Pin, I2C

#create I2C object
i2c = I2C(scl=Pin(22), sda=Pin(21), freq=100000)

#create I2C通信的bmp388 object
bmp388 = bmp388.DFRobot_BMP388_I2C(i2c)

#read temperature and print it
while 1:
    temp = bmp388.readTemperature()
    print("Temperature : %s" % temp)
    time.sleep(0.5)
コード例 #3
0
#   3.3v(17)        VCC
#   MOSI(19)        SDI
#   MISO(21)        SDO
#   SCLK(23)        SCK
#   GND (25)        GND
#
# BMP388_I2C_ADDR = 0x76: pin SDO is low
# BMP388_I2C_ADDR = 0x77: pin SDO is high

import bmp388
import time
import RPi.GPIO as GPIO
# If 0, connect BMP388 to SPI interface of raspberry, else connect I2C interface
if 0:
    # Create a bmp388 object to communicate with I2C.
    bmp388 = bmp388.DFRobot_BMP388_I2C(0x77)

else:
    # Define chip selection pins
    cs = 22

    # Create a bmp388 object to communicate with SPI.
    bmp388 = bmp388.DFRobot_BMP388_SPI(cs)

INT = 27
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(INT, GPIO.IN)

flag = 0