Пример #1
0
    def __init__(self,
                 main_path,
                 calfile='/calibration/Flow_Calibration.txt',
                 dp_thresh=0.0,
                 verbose=False):

        # run in verbose mode?
        self.verbose = verbose

        self.dp_thresh = dp_thresh

        # Initialize the i2c bus
        self.i2c = busio.I2C(board.SCL, board.SDA)

        # Using the adafruit_lps35hw class to read in the pressure sensor
        # note the address must be in decimal.
        # allowed addresses are:
        # 92 (0x5c - if you put jumper from SDO to Gnd)
        # 93 (0x5d - default)

        # Set up the sensors
        self.sensor2 = adafruit_lps35hw.LPS35HW(self.i2c, address=92)
        self.sensor1 = adafruit_lps35hw.LPS35HW(self.i2c, address=93)

        self.sensor1.data_rate = adafruit_lps35hw.DataRate.RATE_75_HZ
        self.sensor2.data_rate = adafruit_lps35hw.DataRate.RATE_75_HZ
        self.sensor1.low_pass_enabled = True
        self.sensor2.low_pass_enabled = True

        # Define the unit conversion factor
        self.mbar2cmh20 = 1.01972

        # Load the flow calibration polynomial coefficients
        self.main_path = main_path
        self.calfile = calfile

        # flow calibration polynomial
        if self.verbose:
            print(f"trying to load calfile at {calfile}")
        self.flowcal = np.loadtxt(self.main_path + self.calfile,
                                  delimiter='\t',
                                  skiprows=1)

        # Zero the sensors
        self.rezero()

        # Initialize the class values
        self.read()
Пример #2
0
 def detect_pressure_lps3xhw(self):
     try:
         import board
         import adafruit_lps35hw
         #device test
         self.sensor_lps35hw = adafruit_lps35hw.LPS35HW(board.I2C())
         #self.sensor_lps35hw.low_pass_enabled = True
         return True
     except:
         return False
Пример #3
0
 def detect_pressure_lps3xhw(self):
     try:
         import board
         import adafruit_lps35hw
         #device test
         self.sensor_lps35hw = adafruit_lps35hw.LPS35HW(board.I2C())
         self.sensor_lps35hw.low_pass_enabled = True
         #self.sensor_lps35hw.data_rate = adafruit_lps35hw.DataRate.RATE_1_HZ
         return True
     except:
         return False
Пример #4
0
 def __init__(self, asIntPin, enabledCams):
     #bus and hardware descriptors1
     self.i2c = busio.I2C(board.SCL, board.SDA)
     self.lps35hw = adafruit_lps35hw.LPS35HW(self.i2c)
     self.si7021 = si(smb(self.bus))
     #maybe add delay here?
     #self.lightningSensor = as3935.AS3935(asIntPin, self.bus, self.as3935Addr) #this uses a pigpio socket
     self.pi = pigpio.pi() #for general gpio, may not end up needing this
     #self.cam = multiCam(enabledCams, self.pi,[1]) #init camera board with a=fisheye, c = ir (this could go in main?)
     self.adc = Adafruit_ADS1x15.ADS1015() #init adc for wind speed+dir sensor, light intensity 
     self.rgbSensor = isl29125.ISL29125([0x0d,0x3f,0])
Пример #5
0
 def __init__(self, test_rate=10):
     self.run = True
     self.current_line = 0
     self.current_menu = 0
     self.previous_menu = 0
     self.units = 0  # 0:mmHg, 1:psi, 2:kPa
     self.button_pressed = False
     self.i2c = board.I2C()
     self.LPS35HW = adafruit_lps35hw.LPS35HW(self.i2c)
     self.LPS35HW.zero_pressure()
     self.data_rate_object = adafruit_lps35hw.DataRate
     self.LPS35HW.data_rate = self.data_rate_object.RATE_50_HZ
     self.test_lengths = [10, 20, 30]
     self.test_start_time = None
     self.test_end_time = None
     self.test_rate = test_rate  # hz
     self.last_test_screen_draw = None
     self.run_test = False
     self.controller = controller(self)
     self.controller.screen.clear_screen()
Пример #6
0
    def _init_stuff(self):

        # decouple display
        self.state_display_timeout = 1.0
        self.state_display_start = 0
        displayio.release_displays()
        i2c = board.I2C()

        display_bus = displayio.I2CDisplay(i2c, device_address=0x3D)
        self.display = adafruit_displayio_ssd1306.SSD1306(
            display_bus, width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT)

        self.min_press_str = "min: %d" % self.min_pressure
        self.high_press_str = "hi: %d" % self.high_pressure

        self.pressure_sensor = adafruit_lps35hw.LPS35HW(i2c)
        self.pressure_sensor.zero_pressure()
        self.pressure_sensor.data_rate = adafruit_lps35hw.DataRate.RATE_75_HZ

        self.pressure_sensor.filter_enabled = True
        self.pressure_sensor.filter_config = True
