I am using a Raspberry Pi 4 and Using the Bar30 and connected them by using a FT200XD USB to I2C. I am not connecting the Bar30 to the pins in the Raspberry Pi4 because i am using a Sense HAT, but I am connected it by a USB to the Raspberry Pi4. so the code in the website or in the BlueRobotics MS5837 Python Library:
import ms5837 import time sensor = ms5837.MS5837_30BA() # Default I2C bus is 1 (Raspberry Pi 3) # We must initialize the sensor before reading it if not sensor.init(): print "Sensor could not be initialized" exit(1) # Print readings while True: if sensor.read(): print("P: %0.1f mbar %0.3f psi\tT: %0.2f C %0.2f F") % ( sensor.pressure(), # Default is mbar (no arguments) sensor.pressure(ms5837.UNITS_psi), # Request psi sensor.temperature(), # Default is degrees C (no arguments) sensor.temperature(ms5837.UNITS_Farenheit)) # Request Farenheit else: print "Sensor read failed!" exit(1)
only works if the Bar30 was connecting to the pins in the Raspberry Pi4. So what is the code if i was connecting the Bar30 to the Raspberry Pi4 by USB.