示例#1
0
def Pressure():
    try:
        import ms5837
        pressure = ms5837.MS5837()
        # Call update so it can try writing some bytes
        # It should fail fast when not connected
        pressure.update()
        return pressure
    except Exception as e:
        print "Failed to Initialize BlueRobotics Bar30 Pressure Sensor"
        print "Error: %s" % e.message
        print "Using Mock Pressure Sensor"
        from Pressure_Mock import Pressure as Pressure_Mock
        return Pressure_Mock()
示例#2
0
    def __init__(self):
        rospy.init_node('pressure_node')

        self.pub_pressure = rospy.Publisher('sensors/pressure',
                                            FluidPressure,
                                            queue_size=1)

        self.pub_temp = rospy.Publisher('sensors/temperature',
                                        Temperature,
                                        queue_size=1)

        self.ms5837 = ms5837.MS5837(model=ms5837.MODEL_30BA)
        if not self.ms5837.init():
            rospy.logfatal(
                'Failed to initialise MS5837! Is the sensor connected?')
        else:
            if not self.ms5837.read():
                rospy.logfatal('Failed to read MS5837!')
            else:
                rospy.loginfo('Successfully initialised MS5837')
        self.talker()
示例#3
0
import tsys01, ms5837
import sdcard, os
from machine import I2C, SPI
from machine import Pin

SCL = 22
SDA = 23

i2c = I2C(-1, Pin(SCL), Pin(SDA))

p = ms5837.MS5837(model='MODEL_30BA', i2c=i2c)
t = tsys01.TSYS01(i2c)

p.init()

temp_acc = t.getTemp()
temp, pressure, depth = p.get_measurement()

print(temp_acc)
print(temp, pressure, depth)

sck = Pin(5)
mosi = Pin(18)
miso = Pin(19)
cs = Pin(14, Pin.OUT)
spi2 = SPI(2, baudrate=5000000, sck=sck, mosi=mosi, miso=miso)

sd = sdcard.SDCard(spi2, cs)
os.mount(sd, '/sd')
output = os.listdir('/sd')
print(output)