def main(): # Instantiate a BMP250E instance using default i2c bus and address sensor = sensorObj.BMA250E() # For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS: # BMA250E(0, -1, 10); ## Exit handlers ## # This function stops python from printing a stacktrace when you hit control-C def SIGINTHandler(signum, frame): raise SystemExit # This function lets you run code on exit def exitHandler(): print("Exiting") sys.exit(0) # Register exit handlers atexit.register(exitHandler) signal.signal(signal.SIGINT, SIGINTHandler) x = sensorObj.new_floatp() y = sensorObj.new_floatp() z = sensorObj.new_floatp() # now output data every 250 milliseconds while (1): sensor.update() sensor.getAccelerometer(x, y, z) print("Accelerometer x:", sensorObj.floatp_value(x), end=' ') print(" y:", sensorObj.floatp_value(y), end=' ') print(" z:", sensorObj.floatp_value(z), end=' ') print(" g") # we show both C and F for temperature print("Compensation Temperature:", sensor.getTemperature(), "C /", end=' ') print(sensor.getTemperature(True), "F") print() time.sleep(.250)
def main(): # Instantiate a BMX055 instance using default i2c bus and address sensor = sensorObj.BMX055() ## Exit handlers ## # This function stops python from printing a stacktrace when you hit control-C def SIGINTHandler(signum, frame): raise SystemExit # This function lets you run code on exit def exitHandler(): print("Exiting") sys.exit(0) # Register exit handlers atexit.register(exitHandler) signal.signal(signal.SIGINT, SIGINTHandler) x = sensorObj.new_floatp() y = sensorObj.new_floatp() z = sensorObj.new_floatp() # now output data every 250 milliseconds while (1): sensor.update() sensor.getAccelerometer(x, y, z) print("Accelerometer x:", sensorObj.floatp_value(x), end=' ') print(" y:", sensorObj.floatp_value(y), end=' ') print(" z:", sensorObj.floatp_value(z), end=' ') print(" g") sensor.getGyroscope(x, y, z) print("Gyroscope x:", sensorObj.floatp_value(x), end=' ') print(" y:", sensorObj.floatp_value(y), end=' ') print(" z:", sensorObj.floatp_value(z), end=' ') print(" degrees/s") sensor.getMagnetometer(x, y, z) print("Magnetometer x:", sensorObj.floatp_value(x), end=' ') print(" y:", sensorObj.floatp_value(y), end=' ') print(" z:", sensorObj.floatp_value(z), end=' ') print(" uT") print() time.sleep(.250)
def main(): # Instantiate a BMP250E instance using default i2c bus and address sensor = sensorObj.BMG160() # For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS: # BMG160(0, -1, 10); ## Exit handlers ## # This function stops python from printing a stacktrace when you hit control-C def SIGINTHandler(signum, frame): raise SystemExit # This function lets you run code on exit def exitHandler(): print("Exiting") sys.exit(0) # Register exit handlers atexit.register(exitHandler) signal.signal(signal.SIGINT, SIGINTHandler) x = sensorObj.new_floatp() y = sensorObj.new_floatp() z = sensorObj.new_floatp() # now output data every 250 milliseconds while (1): sensor.update() sensor.getGyroscope(x, y, z) print("Gyroscope x:", sensorObj.floatp_value(x), end=' ') print(" y:", sensorObj.floatp_value(y), end=' ') print(" z:", sensorObj.floatp_value(z), end=' ') print(" degrees/s") # we show both C and F for temperature print("Compensation Temperature:", sensor.getTemperature(), "C /", end=' ') print(sensor.getTemperature(True), "F") print() time.sleep(.250)
def main(): # Instantiate a BMP250E instance using default i2c bus and address sensor = sensorObj.BMM150() # For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS: # BMM150(0, -1, 10); ## Exit handlers ## # This function stops python from printing a stacktrace when you hit control-C def SIGINTHandler(signum, frame): raise SystemExit # This function lets you run code on exit def exitHandler(): print("Exiting") sys.exit(0) # Register exit handlers atexit.register(exitHandler) signal.signal(signal.SIGINT, SIGINTHandler) x = sensorObj.new_floatp() y = sensorObj.new_floatp() z = sensorObj.new_floatp() # now output data every 250 milliseconds while (1): sensor.update() sensor.getMagnetometer(x, y, z) print("Magnetometer x:", sensorObj.floatp_value(x), end=' ') print(" y:", sensorObj.floatp_value(y), end=' ') print(" z:", sensorObj.floatp_value(z), end=' ') print(" uT") print() time.sleep(.250)