import board
import busio
import adafruit_lps35hw
import time
#import monitor_utils as mu

# Initialize the i2c bus
i2c = busio.I2C(board.SCL, board.SDA)

# Using the adafruit_lps35hw class to read in the pressure sensor
# note the address must be in decimal.
# allowed addresses are:
# 92 (0x5c - if you put jumper from SDO to Gnd)
# 93 (0x5d - default)

p2 = adafruit_lps35hw.LPS35HW(i2c, address=92)
p1 = adafruit_lps35hw.LPS35HW(i2c, address=93)

p1.data_rate = adafruit_lps35hw.DataRate.RATE_75_HZ
p2.data_rate = adafruit_lps35hw.DataRate.RATE_75_HZ
mbar2cmh20 = 1.01972

# Now read out the pressure difference between the sensors
print('p1_0 = ', p1.pressure, ' mbar')
print('p1_0 = ', p1.pressure * mbar2cmh20, ' cmH20')
print('p2_0 = ', p2.pressure, ' mbar')
print('p2_0 = ', p2.pressure * mbar2cmh20, ' cmH20')

print('')
print('Now zero the pressure:')
p1.zero_pressure()
Пример #8
0
import time
import board
import busio
import csv
import adafruit_lps35hw
import adafruit_si7021
from smbus import SMBus as smb
from si7021 import Si7021 as si
import requests
import umsgpack

i2c = busio.I2C(board.SCL, board.SDA)
lps35hw = adafruit_lps35hw.LPS35HW(i2c)
#si7021 = adafruit_si7021.SI7021(i2c)
si7021 = si(smb(1))
lpsTempBuf = []
siTempBuf = []
pressureBuf = []
humBuf = []

testWeatherData = {
    'command': 'test',
    'data': {
        'timeStamp': 1595817930,
        'lpsTemp': 524.28,
        'lpsPressure': -0.043701171875,
        'siTemp': 23.38866455078125,
        'relativeHumidity': 49.461883544921875,
        'lightData': {
            'r': 255,
            'g': 255,
Пример #9
0
 def __init__(self, i2c, address=0x5D):
     self.lps = LPS.LPS35HW(i2c, address=address)
     self.lps.data_rate = LPS.DataRate.RATE_75_HZ
     self.lps.low_pass = 1
     self.data = self.Data()
Пример #10
0
    def __init__(self,
                 main_path,
                 mouthpiece='hamilton',
                 dp_thresh=0.0,
                 verbose=False):

        # run in verbose mode?
        self.verbose = verbose

        self.dp_thresh = dp_thresh

        # Initialize the i2c bus
        self.i2c = busio.I2C(board.SCL, board.SDA)

        # Using the adafruit_lps35hw class to read in the pressure sensor
        # note the address must be in decimal.
        # allowed addresses are:
        # 92 (0x5c - if you put jumper from SDO to Gnd)
        # 93 (0x5d - default)

        # set up the i2c multiplexer
        self.i2cmux = adafruit_tca9548a.TCA9548A(self.i2c)

        # Set up the sensors
        self.sensor2 = adafruit_lps35hw.LPS35HW(self.i2c, address=92)
        self.sensor1 = adafruit_lps35hw.LPS35HW(self.i2c, address=93)
        self.sensor3 = adafruit_lps35hw.LPS35HW(
            self.i2cmux[0])  # this sensor is plugged into the mux on ch 0

        self.sensor1.data_rate = adafruit_lps35hw.DataRate.RATE_75_HZ
        self.sensor2.data_rate = adafruit_lps35hw.DataRate.RATE_75_HZ
        self.sensor3.data_rate = adafruit_lps35hw.DataRate.RATE_75_HZ

        self.sensor1.low_pass_enabled = True
        self.sensor2.low_pass_enabled = True
        self.sensor3.low_pass_enabled = True

        # Load the flow calibration polynomial coefficients
        self.main_path = main_path

        # define the calibration file based on the mouthpiece
        self.set_mouthpiece(mouthpiece)

        # Define the unit conversion factor
        self.mbar2cmh20 = 1.01972

        # Load the flow calibration polynomial coefficients
        self.main_path = main_path

        # initial offsets are zero
        self.p1_offset = 0.0
        self.p2_offset = 0.0
        self.p_ambient = 0.0

        # holds info about whether the sensor is initialized
        self.initialized = False

        # no flow offset initially
        self.dp_offset = 0.0

        # Zero the sensors
        self.rezero()

        # Initialize the class values
        self.read()