def get_press(self, ch): altimeter = ms5803py.MS5803() press, temp = altimeter.read(pressure_osr=512) """if (ch == 5): print("pressure_1="+format(press)) else: print("pressure_2="+format(press))""" return press, temp
def __init__(self, master, infologger, datalogger): self.master = master self.infologger = infologger self.datalogger = datalogger self.gps_port = "/dev/ttyACM0" self.imu_port = "/dev/ttyACM1" self.bus = smbus.SMBus(1) #@TODO TBD self.P0 = 1015 self.dictionary = dict() self.last_compass = 0 try: self.compass = mag3110.compass() self.master.status_vector["COMPASS"] = 1 except: self.infologger.write_error( "DataManager: Can't connect to compass.") self.master.status_vector["COMPASS"] = 0 try: self.compass.loadCalibration() except FileNotFoundError: self.infologger.write_error( "DataManager: Can't locate the calibration file.") self.master.status_vector["COMPASS"] = 0 try: self.altimeter = ms5803py.MS5803() self.master.status_vector["ALTIMETER"] = 1 except: self.infologger.write_error( "DataManager: Can't connect to altimeter.") self.master.status_vector["ALTIMETER"] = 0 try: self.ser_gps = serial.Serial(self.gps_port, baudrate=9600, timeout=0.5) self.master.status_vector["GPS"] = 1 except: self.infologger.write_error("DataManager: Can't connect to GPS.") self.master.status_vector["GPS"] = 0 try: self.ser_imu = serial.Serial(self.imu_port, baudrate=9600, timeout=0.5) self.master.status_vector["IMU"] = 1 except: self.infologger.write_error("DataManager: Can't connect to IMU.") self.master.status_vector["IMU"] = 0 try: self.infrared = as7262.AS7262() self.master.status_vector["INFRARED"] = 1 except: self.infologger.write_error( "DataManager: Can't connect to infrared sensor.") self.master.status_vector["INFRARED"] = 0
import ms5803py import time s = ms5803py.MS5803() while True: # Do the batteries-included version, optionally specifying an OSR. press, temp = s.read(pressure_osr=512) print("quick'n'easy pressure={} mBar, temperature={} C".format( press, temp)) # Use the raw reads for more control, e.g. you need a faster sample # rate for pressure than for temperature. Use a high OverSampling Rate (osr) # value for a slow but accurate temperature read, and a low osr value # for quick and inaccurate pressure readings. raw_temperature = s.read_raw_temperature(osr=4096) for i in range(5): raw_pressure = s.read_raw_pressure(osr=256) press, temp = s.convert_raw_readings(raw_pressure, raw_temperature) print("advanced pressure={} mBar, temperature={} C".format( press, temp)) time.sleep(1)
def setUp(self): self.ms5803 = ms5803py.MS5803()
def __init__(self) -> None: self.MS5803 = ms5803py.MS5803(address=0x76)