From 42354378302e48cf87c24a674defed906407d218 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Fri, 13 Jan 2023 00:10:59 +0000 Subject: [PATCH 01/40] Initial integration of BerryIMU code --- BerryIMU/IMU.py | 291 ++++++++++++++++++++++++++++++++++++++++ BerryIMU/LIS3MDL.py | 29 ++++ BerryIMU/LSM6DSL.py | 45 +++++++ BerryIMU/LSM9DS0.py | 87 ++++++++++++ BerryIMU/LSM9DS1.py | 94 +++++++++++++ berryIMU+data logger.py | 215 +++++++++++++++++++++++++++++ logs/.gitkeep | 0 7 files changed, 761 insertions(+) create mode 100644 BerryIMU/IMU.py create mode 100644 BerryIMU/LIS3MDL.py create mode 100644 BerryIMU/LSM6DSL.py create mode 100644 BerryIMU/LSM9DS0.py create mode 100644 BerryIMU/LSM9DS1.py create mode 100644 berryIMU+data logger.py create mode 100644 logs/.gitkeep diff --git a/BerryIMU/IMU.py b/BerryIMU/IMU.py new file mode 100644 index 0000000..fa6f0c7 --- /dev/null +++ b/BerryIMU/IMU.py @@ -0,0 +1,291 @@ +import smbus +bus = smbus.SMBus(1) +from LSM9DS0 import * +from LSM9DS1 import * +from LSM6DSL import * +from LIS3MDL import * +import time + + + + +BerryIMUversion = 99 + + + + + +def detectIMU(): + #Detect which version of BerryIMU is connected using the 'who am i' register + #BerryIMUv1 uses the LSM9DS0 + #BerryIMUv2 uses the LSM9DS1 + #BerryIMUv3 uses the LSM6DSL and LIS3MDL + + global BerryIMUversion + + + try: + #Check for BerryIMUv1 (LSM9DS0) + #If no LSM9DS0 is connected, there will be an I2C bus error and the program will exit. + #This section of code stops this from happening. + LSM9DS0_WHO_G_response = (bus.read_byte_data(LSM9DS0_GYR_ADDRESS, LSM9DS0_WHO_AM_I_G)) + LSM9DS0_WHO_XM_response = (bus.read_byte_data(LSM9DS0_ACC_ADDRESS, LSM9DS0_WHO_AM_I_XM)) + except IOError as e: + print('') #need to do something here, so we just print a space + else: + if (LSM9DS0_WHO_G_response == 0xd4) and (LSM9DS0_WHO_XM_response == 0x49): + print("Found BerryIMUv1 (LSM9DS0)") + BerryIMUversion = 1 + + + try: + #Check for BerryIMUv2 (LSM9DS1) + #If no LSM9DS1 is connnected, there will be an I2C bus error and the program will exit. + #This section of code stops this from happening. + LSM9DS1_WHO_XG_response = (bus.read_byte_data(LSM9DS1_GYR_ADDRESS, LSM9DS1_WHO_AM_I_XG)) + LSM9DS1_WHO_M_response = (bus.read_byte_data(LSM9DS1_MAG_ADDRESS, LSM9DS1_WHO_AM_I_M)) + + except IOError as f: + print('') #need to do something here, so we just print a space + else: + if (LSM9DS1_WHO_XG_response == 0x68) and (LSM9DS1_WHO_M_response == 0x3d): + print("Found BerryIMUv2 (LSM9DS1)") + BerryIMUversion = 2 + + try: + #Check for BerryIMUv3 (LSM6DSL and LIS3MDL) + #If no LSM6DSL or LIS3MDL is connected, there will be an I2C bus error and the program will exit. + #This section of code stops this from happening. + LSM6DSL_WHO_AM_I_response = (bus.read_byte_data(LSM6DSL_ADDRESS, LSM6DSL_WHO_AM_I)) + LIS3MDL_WHO_AM_I_response = (bus.read_byte_data(LIS3MDL_ADDRESS, LIS3MDL_WHO_AM_I)) + + except IOError as f: + print('') #need to do something here, so we just print a space + else: + if (LSM6DSL_WHO_AM_I_response == 0x6A) and (LIS3MDL_WHO_AM_I_response == 0x3D): + print("Found BerryIMUv3 (LSM6DSL and LIS3MDL)") + BerryIMUversion = 3 + time.sleep(1) + + + + + + + + + + + + + + +def writeByte(device_address,register,value): + bus.write_byte_data(device_address, register, value) + + + +def readACCx(): + acc_l = 0 + acc_h = 0 + if(BerryIMUversion == 1): + acc_l = bus.read_byte_data(LSM9DS0_ACC_ADDRESS, LSM9DS0_OUT_X_L_A) + acc_h = bus.read_byte_data(LSM9DS0_ACC_ADDRESS, LSM9DS0_OUT_X_H_A) + elif(BerryIMUversion == 2): + acc_l = bus.read_byte_data(LSM9DS1_ACC_ADDRESS, LSM9DS1_OUT_X_L_XL) + acc_h = bus.read_byte_data(LSM9DS1_ACC_ADDRESS, LSM9DS1_OUT_X_H_XL) + elif(BerryIMUversion == 3): + acc_l = bus.read_byte_data(LSM6DSL_ADDRESS, LSM6DSL_OUTX_L_XL) + acc_h = bus.read_byte_data(LSM6DSL_ADDRESS, LSM6DSL_OUTX_H_XL) + + acc_combined = (acc_l | acc_h <<8) + return acc_combined if acc_combined < 32768 else acc_combined - 65536 + + + + + + +def readACCy(): + acc_l = 0 + acc_h = 0 + if(BerryIMUversion == 1): + acc_l = bus.read_byte_data(LSM9DS0_ACC_ADDRESS, LSM9DS0_OUT_Y_L_A) + acc_h = bus.read_byte_data(LSM9DS0_ACC_ADDRESS, LSM9DS0_OUT_Y_H_A) + elif(BerryIMUversion == 2): + acc_l = bus.read_byte_data(LSM9DS1_ACC_ADDRESS, LSM9DS1_OUT_Y_L_XL) + acc_h = bus.read_byte_data(LSM9DS1_ACC_ADDRESS, LSM9DS1_OUT_Y_H_XL) + elif(BerryIMUversion == 3): + acc_l = bus.read_byte_data(LSM6DSL_ADDRESS, LSM6DSL_OUTY_L_XL) + acc_h = bus.read_byte_data(LSM6DSL_ADDRESS, LSM6DSL_OUTY_H_XL) + + acc_combined = (acc_l | acc_h <<8) + return acc_combined if acc_combined < 32768 else acc_combined - 65536 + + +def readACCz(): + acc_l = 0 + acc_h = 0 + if(BerryIMUversion == 1): + acc_l = bus.read_byte_data(LSM9DS0_ACC_ADDRESS, LSM9DS0_OUT_Z_L_A) + acc_h = bus.read_byte_data(LSM9DS0_ACC_ADDRESS, LSM9DS0_OUT_Z_H_A) + elif(BerryIMUversion == 2): + acc_l = bus.read_byte_data(LSM9DS1_ACC_ADDRESS, LSM9DS1_OUT_Z_L_XL) + acc_h = bus.read_byte_data(LSM9DS1_ACC_ADDRESS, LSM9DS1_OUT_Z_H_XL) + elif(BerryIMUversion == 3): + acc_l = bus.read_byte_data(LSM6DSL_ADDRESS, LSM6DSL_OUTZ_L_XL) + acc_h = bus.read_byte_data(LSM6DSL_ADDRESS, LSM6DSL_OUTZ_H_XL) + + acc_combined = (acc_l | acc_h <<8) + return acc_combined if acc_combined < 32768 else acc_combined - 65536 + + +def readGYRx(): + gyr_l = 0 + gyr_h = 0 + if(BerryIMUversion == 1): + gyr_l = bus.read_byte_data(LSM9DS0_GYR_ADDRESS, LSM9DS0_OUT_X_L_G) + gyr_h = bus.read_byte_data(LSM9DS0_GYR_ADDRESS, LSM9DS0_OUT_X_H_G) + elif(BerryIMUversion == 2): + gyr_l = bus.read_byte_data(LSM9DS1_GYR_ADDRESS, LSM9DS1_OUT_X_L_G) + gyr_h = bus.read_byte_data(LSM9DS1_GYR_ADDRESS, LSM9DS1_OUT_X_H_G) + elif(BerryIMUversion == 3): + gyr_l = bus.read_byte_data(LSM6DSL_ADDRESS, LSM6DSL_OUTX_L_G) + gyr_h = bus.read_byte_data(LSM6DSL_ADDRESS, LSM6DSL_OUTX_H_G) + + gyr_combined = (gyr_l | gyr_h <<8) + return gyr_combined if gyr_combined < 32768 else gyr_combined - 65536 + + +def readGYRy(): + gyr_l = 0 + gyr_h = 0 + if(BerryIMUversion == 1): + gyr_l = bus.read_byte_data(LSM9DS0_GYR_ADDRESS, LSM9DS0_OUT_Y_L_G) + gyr_h = bus.read_byte_data(LSM9DS0_GYR_ADDRESS, LSM9DS0_OUT_Y_H_G) + elif(BerryIMUversion == 2): + gyr_l = bus.read_byte_data(LSM9DS1_GYR_ADDRESS, LSM9DS1_OUT_Y_L_G) + gyr_h = bus.read_byte_data(LSM9DS1_GYR_ADDRESS, LSM9DS1_OUT_Y_H_G) + elif(BerryIMUversion == 3): + gyr_l = bus.read_byte_data(LSM6DSL_ADDRESS, LSM6DSL_OUTY_L_G) + gyr_h = bus.read_byte_data(LSM6DSL_ADDRESS, LSM6DSL_OUTY_H_G) + + gyr_combined = (gyr_l | gyr_h <<8) + return gyr_combined if gyr_combined < 32768 else gyr_combined - 65536 + +def readGYRz(): + gyr_l = 0 + gyr_h = 0 + if(BerryIMUversion == 1): + gyr_l = bus.read_byte_data(LSM9DS0_GYR_ADDRESS, LSM9DS0_OUT_Z_L_G) + gyr_h = bus.read_byte_data(LSM9DS0_GYR_ADDRESS, LSM9DS0_OUT_Z_H_G) + elif(BerryIMUversion == 2): + gyr_l = bus.read_byte_data(LSM9DS1_GYR_ADDRESS, LSM9DS1_OUT_Z_L_G) + gyr_h = bus.read_byte_data(LSM9DS1_GYR_ADDRESS, LSM9DS1_OUT_Z_H_G) + elif(BerryIMUversion == 3): + gyr_l = bus.read_byte_data(LSM6DSL_ADDRESS, LSM6DSL_OUTZ_L_G) + gyr_h = bus.read_byte_data(LSM6DSL_ADDRESS, LSM6DSL_OUTZ_H_G) + + gyr_combined = (gyr_l | gyr_h <<8) + return gyr_combined if gyr_combined < 32768 else gyr_combined - 65536 + + +def readMAGx(): + mag_l = 0 + mag_h = 0 + if(BerryIMUversion == 1): + mag_l = bus.read_byte_data(LSM9DS0_MAG_ADDRESS, LSM9DS0_OUT_X_L_M) + mag_h = bus.read_byte_data(LSM9DS0_MAG_ADDRESS, LSM9DS0_OUT_X_H_M) + elif(BerryIMUversion == 2): + mag_l = bus.read_byte_data(LSM9DS1_MAG_ADDRESS, LSM9DS1_OUT_X_L_M) + mag_h = bus.read_byte_data(LSM9DS1_MAG_ADDRESS, LSM9DS1_OUT_X_H_M) + elif(BerryIMUversion == 3): + mag_l = bus.read_byte_data(LIS3MDL_ADDRESS, LIS3MDL_OUT_X_L) + mag_h = bus.read_byte_data(LIS3MDL_ADDRESS, LIS3MDL_OUT_X_H) + + mag_combined = (mag_l | mag_h <<8) + return mag_combined if mag_combined < 32768 else mag_combined - 65536 + + +def readMAGy(): + mag_l = 0 + mag_h = 0 + if(BerryIMUversion == 1): + mag_l = bus.read_byte_data(LSM9DS0_MAG_ADDRESS, LSM9DS0_OUT_Y_L_M) + mag_h = bus.read_byte_data(LSM9DS0_MAG_ADDRESS, LSM9DS0_OUT_Y_H_M) + elif(BerryIMUversion == 2): + mag_l = bus.read_byte_data(LSM9DS1_MAG_ADDRESS, LSM9DS1_OUT_Y_L_M) + mag_h = bus.read_byte_data(LSM9DS1_MAG_ADDRESS, LSM9DS1_OUT_Y_H_M) + elif(BerryIMUversion == 3): + mag_l = bus.read_byte_data(LIS3MDL_ADDRESS, LIS3MDL_OUT_Y_L) + mag_h = bus.read_byte_data(LIS3MDL_ADDRESS, LIS3MDL_OUT_Y_H) + + mag_combined = (mag_l | mag_h <<8) + return mag_combined if mag_combined < 32768 else mag_combined - 65536 + + +def readMAGz(): + mag_l = 0 + mag_h = 0 + if(BerryIMUversion == 1): + mag_l = bus.read_byte_data(LSM9DS0_MAG_ADDRESS, LSM9DS0_OUT_Z_L_M) + mag_h = bus.read_byte_data(LSM9DS0_MAG_ADDRESS, LSM9DS0_OUT_Z_H_M) + elif(BerryIMUversion == 2): + mag_l = bus.read_byte_data(LSM9DS1_MAG_ADDRESS, LSM9DS1_OUT_Z_L_M) + mag_h = bus.read_byte_data(LSM9DS1_MAG_ADDRESS, LSM9DS1_OUT_Z_H_M) + elif(BerryIMUversion == 3): + mag_l = bus.read_byte_data(LIS3MDL_ADDRESS, LIS3MDL_OUT_Z_L) + mag_h = bus.read_byte_data(LIS3MDL_ADDRESS, LIS3MDL_OUT_Z_H) + + mag_combined = (mag_l | mag_h <<8) + return mag_combined if mag_combined < 32768 else mag_combined - 65536 + + + +def initIMU(): + + if(BerryIMUversion == 1): #For BerryIMUv1 + #initialise the accelerometer + writeByte(LSM9DS0_ACC_ADDRESS,LSM9DS0_CTRL_REG1_XM, 0b01100111) #z,y,x axis enabled, continuos update, 100Hz data rate + writeByte(LSM9DS0_ACC_ADDRESS,LSM9DS0_CTRL_REG2_XM, 0b00011000) #+/- 8G full scale + + #initialise the magnetometer + writeByte(LSM9DS0_MAG_ADDRESS,LSM9DS0_CTRL_REG5_XM, 0b11110000) #Temp enable, M data rate = 50Hz + writeByte(LSM9DS0_MAG_ADDRESS,LSM9DS0_CTRL_REG6_XM, 0b01100000) #+/- 12gauss + writeByte(LSM9DS0_MAG_ADDRESS,LSM9DS0_CTRL_REG7_XM, 0b00000000) #Continuous-conversion mode + + #initialise the gyroscope + writeByte(LSM9DS0_GYR_ADDRESS,LSM9DS0_CTRL_REG1_G, 0b00001111) #Normal power mode, all axes enabled + writeByte(LSM9DS0_GYR_ADDRESS,LSM9DS0_CTRL_REG4_G, 0b00110000) #Continuos update, 2000 dps full scale + + elif(BerryIMUversion == 2): #For BerryIMUv2 + #initialise the accelerometer + writeByte(LSM9DS1_ACC_ADDRESS,LSM9DS1_CTRL_REG5_XL,0b00111000) #z, y, x axis enabled for accelerometer + writeByte(LSM9DS1_ACC_ADDRESS,LSM9DS1_CTRL_REG6_XL,0b00111000) #+/- 8g + + #initialise the gyroscope + writeByte(LSM9DS1_GYR_ADDRESS,LSM9DS1_CTRL_REG4,0b00111000) #z, y, x axis enabled for gyro + writeByte(LSM9DS1_GYR_ADDRESS,LSM9DS1_CTRL_REG1_G,0b10111000) #Gyro ODR = 476Hz, 2000 dps + writeByte(LSM9DS1_GYR_ADDRESS,LSM9DS1_ORIENT_CFG_G,0b10111000) #Swap orientation + + #initialise the magnetometer + writeByte(LSM9DS1_MAG_ADDRESS,LSM9DS1_CTRL_REG1_M, 0b10011100) #Temp compensation enabled,Low power mode mode,80Hz ODR + writeByte(LSM9DS1_MAG_ADDRESS,LSM9DS1_CTRL_REG2_M, 0b01000000) #+/- 2gauss + writeByte(LSM9DS1_MAG_ADDRESS,LSM9DS1_CTRL_REG3_M, 0b00000000) #continuos update + writeByte(LSM9DS1_MAG_ADDRESS,LSM9DS1_CTRL_REG4_M, 0b00000000) #lower power mode for Z axis + + elif(BerryIMUversion == 3): #For BerryIMUv3 + #initialise the accelerometer + writeByte(LSM6DSL_ADDRESS,LSM6DSL_CTRL1_XL,0b10011111) #ODR 3.33 kHz, +/- 8g , BW = 400hz + writeByte(LSM6DSL_ADDRESS,LSM6DSL_CTRL8_XL,0b11001000) #Low pass filter enabled, BW9, composite filter + writeByte(LSM6DSL_ADDRESS,LSM6DSL_CTRL3_C,0b01000100) #Enable Block Data update, increment during multi byte read + + #initialise the gyroscope + writeByte(LSM6DSL_ADDRESS,LSM6DSL_CTRL2_G,0b10011100) #ODR 3.3 kHz, 2000 dps + + #initialise the magnetometer + writeByte(LIS3MDL_ADDRESS,LIS3MDL_CTRL_REG1, 0b11011100) # Temp sesnor enabled, High performance, ODR 80 Hz, FAST ODR disabled and Selft test disabled. + writeByte(LIS3MDL_ADDRESS,LIS3MDL_CTRL_REG2, 0b00100000) # +/- 8 gauss + writeByte(LIS3MDL_ADDRESS,LIS3MDL_CTRL_REG3, 0b00000000) # Continuous-conversion mode + + diff --git a/BerryIMU/LIS3MDL.py b/BerryIMU/LIS3MDL.py new file mode 100644 index 0000000..b6e6ccf --- /dev/null +++ b/BerryIMU/LIS3MDL.py @@ -0,0 +1,29 @@ + +LIS3MDL_ADDRESS = 0x1C + +LIS3MDL_WHO_AM_I = 0x0F + +LIS3MDL_CTRL_REG1 = 0x20 + +LIS3MDL_CTRL_REG2 = 0x21 +LIS3MDL_CTRL_REG3 = 0x22 +LIS3MDL_CTRL_REG4 = 0x23 +LIS3MDL_CTRL_REG5 = 0x24 + +LIS3MDL_STATUS_REG = 0x27 + +LIS3MDL_OUT_X_L = 0x28 +LIS3MDL_OUT_X_H = 0x29 +LIS3MDL_OUT_Y_L = 0x2A +LIS3MDL_OUT_Y_H = 0x2B +LIS3MDL_OUT_Z_L = 0x2C +LIS3MDL_OUT_Z_H = 0x2D + +LIS3MDL_TEMP_OUT_L = 0x2E +LIS3MDL_TEMP_OUT_H = 0x2F + +LIS3MDL_INT_CFG = 0x30 +LIS3MDL_INT_SRC = 0x31 +LIS3MDL_INT_THS_L = 0x32 +LIS3MDL_INT_THS_H = 0x33 + diff --git a/BerryIMU/LSM6DSL.py b/BerryIMU/LSM6DSL.py new file mode 100644 index 0000000..2d25ff1 --- /dev/null +++ b/BerryIMU/LSM6DSL.py @@ -0,0 +1,45 @@ + +LSM6DSL_ADDRESS = 0x6A + +LSM6DSL_WHO_AM_I = 0x0F +LSM6DSL_RAM_ACCESS = 0x01 +LSM6DSL_CTRL1_XL = 0x10 +LSM6DSL_CTRL8_XL = 0x17 +LSM6DSL_CTRL2_G = 0x11 +LSM6DSL_CTRL10_C = 0x19 +LSM6DSL_TAP_CFG1 = 0x58 +LSM6DSL_INT1_CTR = 0x0D +LSM6DSL_CTRL3_C = 0x12 +LSM6DSL_CTRL4_C = 0x13 + +LSM6DSL_STEP_COUNTER_L = 0x4B +LSM6DSL_STEP_COUNTER_H = 0x4C + +LSM6DSL_OUTX_L_XL = 0x28 +LSM6DSL_OUTX_H_XL = 0x29 +LSM6DSL_OUTY_L_XL = 0x2A +LSM6DSL_OUTY_H_XL = 0x2B +LSM6DSL_OUTZ_L_XL = 0x2C +LSM6DSL_OUTZ_H_XL = 0x2D + +LSM6DSL_OUT_L_TEMP = 0x20 +LSM6DSL_OUT_H_TEMP = 0x21 + +LSM6DSL_OUTX_L_G = 0x22 +LSM6DSL_OUTX_H_G = 0x23 +LSM6DSL_OUTY_L_G = 0x24 +LSM6DSL_OUTY_H_G = 0x25 +LSM6DSL_OUTZ_L_G = 0x26 +LSM6DSL_OUTZ_H_G = 0x27 + +LSM6DSL_TAP_CFG = 0x58 +LSM6DSL_WAKE_UP_SRC = 0x1B +LSM6DSL_WAKE_UP_DUR = 0x5C +LSM6DSL_FREE_FALL = 0x5D +LSM6DSL_MD1_CFG = 0x5E +LSM6DSL_MD2_CFG = 0x5F +LSM6DSL_WAKE_UP_SRC = 0x1B +LSM6DSL_TAP_THS_6D = 0x59 +LSM6DSL_INT_DUR2 = 0x5A +LSM6DSL_WAKE_UP_THS = 0x5B +LSM6DSL_FUNC_SRC1 = 0x53 diff --git a/BerryIMU/LSM9DS0.py b/BerryIMU/LSM9DS0.py new file mode 100644 index 0000000..987f193 --- /dev/null +++ b/BerryIMU/LSM9DS0.py @@ -0,0 +1,87 @@ +LSM9DS0_MAG_ADDRESS = 0x1E +LSM9DS0_ACC_ADDRESS = 0x1E +LSM9DS0_GYR_ADDRESS = 0x6A + +#LSM9DS0 Gyro Registers +LSM9DS0_WHO_AM_I_G = 0x0F +LSM9DS0_CTRL_REG1_G = 0x20 +LSM9DS0_CTRL_REG2_G = 0x21 +LSM9DS0_CTRL_REG3_G = 0x22 +LSM9DS0_CTRL_REG4_G = 0x23 +LSM9DS0_CTRL_REG5_G = 0x24 +LSM9DS0_REFERENCE_G = 0x25 +LSM9DS0_STATUS_REG_G = 0x27 +LSM9DS0_OUT_X_L_G = 0x28 +LSM9DS0_OUT_X_H_G = 0x29 +LSM9DS0_OUT_Y_L_G = 0x2A +LSM9DS0_OUT_Y_H_G = 0x2B +LSM9DS0_OUT_Z_L_G = 0x2C +LSM9DS0_OUT_Z_H_G = 0x2D +LSM9DS0_FIFO_CTRL_REG_G = 0x2E +LSM9DS0_FIFO_SRC_REG_G = 0x2F +LSM9DS0_INT1_CFG_G = 0x30 +LSM9DS0_INT1_SRC_G = 0x31 +LSM9DS0_INT1_THS_XH_G = 0x32 +LSM9DS0_INT1_THS_XL_G = 0x33 +LSM9DS0_INT1_THS_YH_G = 0x34 +LSM9DS0_INT1_THS_YL_G = 0x35 +LSM9DS0_INT1_THS_ZH_G = 0x36 +LSM9DS0_INT1_THS_ZL_G = 0x37 +LSM9DS0_INT1_DURATION_G = 0x38 + +#LSM9DS0 Accel and Magneto Registers +LSM9DS0_OUT_TEMP_L_XM = 0x05 +LSM9DS0_OUT_TEMP_H_XM = 0x06 +LSM9DS0_STATUS_REG_M = 0x07 +LSM9DS0_OUT_X_L_M = 0x08 +LSM9DS0_OUT_X_H_M = 0x09 +LSM9DS0_OUT_Y_L_M = 0x0A +LSM9DS0_OUT_Y_H_M = 0x0B +LSM9DS0_OUT_Z_L_M = 0x0C +LSM9DS0_OUT_Z_H_M = 0x0D +LSM9DS0_WHO_AM_I_XM = 0x0F +LSM9DS0_INT_CTRL_REG_M = 0x12 +LSM9DS0_INT_SRC_REG_M = 0x13 +LSM9DS0_INT_THS_L_M = 0x14 +LSM9DS0_INT_THS_H_M = 0x15 +LSM9DS0_OFFSET_X_L_M = 0x16 +LSM9DS0_OFFSET_X_H_M = 0x17 +LSM9DS0_OFFSET_Y_L_M = 0x18 +LSM9DS0_OFFSET_Y_H_M = 0x19 +LSM9DS0_OFFSET_Z_L_M = 0x1A +LSM9DS0_OFFSET_Z_H_M = 0x1B +LSM9DS0_REFERENCE_X = 0x1C +LSM9DS0_REFERENCE_Y = 0x1D +LSM9DS0_REFERENCE_Z = 0x1E +LSM9DS0_CTRL_REG0_XM = 0x1F +LSM9DS0_CTRL_REG1_XM = 0x20 +LSM9DS0_CTRL_REG2_XM = 0x21 +LSM9DS0_CTRL_REG3_XM = 0x22 +LSM9DS0_CTRL_REG4_XM = 0x23 +LSM9DS0_CTRL_REG5_XM = 0x24 +LSM9DS0_CTRL_REG6_XM = 0x25 +LSM9DS0_CTRL_REG7_XM = 0x26 +LSM9DS0_STATUS_REG_A = 0x27 +LSM9DS0_OUT_X_L_A = 0x28 +LSM9DS0_OUT_X_H_A = 0x29 +LSM9DS0_OUT_Y_L_A = 0x2A +LSM9DS0_OUT_Y_H_A = 0x2B +LSM9DS0_OUT_Z_L_A = 0x2C +LSM9DS0_OUT_Z_H_A = 0x2D +LSM9DS0_FIFO_CTRL_REG = 0x2E +LSM9DS0_FIFO_SRC_REG = 0x2F +LSM9DS0_INT_GEN_1_REG = 0x30 +LSM9DS0_INT_GEN_1_SRC = 0x31 +LSM9DS0_INT_GEN_1_THS = 0x32 +LSM9DS0_INT_GEN_1_DURATION = 0x33 +LSM9DS0_INT_GEN_2_REG = 0x34 +LSM9DS0_INT_GEN_2_SRC = 0x35 +LSM9DS0_INT_GEN_2_THS = 0x36 +LSM9DS0_INT_GEN_2_DURATION = 0x37 +LSM9DS0_CLICK_CFG = 0x38 +LSM9DS0_CLICK_SRC = 0x39 +LSM9DS0_CLICK_THS = 0x3A +LSM9DS0_TIME_LIMIT = 0x3B +LSM9DS0_TIME_LATENCY = 0x3C +LSM9DS0_TIME_WINDOW = 0x3D + diff --git a/BerryIMU/LSM9DS1.py b/BerryIMU/LSM9DS1.py new file mode 100644 index 0000000..4123274 --- /dev/null +++ b/BerryIMU/LSM9DS1.py @@ -0,0 +1,94 @@ + +LSM9DS1_MAG_ADDRESS = 0x1C #Would be 0x1E if SDO_M is HIGH +LSM9DS1_ACC_ADDRESS = 0x6A +LSM9DS1_GYR_ADDRESS = 0x6A #Would be 0x6B if SDO_AG is HIGH + + +#///////////////////////////////////////// +#// LSM9DS1 Accel/Gyro (XL/G) Registers // +#///////////////////////////////////////// +LSM9DS1_ACT_THS = 0x04 +LSM9DS1_ACT_DUR = 0x05 +LSM9DS1_INT_GEN_CFG_XL = 0x06 +LSM9DS1_INT_GEN_THS_X_XL = 0x07 +LSM9DS1_INT_GEN_THS_Y_XL = 0x08 +LSM9DS1_INT_GEN_THS_Z_XL = 0x09 +LSM9DS1_INT_GEN_DUR_XL = 0x0A +LSM9DS1_REFERENCE_G = 0x0B +LSM9DS1_INT1_CTRL = 0x0C +LSM9DS1_INT2_CTRL = 0x0D +LSM9DS1_WHO_AM_I_XG = 0x0F +LSM9DS1_CTRL_REG1_G = 0x10 +LSM9DS1_CTRL_REG2_G = 0x11 +LSM9DS1_CTRL_REG3_G = 0x12 +LSM9DS1_ORIENT_CFG_G = 0x13 +LSM9DS1_INT_GEN_SRC_G = 0x14 +LSM9DS1_OUT_TEMP_L = 0x15 +LSM9DS1_OUT_TEMP_H = 0x16 +LSM9DS1_STATUS_REG_0 = 0x17 +LSM9DS1_OUT_X_L_G = 0x18 +LSM9DS1_OUT_X_H_G = 0x19 +LSM9DS1_OUT_Y_L_G = 0x1A +LSM9DS1_OUT_Y_H_G = 0x1B +LSM9DS1_OUT_Z_L_G = 0x1C +LSM9DS1_OUT_Z_H_G = 0x1D +LSM9DS1_CTRL_REG4 = 0x1E +LSM9DS1_CTRL_REG5_XL = 0x1F +LSM9DS1_CTRL_REG6_XL = 0x20 +LSM9DS1_CTRL_REG7_XL = 0x21 +LSM9DS1_CTRL_REG8 = 0x22 +LSM9DS1_CTRL_REG9 = 0x23 +LSM9DS1_CTRL_REG10 = 0x24 +LSM9DS1_INT_GEN_SRC_XL = 0x26 +LSM9DS1_STATUS_REG_1 = 0x27 +LSM9DS1_OUT_X_L_XL = 0x28 +LSM9DS1_OUT_X_H_XL = 0x29 +LSM9DS1_OUT_Y_L_XL = 0x2A +LSM9DS1_OUT_Y_H_XL = 0x2B +LSM9DS1_OUT_Z_L_XL = 0x2C +LSM9DS1_OUT_Z_H_XL = 0x2D +LSM9DS1_FIFO_CTRL = 0x2E +LSM9DS1_FIFO_SRC = 0x2F +LSM9DS1_INT_GEN_CFG_G = 0x30 +LSM9DS1_INT_GEN_THS_XH_G = 0x31 +LSM9DS1_INT_GEN_THS_XL_G = 0x32 +LSM9DS1_INT_GEN_THS_YH_G = 0x33 +LSM9DS1_INT_GEN_THS_YL_G = 0x34 +LSM9DS1_INT_GEN_THS_ZH_G = 0x35 +LSM9DS1_INT_GEN_THS_ZL_G = 0x36 +LSM9DS1_INT_GEN_DUR_G = 0x37 + +#/////////////////////////////// +#// LSM9DS1 Magneto Registers // +#/////////////////////////////// +LSM9DS1_OFFSET_X_REG_L_M = 0x05 +LSM9DS1_OFFSET_X_REG_H_M = 0x06 +LSM9DS1_OFFSET_Y_REG_L_M = 0x07 +LSM9DS1_OFFSET_Y_REG_H_M = 0x08 +LSM9DS1_OFFSET_Z_REG_L_M = 0x09 +LSM9DS1_OFFSET_Z_REG_H_M = 0x0A +LSM9DS1_WHO_AM_I_M = 0x0F +LSM9DS1_CTRL_REG1_M = 0x20 +LSM9DS1_CTRL_REG2_M = 0x21 +LSM9DS1_CTRL_REG3_M = 0x22 +LSM9DS1_CTRL_REG4_M = 0x23 +LSM9DS1_CTRL_REG5_M = 0x24 +LSM9DS1_STATUS_REG_M = 0x27 +LSM9DS1_OUT_X_L_M = 0x28 +LSM9DS1_OUT_X_H_M = 0x29 +LSM9DS1_OUT_Y_L_M = 0x2A +LSM9DS1_OUT_Y_H_M = 0x2B +LSM9DS1_OUT_Z_L_M = 0x2C +LSM9DS1_OUT_Z_H_M = 0x2D +LSM9DS1_INT_CFG_M = 0x30 +LSM9DS1_INT_SRC_M = 0x30 +LSM9DS1_INT_THS_L_M = 0x32 +LSM9DS1_INT_THS_H_M = 0x33 + +#//////////////////////////////// +#// LSM9DS1 WHO_AM_I Responses // +#//////////////////////////////// +LSM9DS1_WHO_AM_I_AG_RSP = 0x68 +LSM9DS1_WHO_AM_I_M_RSP = 0x3D + + diff --git a/berryIMU+data logger.py b/berryIMU+data logger.py new file mode 100644 index 0000000..6f71d94 --- /dev/null +++ b/berryIMU+data logger.py @@ -0,0 +1,215 @@ +# Feel free to do whatever you like with this code. +# Distributed as-is; no warranty is given. +# +# https://ozzmaker.com/berryimu/ + +# Modified by Chloe Zheng based on berryIMU-simple.py +# This test: +# * Get usable angles using a Complementary filter +# * Save data to a txt file +# * Run for 10(total_time) seconds, record data each 0.5(updaterate) second + + +import time +import math +from BerryIMU import IMU +import datetime +import os +import sys +import rocketLogger + +RAD_TO_DEG = 57.29578 +M_PI = 3.14159265358979323846 +G_GAIN = 0.070 # [deg/s/LSB] If you change the dps for gyro, you need to update this value accordingly +AA = 0.40 # Complementary filter constant + +updaterate = 0.5 #in seconds +current_time = 0 # record time, only for testing purpose +total_time = 10 + +################# Compass Calibration values ############ +# Use calibrateBerryIMU.py to get calibration values +# Calibrating the compass isnt mandatory, however a calibrated +# compass will result in a more accurate heading values. + +magXmin = 0 +magYmin = 0 +magZmin = 0 +magXmax = 0 +magYmax = 0 +magZmax = 0 + + + +''' +Here is an example: +magXmin = -1748 +magYmin = -1025 +magZmin = -1876 +magXmax = 959 +magYmax = 1651 +magZmax = 708 +Dont use the above values, these are just an example. +''' +############### END Calibration offsets ################# + + + +gyroXangle = 0.0 +gyroYangle = 0.0 +gyroZangle = 0.0 +CFangleX = 0.0 +CFangleY = 0.0 + + +IMU.detectIMU() #Detect if BerryIMU is connected. +if(IMU.BerryIMUversion == 99): + print(" No BerryIMU found... exiting ") + sys.exit() +IMU.initIMU() #Initialise the accelerometer, gyroscope and compass + + +a = datetime.datetime.now() + + +#Initial logging setup, temporarily here before refactor to main logic +""" +f = open("Acc+Gyro data.txt", "w+") +f.write('AccXangle \t AccYangle \t gyroXangle \t gyroYangle \t gyroZangle \n') +f.close() +""" +logger = rocketLogger() +logger.dataLog('AccXangle \t AccYangle \t gyroXangle \t gyroYangle \t gyroZangle \n') + + +while True and current_time <= total_time: + #Read the accelerometer,gyroscope and magnetometer values + ACCx = IMU.readACCx() + ACCy = IMU.readACCy() + ACCz = IMU.readACCz() + GYRx = IMU.readGYRx() + GYRy = IMU.readGYRy() + GYRz = IMU.readGYRz() + MAGx = IMU.readMAGx() + MAGy = IMU.readMAGy() + MAGz = IMU.readMAGz() + + #Apply compass calibration + MAGx -= (magXmin + magXmax) /2 + MAGy -= (magYmin + magYmax) /2 + MAGz -= (magZmin + magZmax) /2 + + ##Calculate loop Period(LP). How long between Gyro Reads + b = datetime.datetime.now() - a + a = datetime.datetime.now() + LP = b.microseconds/(1000000*1.0) + #outputString = "Loop Time %5.2f " % ( LP ) + + + #Convert Gyro raw to degrees per second + rate_gyr_x = GYRx * G_GAIN + rate_gyr_y = GYRy * G_GAIN + rate_gyr_z = GYRz * G_GAIN + + + #Calculate the angles from the gyro. + gyroXangle+=rate_gyr_x*LP + gyroYangle+=rate_gyr_y*LP + gyroZangle+=rate_gyr_z*LP + + + #Convert Accelerometer values to degrees + AccXangle = (math.atan2(ACCy,ACCz)*RAD_TO_DEG) + AccYangle = (math.atan2(ACCz,ACCx)+M_PI)*RAD_TO_DEG + + #convert the values to -180 and +180 + if AccYangle > 90: + AccYangle -= 270.0 + else: + AccYangle += 90.0 + + + + #Complementary filter used to combine the accelerometer and gyro values. + CFangleX=AA*(CFangleX+rate_gyr_x*LP) +(1 - AA) * AccXangle + CFangleY=AA*(CFangleY+rate_gyr_y*LP) +(1 - AA) * AccYangle + + + + #Calculate heading + heading = 180 * math.atan2(MAGy,MAGx)/M_PI + + #Only have our heading between 0 and 360 + if heading < 0: + heading += 360 + + #################################################################### + ###################Tilt compensated heading######################### + #################################################################### + #Normalize accelerometer raw values. + accXnorm = ACCx/math.sqrt(ACCx * ACCx + ACCy * ACCy + ACCz * ACCz) + accYnorm = ACCy/math.sqrt(ACCx * ACCx + ACCy * ACCy + ACCz * ACCz) + + + #Calculate pitch and roll + pitch = math.asin(accXnorm) + roll = -math.asin(accYnorm/math.cos(pitch)) + + + #Calculate the new tilt compensated values + #The compass and accelerometer are orientated differently on the the BerryIMUv1, v2 and v3. + #This needs to be taken into consideration when performing the calculations + + #X compensation + if(IMU.BerryIMUversion == 1 or IMU.BerryIMUversion == 3): #LSM9DS0 and (LSM6DSL & LIS2MDL) + magXcomp = MAGx*math.cos(pitch)+MAGz*math.sin(pitch) + else: #LSM9DS1 + magXcomp = MAGx*math.cos(pitch)-MAGz*math.sin(pitch) + + #Y compensation + if(IMU.BerryIMUversion == 1 or IMU.BerryIMUversion == 3): #LSM9DS0 and (LSM6DSL & LIS2MDL) + magYcomp = MAGx*math.sin(roll)*math.sin(pitch)+MAGy*math.cos(roll)-MAGz*math.sin(roll)*math.cos(pitch) + else: #LSM9DS1 + magYcomp = MAGx*math.sin(roll)*math.sin(pitch)+MAGy*math.cos(roll)+MAGz*math.sin(roll)*math.cos(pitch) + + + + + #Calculate tilt compensated heading + tiltCompensatedHeading = 180 * math.atan2(magYcomp,magXcomp)/M_PI + + if tiltCompensatedHeading < 0: + tiltCompensatedHeading += 360 + + + ##################### END Tilt Compensation ######################## + + + if 1: #Change to '0' to stop showing the angles from the accelerometer + outputString = " %5.2f\t\t%5.2f" % (AccXangle, AccYangle) + + if 1: #Change to '0' to stop showing the angles from the gyro + outputString +="\t\t%5.2f\t\t%5.2f\t\t%5.2f\t\t" % (gyroXangle,gyroYangle,gyroZangle) + + if 0: #Change to '0' to stop showing the angles from the complementary filter + outputString +=" %5.2f %5.2f " % (CFangleX,CFangleY) + + if 0: #Change to '0' to stop showing the heading + outputString +=" %5.2f %5.2f " % (heading,tiltCompensatedHeading) + + + ##################### Write data to file ######################## + + """ + f = open("Acc+Gyro data.txt", "a") + f.write(outputString) + f.write("\n") + f.close() + print(outputString) + """ + logger.dataLog(outputString + "\n") + + current_time += updaterate + + #slow program down a bit, makes the output more readable + time.sleep(updaterate) diff --git a/logs/.gitkeep b/logs/.gitkeep new file mode 100644 index 0000000..e69de29 From b4256514fe5df243f5fca73109581312575cc7c5 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Fri, 13 Jan 2023 04:11:49 +0000 Subject: [PATCH 02/40] created sensor, accelometer class, initial run logic --- berryAccelerometer.py | 69 +++++++++++++++++++++++++++++++++++++++++ berryIMU+data logger.py | 2 +- run.py | 28 +++++++++++++++++ sensor.py | 28 +++++++++++++++++ 4 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 berryAccelerometer.py diff --git a/berryAccelerometer.py b/berryAccelerometer.py new file mode 100644 index 0000000..bed3efc --- /dev/null +++ b/berryAccelerometer.py @@ -0,0 +1,69 @@ +import sensor + +import time +import math +from BerryIMU import IMU +import datetime +import os +import sys + +RAD_TO_DEG = 57.29578 +M_PI = 3.14159265358979323846 + + +class berryAccelerometer(sensor): + + def __init__(self): + sensor.__init__(self) + + def applySensorReadLogic(self): + rawSensorData = getRawSensorData() + convertedSensorData = convertDataToDeg(rawSensorData) + calibratedSensorData = applyCalibration(convertedSensorData) + self.callibratedAccYangle = calibratedSensorData[1] + self.callibratedAccXangle = calibratedSensorData[0] + + def getSensorData(self): + #returns finalized sensor data for use outside class + return [self.callibratedAccYangle. self.callibratedAccXangle] + + def getRawSensorData(self): + """ + gets raw accelerameter data from IMU sensor and returns as array + """ + ACCx = IMU.readACCx() + ACCy = IMU.readACCy() + ACCz = IMU.readACCz() + data = [ACCx,ACCy,ACCz] + return data + + def applyCalibration(self, data): + """ + Calibrates raw sensor data and returns value as array + """ + AccXangle = data[0] + AccYangle = data[1] + #convert the values to -180 and +180 + if AccYangle > 90: + AccYangle -= 270.0 + else: + AccYangle += 90.0 + calibratedSensorData = [AccXangle, AccYangle] + return calibratedSensorData + + def convertDataToDeg(self, data): + """ + Converts sensor data to degree and returns as array + """ + AccXangle = (math.atan2(data[1],data[2])*RAD_TO_DEG) + AccYangle = (math.atan2(data[2],data[0])+M_PI)*RAD_TO_DEG + + convertedSensorData = [AccXangle, AccYangle] + return convertedSensorData + + def normalizeData(self): + self.accXnorm = ACCx/math.sqrt(ACCx * ACCx + ACCy * ACCy + ACCz * ACCz) + self.accYnorm = ACCy/math.sqrt(ACCx * ACCx + ACCy * ACCy + ACCz * ACCz) + + def getNormalizedData(self): + return [self.accXnorm, self.accYnorm] diff --git a/berryIMU+data logger.py b/berryIMU+data logger.py index 6f71d94..bc0b06a 100644 --- a/berryIMU+data logger.py +++ b/berryIMU+data logger.py @@ -82,7 +82,7 @@ logger.dataLog('AccXangle \t AccYangle \t gyroXangle \t gyroYangle \t gyroZangle \n') -while True and current_time <= total_time: +while current_time <= total_time: #Read the accelerometer,gyroscope and magnetometer values ACCx = IMU.readACCx() ACCy = IMU.readACCy() diff --git a/run.py b/run.py index 8b13789..5b90a41 100644 --- a/run.py +++ b/run.py @@ -1 +1,29 @@ +import sensor +import berryAccelerometer +import rocketLogger +logger = rocketLogger() +logger.dataLog('AccXangle \t AccYangle \t gyroXangle \t gyroYangle \t gyroZangle \n') + + +def manageSensors() + callSensorLogics() + logSensorData() + +def callSensorLogics(): + #add sensor logic calls here + berryAccelerometer.applySensorReadLogic() + +def logSensorData(): + logger.dataLog(berryAccelerometer.getSensorData()[0] + + " " + berryAccelerometer.getSensorData()[1] + + "/N") + + +def main(): + initalizeLogger() + while True: + manageSensors() + +if __name__=="__main__": +    main() \ No newline at end of file diff --git a/sensor.py b/sensor.py index 8b13789..173b845 100644 --- a/sensor.py +++ b/sensor.py @@ -1 +1,29 @@ +class sensor: + + def __init__(self): + pass + + def applySensorReadLogic(self): + """ + Sensor logic defined to retrieve and calibrate raw sensor data, to be called once per logic iteration + """ + pass + + def getRawSensorData(self): + """ + Returns raw sensor data in format relevent to particular sensor implementation + """ + return data + + def applyCalibration(self, data); + #some code to calibrate data here + pass + + def convertDataToDeg(self, value): + #some code to convert data + return value + + def getSensorData(self): + #gets finalized sensor data, likel to used in logging and logic + pass \ No newline at end of file From 3a883a07acde6807593b9ebfe05f1f008ecdf5b4 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Fri, 13 Jan 2023 18:14:53 +0000 Subject: [PATCH 03/40] Reorganize directories for refractor --- berryAccelerometer.py => Sensors/berryAccelerometer.py | 0 sensor.py => Sensors/sensor.py | 0 example.log => logs/example.log | 0 run.py | 2 +- 4 files changed, 1 insertion(+), 1 deletion(-) rename berryAccelerometer.py => Sensors/berryAccelerometer.py (100%) rename sensor.py => Sensors/sensor.py (100%) rename example.log => logs/example.log (100%) diff --git a/berryAccelerometer.py b/Sensors/berryAccelerometer.py similarity index 100% rename from berryAccelerometer.py rename to Sensors/berryAccelerometer.py diff --git a/sensor.py b/Sensors/sensor.py similarity index 100% rename from sensor.py rename to Sensors/sensor.py diff --git a/example.log b/logs/example.log similarity index 100% rename from example.log rename to logs/example.log diff --git a/run.py b/run.py index 5b90a41..cc84402 100644 --- a/run.py +++ b/run.py @@ -1,4 +1,4 @@ -import sensor +from Sensors import sensor import berryAccelerometer import rocketLogger From d3389fb0a24cb2f6776722b0faf3d568f7cef068 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Sun, 15 Jan 2023 00:43:36 +0000 Subject: [PATCH 04/40] Initial gyroscope refractor, update sensor class --- Sensors/berryAccelerometer.py | 1 + Sensors/berryGyroscope.py | 72 +++++++++++++++++++++++++++++++++++ Sensors/sensor.py | 12 +++++- 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 Sensors/berryGyroscope.py diff --git a/Sensors/berryAccelerometer.py b/Sensors/berryAccelerometer.py index bed3efc..76c7f13 100644 --- a/Sensors/berryAccelerometer.py +++ b/Sensors/berryAccelerometer.py @@ -22,6 +22,7 @@ def applySensorReadLogic(self): calibratedSensorData = applyCalibration(convertedSensorData) self.callibratedAccYangle = calibratedSensorData[1] self.callibratedAccXangle = calibratedSensorData[0] + self.normalizeData() def getSensorData(self): #returns finalized sensor data for use outside class diff --git a/Sensors/berryGyroscope.py b/Sensors/berryGyroscope.py new file mode 100644 index 0000000..3ffc13b --- /dev/null +++ b/Sensors/berryGyroscope.py @@ -0,0 +1,72 @@ +import sensor + +import time +import math +from BerryIMU import IMU +import datetime +import os +import sys + +G_GAIN = 0.070 # [deg/s/LSB] If you change the dps for gyro, you need to update this value accordingly + + +class berryGyroscope(sensor): + + def __init__(self): + sensor.__init__(self) + self.timeA = datetime.datetime.now() + self.gyroXangle = 0.0 + self.gyroYangle = 0.0 + self.gyroZangle = 0.0 + + def applySensorReadLogic(self): + """ + Sensor logic defined to retrieve and calibrate raw sensor data, to be called once per logic iteration + """ + rawSensorData = getRawSensorData() + calculateLP() + convertedSensorData = convertDataToDeg(rawSensorData) + applyCalibration(convertedSensorData) + + + def getRawSensorData(self): + """ + Returns raw sensor data in format relevent to particular sensor implementation + """ + GYRx = IMU.readGYRx() + GYRy = IMU.readGYRy() + GYRz = IMU.readGYRz() + data = [GYRx, GYRy, GYRz] + return data + + def calculateLP(self): + """ + Calculate loop Period(LP). How long between Gyro Reads + + """ + self.timeB = datetime.datetime.now() - self.timeA + self.timeA = datetime.datetime.now() + self.LP = self.timeB.microseconds/(1000000*1.0) + + + + def applyCalibration(self, data); + #Apply calibration to generate finalized gyro angle data + x,y,z = data + self.gyroXangle+=x*self.LP + self.gyroYangle+=y*self.LP + self.gyroZangle+=z*self.LP + + def convertDataToDeg(self, data): + #convert gyro data to degrees, returns converted data + GYRx, GYRy, GYRz = data + rate_gyr_x = GYRx * G_GAIN + rate_gyr_y = GYRy * G_GAIN + rate_gyr_z = GYRz * G_GAIN + convertedSensorData = [rate_gyr_x, rate_gyr_y, rate_gyr_z] + return convertedSensorData + + def getSensorData(self): + return [self.gyroXangle, self.gyroYangle, self.gyroZangle] + + diff --git a/Sensors/sensor.py b/Sensors/sensor.py index 173b845..0ccf8b9 100644 --- a/Sensors/sensor.py +++ b/Sensors/sensor.py @@ -1,7 +1,17 @@ +from BerryIMU import IMU +import rocketLogger class sensor: def __init__(self): + logger = rocketLogger() + IMU.detectIMU() #Detect if BerryIMU is connected. + if(IMU.BerryIMUversion == 99): + logger.debugLog(level=logging.WARNING, "No IMU detected!") + IMU.initIMU() + + def getSensorData(self): + #returns finaliozed sensor data pass def applySensorReadLogic(self): @@ -25,5 +35,5 @@ def convertDataToDeg(self, value): return value def getSensorData(self): - #gets finalized sensor data, likel to used in logging and logic + #gets finalized sensor data, like to used in logging and logic pass \ No newline at end of file From ddb33191a6c88d9049b02be2b7b97613fef39d83 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Sun, 15 Jan 2023 01:04:08 +0000 Subject: [PATCH 05/40] add pitch/roll calculator --- Sensors/berryAccelerometer.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sensors/berryAccelerometer.py b/Sensors/berryAccelerometer.py index 76c7f13..91f5c76 100644 --- a/Sensors/berryAccelerometer.py +++ b/Sensors/berryAccelerometer.py @@ -68,3 +68,9 @@ def normalizeData(self): def getNormalizedData(self): return [self.accXnorm, self.accYnorm] + + def getPitch(self): + return math.asin(self.accXnorm) + + def getRoll(self): + return -math.asin(accYnorm/math.cos(self.getPitch)) From fd16ff53187c65d808eae0c05490870dbe230ff9 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Sun, 15 Jan 2023 02:42:21 +0000 Subject: [PATCH 06/40] refractor magnetmeter --- Sensors/berryMagnetometer.py | 75 ++++++++++++++++++++++++++++++++++++ Sensors/sensor.py | 4 -- 2 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 Sensors/berryMagnetometer.py diff --git a/Sensors/berryMagnetometer.py b/Sensors/berryMagnetometer.py new file mode 100644 index 0000000..a30d05e --- /dev/null +++ b/Sensors/berryMagnetometer.py @@ -0,0 +1,75 @@ +import sensor +import time +import math +from BerryIMU import IMU +import datetime +import os +import sys + +M_PI = 3.14159265358979323846 + + +class berryMagnetometer(sensor): + + def __init__(self): + sensor.__init__(self) + + ################# Compass Calibration values ############ + # Use calibrateBerryIMU.py to get calibration values + # Calibrating the compass isnt mandatory, however a calibrated + # compass will result in a more accurate heading values. + self.magXmin = 0 + self.magYmin = 0 + self.magZmin = 0 + self.magXmax = 0 + self.magYmax = 0 + self.magZmax = 0 + + def applySensorReadLogic(self): + """ + Sensor logic defined to retrieve and calibrate raw sensor data, to be called once per logic iteration + """ + rawSensorData = getRawSensorData() + calibratedSensorData = applyCalibration(rawSensorData) + compensatedTiltValues = calculateTiltCompensatedValues(calibratedSensorData) + self.heading = calculateTiltCompensatedHeading(compensatedTiltValues) + + + def getSensorData(self): + #returns tilt heading, compensated by calibrated values + return self.heading + + + def calculateTiltCompensatedHeading(self, data) + tiltCompensatedHeading = 180 * math.atan2(data[1],data[0])/M_PI + if tiltCompensatedHeading < 0: + tiltCompensatedHeading += 360 + return tiltCompensatedHeading + + def calculateTiltCompensatedValues(self, data, pitch, roll): + """ + Calculate tilt compensated values + Input: cailbrated sensor data, pitch, roll + Returns: xComp and yComp as array + """ + magXcomp = data[0]*math.cos(pitch)+data[2]*math.sin(pitch) + magYcomp = data[0]*math.sin(roll)*math.sin(pitch)+data[1]*math.cos(roll)-data[2]*math.sin(roll)*math.cos(pitch) + return [magXcomp, magYcomp] + + def getRawSensorData(self): + """ + Returns magnetometer x y and z values as array + """ + MAGx = IMU.readMAGx() + MAGy = IMU.readMAGy() + MAGz = IMU.readMAGz() + return [MAGx, MAGy, MAGz] + + def applyCalibration(self, data); + mag = data + mag[0] -= (self.magXmin + self.magXmax) /2 + mag[1] -= (self.magYmin + self.magYmax) /2 + mag[2] -= (self.magZmin + self.magZmax) /2 + return mag + + diff --git a/Sensors/sensor.py b/Sensors/sensor.py index 0ccf8b9..3bfdf68 100644 --- a/Sensors/sensor.py +++ b/Sensors/sensor.py @@ -33,7 +33,3 @@ def applyCalibration(self, data); def convertDataToDeg(self, value): #some code to convert data return value - - def getSensorData(self): - #gets finalized sensor data, like to used in logging and logic - pass \ No newline at end of file From ec4e000ede0e03c336f12f8e2771a831bc223c0d Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Sun, 15 Jan 2023 02:46:12 +0000 Subject: [PATCH 07/40] Directory cleanup after refractor --- berryIMU+data logger.py => BerryIMU/berryIMU+data logger.py | 0 README.md | 6 ++++++ Servo_test2.py => Servos/Servo_test2.py | 0 3 files changed, 6 insertions(+) rename berryIMU+data logger.py => BerryIMU/berryIMU+data logger.py (100%) rename Servo_test2.py => Servos/Servo_test2.py (100%) diff --git a/berryIMU+data logger.py b/BerryIMU/berryIMU+data logger.py similarity index 100% rename from berryIMU+data logger.py rename to BerryIMU/berryIMU+data logger.py diff --git a/README.md b/README.md index fc8c6f8..07e9d5d 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,9 @@ Log sensor and debug data to file, in /logs run.py Controller class, grabs sensor data from sensor.py, sends to both datalogger.py (to log to file) and to an algogrythm to determine servo action, which sends data to servo.py + +Setup: + +1. Clone the repo both on your local machine and the rocket's raspberry pi. +2. On the raspberry pi, enable SSH and GPIO On the raspberry pi. +3. run Autorun/setup_autorunner.sh to allow the code to run on boot diff --git a/Servo_test2.py b/Servos/Servo_test2.py similarity index 100% rename from Servo_test2.py rename to Servos/Servo_test2.py From 678fe66ae253d64ae9f732f29b7c66e14d8a3d9e Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Mon, 16 Jan 2023 03:35:13 +0000 Subject: [PATCH 08/40] add filter angle calculator --- Sensors/berryGyroscope.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sensors/berryGyroscope.py b/Sensors/berryGyroscope.py index 3ffc13b..5226b08 100644 --- a/Sensors/berryGyroscope.py +++ b/Sensors/berryGyroscope.py @@ -8,7 +8,7 @@ import sys G_GAIN = 0.070 # [deg/s/LSB] If you change the dps for gyro, you need to update this value accordingly - +AA = 0.40 class berryGyroscope(sensor): @@ -18,6 +18,8 @@ def __init__(self): self.gyroXangle = 0.0 self.gyroYangle = 0.0 self.gyroZangle = 0.0 + self.CFangleX = 0.0 + self.CFangleY = 0.0 def applySensorReadLogic(self): """ @@ -48,7 +50,9 @@ def calculateLP(self): self.timeA = datetime.datetime.now() self.LP = self.timeB.microseconds/(1000000*1.0) - + def applyFilter(self, gyroxy, loopPeriod, accxy) + self.CFangleX=AA*(self.CFangleX+gyroxy[0]*LP) +(1 - AA) * accxy[0] + self.CFangleY=AA*(self.CFangleY+gyroxy[1]*LP) +(1 - AA) * accxy[1] def applyCalibration(self, data); #Apply calibration to generate finalized gyro angle data From fac73475d19a94e0cfd6c926d06b6007be716a45 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Thu, 19 Jan 2023 14:06:44 -0600 Subject: [PATCH 09/40] Fix syntax errors --- Sensors/berryAccelerometer.py | 17 +++++++++++------ Sensors/berryGyroscope.py | 14 +++++++------- Sensors/berryMagnetometer.py | 12 ++++++------ Sensors/sensor.py | 5 +++-- rocketLogger.py | 14 +++++++------- run.py | 7 +++---- 6 files changed, 37 insertions(+), 32 deletions(-) diff --git a/Sensors/berryAccelerometer.py b/Sensors/berryAccelerometer.py index 91f5c76..b4a419c 100644 --- a/Sensors/berryAccelerometer.py +++ b/Sensors/berryAccelerometer.py @@ -17,12 +17,13 @@ def __init__(self): sensor.__init__(self) def applySensorReadLogic(self): - rawSensorData = getRawSensorData() - convertedSensorData = convertDataToDeg(rawSensorData) - calibratedSensorData = applyCalibration(convertedSensorData) + rawSensorData = self.getRawSensorData() + convertedSensorData = self.convertDataToDeg(rawSensorData) + calibratedSensorData = self.applyCalibration(convertedSensorData) self.callibratedAccYangle = calibratedSensorData[1] self.callibratedAccXangle = calibratedSensorData[0] - self.normalizeData() + data = [self.callibratedAccXangle, self.callibratedAccYangle] + self.normalizeData(data) def getSensorData(self): #returns finalized sensor data for use outside class @@ -62,7 +63,11 @@ def convertDataToDeg(self, data): convertedSensorData = [AccXangle, AccYangle] return convertedSensorData - def normalizeData(self): + + def normalizeData(self,data): + ACCx = data[0] + ACCy = data[1] + ACCz = IMU.readACCz() self.accXnorm = ACCx/math.sqrt(ACCx * ACCx + ACCy * ACCy + ACCz * ACCz) self.accYnorm = ACCy/math.sqrt(ACCx * ACCx + ACCy * ACCy + ACCz * ACCz) @@ -73,4 +78,4 @@ def getPitch(self): return math.asin(self.accXnorm) def getRoll(self): - return -math.asin(accYnorm/math.cos(self.getPitch)) + return -math.asin(self.accYnorm/math.cos(self.getPitch)) diff --git a/Sensors/berryGyroscope.py b/Sensors/berryGyroscope.py index 5226b08..027c6d2 100644 --- a/Sensors/berryGyroscope.py +++ b/Sensors/berryGyroscope.py @@ -25,10 +25,10 @@ def applySensorReadLogic(self): """ Sensor logic defined to retrieve and calibrate raw sensor data, to be called once per logic iteration """ - rawSensorData = getRawSensorData() - calculateLP() - convertedSensorData = convertDataToDeg(rawSensorData) - applyCalibration(convertedSensorData) + rawSensorData = self.getRawSensorData() + self.calculateLP() + convertedSensorData = self.convertDataToDeg(rawSensorData) + self.applyCalibration(convertedSensorData) def getRawSensorData(self): @@ -50,9 +50,9 @@ def calculateLP(self): self.timeA = datetime.datetime.now() self.LP = self.timeB.microseconds/(1000000*1.0) - def applyFilter(self, gyroxy, loopPeriod, accxy) - self.CFangleX=AA*(self.CFangleX+gyroxy[0]*LP) +(1 - AA) * accxy[0] - self.CFangleY=AA*(self.CFangleY+gyroxy[1]*LP) +(1 - AA) * accxy[1] + def applyFilter(self, gyroxy, loopPeriod, accxy): + self.CFangleX=AA*(self.CFangleX+gyroxy[0]*self.LP) +(1 - AA) * accxy[0] + self.CFangleY=AA*(self.CFangleY+gyroxy[1]*self.LP) +(1 - AA) * accxy[1] def applyCalibration(self, data); #Apply calibration to generate finalized gyro angle data diff --git a/Sensors/berryMagnetometer.py b/Sensors/berryMagnetometer.py index a30d05e..a9369a1 100644 --- a/Sensors/berryMagnetometer.py +++ b/Sensors/berryMagnetometer.py @@ -29,10 +29,10 @@ def applySensorReadLogic(self): """ Sensor logic defined to retrieve and calibrate raw sensor data, to be called once per logic iteration """ - rawSensorData = getRawSensorData() - calibratedSensorData = applyCalibration(rawSensorData) - compensatedTiltValues = calculateTiltCompensatedValues(calibratedSensorData) - self.heading = calculateTiltCompensatedHeading(compensatedTiltValues) + rawSensorData = self.getRawSensorData() + calibratedSensorData = self.applyCalibration(rawSensorData) + compensatedTiltValues = self.calculateTiltCompensatedValues(calibratedSensorData) + self.heading = self.calculateTiltCompensatedHeading(compensatedTiltValues) def getSensorData(self): @@ -40,7 +40,7 @@ def getSensorData(self): return self.heading - def calculateTiltCompensatedHeading(self, data) + def calculateTiltCompensatedHeading(self, data): tiltCompensatedHeading = 180 * math.atan2(data[1],data[0])/M_PI if tiltCompensatedHeading < 0: tiltCompensatedHeading += 360 @@ -65,7 +65,7 @@ def getRawSensorData(self): MAGz = IMU.readMAGz() return [MAGx, MAGy, MAGz] - def applyCalibration(self, data); + def applyCalibration(self, data): mag = data mag[0] -= (self.magXmin + self.magXmax) /2 mag[1] -= (self.magYmin + self.magYmax) /2 diff --git a/Sensors/sensor.py b/Sensors/sensor.py index 3bfdf68..ee255bb 100644 --- a/Sensors/sensor.py +++ b/Sensors/sensor.py @@ -1,5 +1,6 @@ from BerryIMU import IMU import rocketLogger +import logging class sensor: @@ -7,7 +8,7 @@ def __init__(self): logger = rocketLogger() IMU.detectIMU() #Detect if BerryIMU is connected. if(IMU.BerryIMUversion == 99): - logger.debugLog(level=logging.WARNING, "No IMU detected!") + logger.debugLog("No IMU detected!", level=logging.WARNING) IMU.initIMU() def getSensorData(self): @@ -24,7 +25,7 @@ def getRawSensorData(self): """ Returns raw sensor data in format relevent to particular sensor implementation """ - return data + pass def applyCalibration(self, data); #some code to calibrate data here diff --git a/rocketLogger.py b/rocketLogger.py index 9238b26..0ea85fb 100644 --- a/rocketLogger.py +++ b/rocketLogger.py @@ -14,14 +14,14 @@ class rocketLogger: def __init__(self): - formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') - self.dataLogger = setup_logger('data_logger', 'data.log', logging.INFO) - self.debugLogger = setup_logger('debug_logger', 'debug.log') + self.formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') + self.dataLogger = self.setup_logger('data_logger', 'data.log', logging.INFO) + self.debugLogger = self.setup_logger('debug_logger', 'debug.log') - def setup_logger(name, log_file, level=logging.WARNING): + def setup_logger(self, name, log_file, level=logging.WARNING): handler = logging.FileHandler(log_file) - handler.setFormatter(formatter) + handler.setFormatter(self.formatter) logger = logging.getLogger("logs//" + name) logger.setLevel(level) @@ -29,11 +29,11 @@ def setup_logger(name, log_file, level=logging.WARNING): return logger - def dataLog(data_to_log): + def dataLog(self,data_to_log): #Data log should probably always be info level self.dataLoggger.info(data_to_log) - def debugLog(level=logging.WARNING, debug_to_log) + def debugLog(self, debug_to_log, level=logging.WARNING) self.debugLogger.log(level, debug_to_log) diff --git a/run.py b/run.py index cc84402..c56b6c2 100644 --- a/run.py +++ b/run.py @@ -1,12 +1,12 @@ from Sensors import sensor -import berryAccelerometer +from Sensors import berryAccelerometer import rocketLogger logger = rocketLogger() logger.dataLog('AccXangle \t AccYangle \t gyroXangle \t gyroYangle \t gyroZangle \n') -def manageSensors() +def manageSensors(): callSensorLogics() logSensorData() @@ -21,9 +21,8 @@ def logSensorData(): def main(): - initalizeLogger() while True: manageSensors() if __name__=="__main__": -    main() \ No newline at end of file + main() \ No newline at end of file From 004a7c5fb2495410ee03829db9293603bc0d2597 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Thu, 19 Jan 2023 14:07:25 -0600 Subject: [PATCH 10/40] fix semicolon --- Sensors/sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sensors/sensor.py b/Sensors/sensor.py index ee255bb..f7e193a 100644 --- a/Sensors/sensor.py +++ b/Sensors/sensor.py @@ -27,7 +27,7 @@ def getRawSensorData(self): """ pass - def applyCalibration(self, data); + def applyCalibration(self, data): #some code to calibrate data here pass From 26b1e2eddf906e726b94c24a0da2bd9d1a43e241 Mon Sep 17 00:00:00 2001 From: MacHighPowerRocketry Date: Thu, 26 Jan 2023 15:45:36 -0600 Subject: [PATCH 11/40] Debug existing sensor code and integrate to run.py --- BerryIMU/IMU.py | 8 +- BerryIMU/__init__.py | 0 BerryIMU/__pycache__/IMU.cpython-37.pyc | Bin 0 -> 6697 bytes BerryIMU/__pycache__/LIS3MDL.cpython-37.pyc | Bin 0 -> 719 bytes BerryIMU/__pycache__/LSM6DSL.cpython-37.pyc | Bin 0 -> 1239 bytes BerryIMU/__pycache__/LSM9DS0.cpython-37.pyc | Bin 0 -> 2657 bytes BerryIMU/__pycache__/LSM9DS1.cpython-37.pyc | Bin 0 -> 2549 bytes BerryIMU/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 141 bytes Sensors/__init__.py | 0 Sensors/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 140 bytes .../berryAccelerometer.cpython-37.pyc | Bin 0 -> 2962 bytes .../__pycache__/berryGyroscope.cpython-37.pyc | Bin 0 -> 2701 bytes .../berryMagnetometer.cpython-37.pyc | Bin 0 -> 2663 bytes Sensors/__pycache__/sensor.cpython-37.pyc | Bin 0 -> 1508 bytes Sensors/berryAccelerometer.py | 10 +- Sensors/berryGyroscope.py | 8 +- Sensors/berryMagnetometer.py | 10 +- Sensors/sensor.py | 4 +- Servos/__init__.py | 0 __pycache__/rocketLogger.cpython-37.pyc | Bin 0 -> 1583 bytes logs/__init__.py | 0 logs/data.log | 1232 +++++++++++++++++ logs/debug.log | 0 rocketLogger.py | 11 +- rocketrun.service | 6 +- run.py | 26 +- setup_autorunner.sh | 0 todo | 1 + 28 files changed, 1278 insertions(+), 38 deletions(-) create mode 100644 BerryIMU/__init__.py create mode 100644 BerryIMU/__pycache__/IMU.cpython-37.pyc create mode 100644 BerryIMU/__pycache__/LIS3MDL.cpython-37.pyc create mode 100644 BerryIMU/__pycache__/LSM6DSL.cpython-37.pyc create mode 100644 BerryIMU/__pycache__/LSM9DS0.cpython-37.pyc create mode 100644 BerryIMU/__pycache__/LSM9DS1.cpython-37.pyc create mode 100644 BerryIMU/__pycache__/__init__.cpython-37.pyc create mode 100644 Sensors/__init__.py create mode 100644 Sensors/__pycache__/__init__.cpython-37.pyc create mode 100644 Sensors/__pycache__/berryAccelerometer.cpython-37.pyc create mode 100644 Sensors/__pycache__/berryGyroscope.cpython-37.pyc create mode 100644 Sensors/__pycache__/berryMagnetometer.cpython-37.pyc create mode 100644 Sensors/__pycache__/sensor.cpython-37.pyc create mode 100644 Servos/__init__.py create mode 100644 __pycache__/rocketLogger.cpython-37.pyc create mode 100644 logs/__init__.py create mode 100644 logs/data.log create mode 100644 logs/debug.log mode change 100644 => 100755 setup_autorunner.sh create mode 100644 todo diff --git a/BerryIMU/IMU.py b/BerryIMU/IMU.py index fa6f0c7..dd7dd74 100644 --- a/BerryIMU/IMU.py +++ b/BerryIMU/IMU.py @@ -1,9 +1,9 @@ import smbus bus = smbus.SMBus(1) -from LSM9DS0 import * -from LSM9DS1 import * -from LSM6DSL import * -from LIS3MDL import * +from BerryIMU.LSM9DS0 import * +from BerryIMU.LSM9DS1 import * +from BerryIMU.LSM6DSL import * +from BerryIMU.LIS3MDL import * import time diff --git a/BerryIMU/__init__.py b/BerryIMU/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/BerryIMU/__pycache__/IMU.cpython-37.pyc b/BerryIMU/__pycache__/IMU.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ee52c31261fbb17b64ba90d3966fe54e8b131832 GIT binary patch literal 6697 zcmd^D&2JmW72jQQ$tA@vk&-RTcB-V!2i?>%CC5#HHn6@-sUYP-bYOZ9+0vY?%$lNv z;mEZF+9;453$%Ygf!e*LryhIlE$6@|qPH9h0zLH7OHcj1+1=stBe8OJ* zX7@MqH1pQe>7<6=KmYY*^XJz!?JK$oei10QadrO;!8E3~HCuDF7dkUu>b3z(q#e0O zJ&|_QZ%x0A$yRU2?Kq1zEM~IUXPTX0ab}@SvII+_onbR9g*L^~EQ2=9vMh%-!)93? zZI%_-9NHY4XBW`UvWsj1ZJu3Xi)ah%GP{Cyj_Eb6cy)krYP$m+vZ(jCNJ)K3U1u{xVW;QH8MnWXvHzH%qh!pf_D8^q9!<-Vsd~T{3 z5f+2*FM3fHrxr0R86%-$q(ugPV=_ioRYofe`H;J+2V*}WgUYz2P zhDb9qQmSEz*%x_czNB~4@WIo&eQodxpL4JSak_Zt@VLX4)?Lm|cB&sgDJ{KMsa1cn zS-Vl>2B992_}Mh*N&qbt2NL>gLcKHQa8;siZPqGF4Fsy})K;sTmEwRVYO&CdJUs69 zGu&-3=i!NP9o7(ye!(AtQ+}}LtZi=YZPjXaJ}}ptD4=>;0qfO% zeCO^K=ZCy+9`RO3^t0-XUEXaSb^=$Wk(j=#k~4Irf|i`>T3H44M;Ag?`&o>bUR;54 zfgx}Qi1$505Z|C6QPDbZZL`~U-J_yqUkHDOvcui((P5|S+84w2dR2Awb=Bt$t{!^G zcjk43pZS%2X?(28Bf7@MsJcGa_+{|=-_r7x7qjR|qkZhkm-WOIxacROi*?N78g9F^C^VffK{iRHAB`!BOOEMxP?-LV zE?syD>6*}AAi0SsQi0~{GQD-yfuK}Xk=B@qD@06K(Dlv|5K$o765*vU&qqSc5Q5&F znICEENQFHE$w}j%^^BSZJ-$H6!P@1Nh~>)Xly`XwVnA8ArTvzKrfbC%FHjeKHJ%}n zgRp0V33&J8drsZKtRFXRJ8Q#b7GAMx@dS_7E5ULvIi79XsaN=gAdXyB=%6sbQs|+H zpv6evY&4rr+iM>6Q*_rnJb2jZxNMv^@Y-M)(9=2sbQd8sOr|KNR7%f;WXeeC{2lcE zU(?Co#2b7&Iv-5Z`M?34{4KZ|rHY{A^bvL%eLgl!p9d{Q`1j$N|A55XBq*(fR$9Q= z$pP%IW9(gEzH5xxlZ@G4!x%xw86)g8#(Zp;F%NoX#!jD~fwA|_J!4tC;dp+mIOTEE zwo~SFA!v{eL(srPP?;drF2hfdWqZ^DAf?Cs6He)o8l*>RzA-&wEB5sFXQ1x=?;v%Q z$Hu6mJT{HG5vWI<2c4kKLx!o7KrFN(J~6*W;)f)rrADxI@&cW&ON~DQ=6t8d$%RHa zY>X|+Vbj&L z2RX6gC}?2XcB=d$LDkXA-*k=}wkb&-H1;V;QiCK(%{L}VoCu%({R~8|o_8Yoa)^x^ zat}}WOtBG|h>c0&MxetaIgL0#M~Op{#G<=_@VrEV4w6$-B)B^H5}mJ0kvD-k-zjpE zE6QeLTv0lk#?=UPm?Ecf1?VVO@OfsgPQN+>S09AAf<8QI-@>^T$73DG<4=UFA2Q=p z6al0jWf5ODMGSR7&u*fMW-8rcF<-~Qn#GkqgPI=jomcRlfcIDMm=bB0^bskMQ93Go zA$=A#IxkXIs(6Ftefw4MJyuZqlILGm4Ci*eO5i@e=U{=vze)TOLRJd~^e=WGR~(fL1|O36 z8;L)XxDDZz5&lHCUy#@&@edM95XCpWf&%GYEnzOGC2ZW=t2ldG<&smc+7s3lSiMX$ z(e=U92X0NZ{+QgzeS#_-4&#>X3FA%d739I!k6Lm9IHFd9VGgZ`S{d8L2M^o~ybsZ+ zKn`8p-P_sPz2|J)DI=y#l&T~dxIi6p(#gs+5&xL|nqgpCnKZ42^0eI4%A#7l)oD>#@IROxT}sB9VWAF_ zir|tmGj>n*jFBV^^-CPz!gIxWlu-{*aJJ1_b^W;O)%|ioCGxsI>FjY!Y1BfMrm)3( zF-|MPo5xgylvO`jE8s`LuO+{}20|)87C9 literal 0 HcmV?d00001 diff --git a/BerryIMU/__pycache__/LIS3MDL.cpython-37.pyc b/BerryIMU/__pycache__/LIS3MDL.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9992ada62085224c10934c446961debe833bc8a9 GIT binary patch literal 719 zcmZva%TB^j5I|er@3%V__y~#*Dj+*!B-!a=}hmW1;5`T@b&rr)lFCg;hPTT5_xdLpRvY)0thIAh!(J*6|86j z8`{B+4sf6ooah1`5hk{QPPRrRGTQ_QpM9pgat)H+Yl^`e-z%*4onFfKtQB)OFQ2@a;vv Y=D(ycPH@;P^DWwFQ@n^4Co=Q%FEr}600000 literal 0 HcmV?d00001 diff --git a/BerryIMU/__pycache__/LSM6DSL.cpython-37.pyc b/BerryIMU/__pycache__/LSM6DSL.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..75eee9e3a54c55f35baed298e5d276d9ba281ca0 GIT binary patch literal 1239 zcmZ{i+j7!S6ovz(Ev2QLS}3Iljw+rI)ar%fNRx1|;V?;0%VMz<^%#U7YdS zH}DmF1#Z3K0le|by%->b)G+ym{msAEURlYh+wBtg_4E6$i$4xQ_)Ux1W#fNd@O$`; z0|gM!1~#;V9amrl9pJ!KSj9D1!*y6kCpd8fHqZqw+=NZsf-Q7|8@FK_J>Wqvc+m$w z^n)J*5WpSS!ClzJAOtZ4A>4yK3_}?AVV~EFU<3~E01ojGj_?SM@fe~L7ljzcAdYcJ zU;>hu)P!_u{E@df_7JG+v6m1c_y}P_li()!2?4?xK_T2CqzShPcL;Y0_Xtr!j1VUz z2uVVUaD#A@5FxxKydk_LFhYv}gjWQOqnb{QJc?F1ku-(nB}tVvZRDMa^HPoFE36Fu znNj&NFN&s=sH;krH5FqYnWtptrOD)25$2^Qn;tOHFnYeu#6mG^m~vImG9EOSdB``J z>OSHkIBQVTWnQM%sOqxHl>hkB$T!Q^8hVo{)T>#QmQ~A|YB5U+tSOkJj1lq^c}SNl zb+ao?oH4{{XT>E`VrD~qEt};Gb!E;_Q$=Hp)7e8{HkR}Jnamn>rm3P;N(~j}(<-R4 z%nEr$F{)K0{@Mx)6(|w;gZ4U-ll8 ZZa=s4O2d~N4!gr<`H@@n*R3tP{sC(ILdpOD literal 0 HcmV?d00001 diff --git a/BerryIMU/__pycache__/LSM9DS0.cpython-37.pyc b/BerryIMU/__pycache__/LSM9DS0.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f708d800a94d7045732cac05c4030ebbf52bf90c GIT binary patch literal 2657 zcmb7`$#UC95Qar-UuaqTzOU5AU5hO*5DAiq2~r`TNbCzL2R}`!a?2a! z74izY=A>81Dg8qNKoN6r$l_PvkDi(SryE0_M5BFe^7`xdzduFf>K}aZUJ<$YAfLOk zTyY!W6X6KG;1|@+?bN{?)XAOH#a-0R-PFT9)XTlp$9>e#{WQP>6y+$r$J%m6yr_W;uvl77VYph?eY%o@h-)Aj}jcGquf#iQE`5$qTUW@IgFi;^9O*Jm}(~ARdb1 zp(Gv*@$ij!_$VIAoFbFcRN)L&IZLO!Pv7!^)fPK^n3sKh_z4&U7J(&T8CU^Ufi++Q z*aTw07O)NM0K32*5C;-K5=a4QAOmE9ec%8%1Ui8(pd07`dI5CBLq9M8M1f&o1Q-Rz zfN@{~m;|PPX!IDUITA{W8kfz606;hlr8fpZzUX4D>_;}U(+os5Vc$` zEEelEUmW&^pO>nRW;%vb3`XbdTG^@T#iUate;rRusl>Euct#bOZ5C^KL9gkRoG#+1 zmyu;__L+tCWzr!}t)AJ=g;NeorBFvhQX$vX(RFn+siO(ezC|~a{8>%2jcTQN zQS7#@o2Rl#7iN%)FP9*zDrSZ&7LrO%i-d}Wq)-$p))Iw^nL*$By)4Q3)e?_E6`Q<3 z_ljr+Z4Mc=k+s62tQNSg77CXB*pw<&73&%e&4BI<&*0h(#k!7z#DWLtLM7H!A_bFr z-JOtf-uvbB)TB~PJuAHzn^vkB>B&A*;g*I13D;G#P z{sR8ln=2c+k2u+=MZ&}_5+?OeMB6ZRr)-#p9cb408}XaVc)oG>^RL%8@zdMJr^~y`>#OqjSA2Q(L;R$1d;7&O&*D#ewRiL7 lzUTP!HUIWY;~oB(-Tfixh{(I$C9b~q{r^XN?aZOL{{Tlpz+nIY literal 0 HcmV?d00001 diff --git a/BerryIMU/__pycache__/LSM9DS1.cpython-37.pyc b/BerryIMU/__pycache__/LSM9DS1.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6356fe53629e480a32236fd2295eb92734d20afa GIT binary patch literal 2549 zcmcJQ$yVc55QYuS3~uIm9vU!{JVKMuoi?^CJF#qzWD;DPdvdybx=GT&fn?FIl1WZ{`l?B_aEf$FZ^&mU2^kI zu7@+Z;|N8#i@N0M=5BhyFQ|umsF!=GkNc>f`)Pm&XpjeKh=*vHhiQaID9TZK$uDV? zM`?`5Xq?Asf+uK_CuxeOXqu;KhG%G&XK9Y-XkL64c%Bw{ftGlYmU)R*c$rpth1PhL z)_ILKc%3$RgSL2+Uhx)f^DElnZQA7>it#S(ag6qPj}CaB4*7tN_>eR{qBv`m;5a2Y zK`BmBT5`xp4#$$iiRAEFayXS7zL0f)DZXdo`$l}d~@I=f~mTn~Ed9H~gCd0&(GMZD4bJZ&8QV-O^plL^S zN@QC(ktZCvdMUNl%?niy(Te0g)UIV~mo`?V;!QV6%)U}(ara3@zf=!K)m0#hf>G2S z<&+`qfGB|Q*6QtvpY-f<3f zoI{us=xH3t7W-;a5RV Tmwfx4h`ayq+xwrMEz$n~2??n@ literal 0 HcmV?d00001 diff --git a/BerryIMU/__pycache__/__init__.cpython-37.pyc b/BerryIMU/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..51c090efd24e783cdc4b79869b48bf3fd56c9f93 GIT binary patch literal 141 zcmZ?b<>g`kf{AY~C4=b4AOZ#$feZ&AE@lA|DGb33nv8xc8Hzx{2;!HSenx(7s(wMH zzDsIxc1eDLen3%ba%OR6ex6TaUP@+Oy1r9tQBkF*Z>WBJd}dx|NqoFsLFFwDo80`A O(wtN~ka?ehm;nH=Y9ast literal 0 HcmV?d00001 diff --git a/Sensors/__init__.py b/Sensors/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Sensors/__pycache__/__init__.cpython-37.pyc b/Sensors/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3e827c160c388f844a0b92a7ef47bf87c54e12c3 GIT binary patch literal 140 zcmZ?b<>g`kg1K)lC4=b4AOZ#$feZ&AE@lA|DGb33nv8xc8Hzx{2;!Hienx(7s(wMH zzDsIxc1eDLen3%ba%OR6ex6TaUP@+Ox_)qKUU7a=v3`7fW?p7Ve7s&k<@@t<(xXmLQ|)H64@@O$GVyGc{P$-MXMc{B6o_daH>HySmD=jT6v z?fg(>><@aGJQ6|+E%_QmF~uX+<1XhUTao2jh6`7Ki%9lLZfV?CcFU%(;#Lf|U0X@F zs!DF{CR1fqdBs#E;NJ^(Nm=(<(|(N=Sd-`FB{djab>+?FiI#1E>%gD!Aq*5Z1A$Gsv3AjEvY)Vtr}_> zysD0<74Vums*Zs#spD!Dysl2bz<2Uvj{~g-*E*db3Uu5H(m;1;eR_x!SQ}``3P{TK zdB!q6vIr22=bKGSlUi)6n;6mIP^5lPrTUZu8psSLega3w*F>{L~+W75UHjqYeSsQsW`ziwP%MMjrub zaO4UzIY@LTF(K_Bz#Sc=d%B-EKK@$!gXu&~sVPKrTLbQE z8ynwFrNLAhj=h~rqd;_EOcj(iyheT-UR;dOOxRA-pFo=W>Jz+V zobm%1gHi-eSt6cEeF0ov#e3g|RQi;92sFwV0kzSvHxd*RZ&DKwOzT*J*Ae#UE1fHPR!JW}rDm z`lpGUAuGm~Q_7Y^$^LJ098+O$4bbQfgH)ThDas#cMBP zr^&7y35oJYz$rO$2k!AAv|FdBg_X2~QYqc^0@8*@K!_o6Oa{x|wTu4Z|JJk+#>A zHLtbCWL-9%Gucr5d&`@X;sNV8FYpD{;YB@Fahm8&h}Qb&U-ka};@7J`{PoMN-cLVL z`~6lx3y+(Ca2q|{08z~2lHpKXisuZ6vZM`e%bKi%*JMLF;C0!QE%1h%lWlNE&dUYx zraUJX!CUe?4s@Ydc&xM@t&Mb&2FXwb^et+{37EU+>4zX0JLEab`H|o(6Mb=L9kHDG zw#2AkGqi4K!%)Z2reyev*z7@pX`PlP&4uIpVH{?@UpTUxsVp3*!itl7SWi#OMC~Xys`#P%Fc5<(^8v z$&%s9mR3QShDp59jb#}3Rvs9Sq${WKSRRga4I0j&rwbsAxAD{`&-l{J@?*0CPHWMu zNjEs&z)Q{!*%3PcYKQ!Yae5a(l^+O5RxXYx@HnA1-fOv&RvylUQDNXp^(2gybhE_O zD$}8Qrd$}|2HhxptbwMhyL)aKVJ^_^-lV0E6)lLcFNp)?4was$3p0gHK%)BEX2&iT zdn()R?v)?D2PMTEwgumQ%a}Is*|izWX5C!jMFC8yYVdjoLdN$z=sBd_K4yn*WAaq`a z`TJ8cJXej6^(9(O*HuZV66z(8+vq6;0E2;4`p!(`*@Ap3kt-ufJzPK?H&9>ntkMXp zbioPwXXZ{Zk8*KRw%6%kR3jK4Uzy3EQwujcb9Cd!-GRc5-}3!IB6lN_+rIzpZZ|4t z%uTDQ&YSY3DO2^EM99wu3*8~<1SBIFq$oZqH&PmMgwu3dc$$vwG@PcU*-qPAC=Z`5 zr{=aV|3z%`_hF-aKP{X)^gD!KGEfjj7@iq_tg|E`wBaK_i$N9As+2%gsTD;iC6OoGO`gCfR`6S333kz+A_QzkpM{njB z`;$JV%?7iEo;?PUO!9>FdB8dGA`yWwqZL>ft;Fs-fm6@9fotYkLCcI@;7L1}yTha- z-PcUIivMf{Z7CkIPHP{#vkouaOr_aCZ-KS$Zhqf8^V!Cue=g3gMKnKc0?ZnEwgIA8 zz$JqnT#DBWc39HJXjfVSN4BJgZ&%LAHpZ4bCg(AFazQR)oRi0)f2ln2RB1ih411}{ z2Yr<*9g!MpG*TGW(X%f=a`uK7tl$#?SHX3m9Mm$@HqqcFR^j>^<(ssbQW>nPAF1?uWbeRLunVrz1)`Q^~W^O$NQ5(!Vmjh;9GAwYm-K zSBLTHhRR;#gW>9Zt)e)K2kE^qm2uizeP|+_tsZgs>TskTY(g7lL>QlUT|WJd&mLVd zbt1Az9L+_iJxr{wfhpJ#cBMi?bod` z)rX654wKP(tpxJr$Jj91NucpjoaF0+{tywx zm;512c2rhgc;EcDDx?gQt?i2GxOyHTDxG1RN86>X2T4*cz>5Rwm$6ypo_zana58$U zm5it~n-ZwVaoTs;m|iV=0G0PBj^{Cxc_7U8c$+Ws@#Uj=eb>T>%9k3A)J={l;RSn6 z70!WLy^L=RX{u`E>mv-M6%De|%Hp)fm-b2GB#~1ffky`}*=)Ec#LZ^$1IS%R&nWuL{e*wV z$JhRU4l6h|fT2`U<(jI!1ct(oLy>A%U=$cFb4Viah1IhNOyjl2&pIML>~3x+f7c(G z*o^Ct`{8VOI<_XQrKf@Y&2R4PHr%M;#t>;&E4=Lwko&*DR&sai!%hBpT@J|9Qz9Ky2%K@^_;+*H8UsbIov4Eox^ifuho64 zFG5jO9<~qlM#p>kEu4d-?uO1IvKW7kX}s4*&oF literal 0 HcmV?d00001 diff --git a/Sensors/__pycache__/sensor.cpython-37.pyc b/Sensors/__pycache__/sensor.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..20c305c2f1b0cd903b98c00278faae03b3aae6de GIT binary patch literal 1508 zcmb7EPjAyO6t|tENxOEd&?JzMP}r>!S`XaNgvK^$nlviZfsk?uS?m?BX%ZZF)2iLr zmG3Z)d;vZP$6Pt>!Uy2Qd-+psWgEhkpY8hR-+RC3=WKO4EduSuuOH!egOH!Ns2i-w zCiH9_3@4mMWI{bkan2&9N6?HjgcCd||kA*+2v*z-SJxFxFXjkhl=I%Y_!9 z7W^qFu_AFIqMohLiPtQ*0OYM~38l_pb|O?JlNh2Chttu1GRo~J8I5E-^6dAohJ(Gq zu4l_wYQXkbZe}7n${Pp~>Kjo_;Qjr)|1p_}ek%JrA{*-@?Y~hXl*qdu#2mQ#2ZiRW zUus`Z&vM82k=FNZ)a`&F%%LsXrL&a^RU<-*yU=jNUZe_hRwRH9iZFUqAyqLi4VFpX z83|o_-wAZE41Z-s=Gknua&rT4k1q2pOQb!gBS`uRdKec#g(ypl&DFdK|GdRtWjMWC@sTj6sTIboTQPM z!1jM=>%#pEgVRzR-r=Kbx*k@#7BM$o*WD$-6;>p}Eo7H|7 zF?aht$MUI5weoA71kqIdtL0iG_^=f|AZ38Dpl5i>VUF#XP6K{svD33Wr~Z}{ kUzxnEl5i|ElpuT}RHLT2jXQTX$}nHz6=jHRQ-?b253=N5LI3~& literal 0 HcmV?d00001 diff --git a/Sensors/berryAccelerometer.py b/Sensors/berryAccelerometer.py index b4a419c..5d5a34c 100644 --- a/Sensors/berryAccelerometer.py +++ b/Sensors/berryAccelerometer.py @@ -1,4 +1,4 @@ -import sensor +from Sensors.sensor import sensor import time import math @@ -13,8 +13,8 @@ class berryAccelerometer(sensor): - def __init__(self): - sensor.__init__(self) + def __init__(self,logger): + sensor.__init__(self,logger) def applySensorReadLogic(self): rawSensorData = self.getRawSensorData() @@ -27,7 +27,7 @@ def applySensorReadLogic(self): def getSensorData(self): #returns finalized sensor data for use outside class - return [self.callibratedAccYangle. self.callibratedAccXangle] + return [self.callibratedAccYangle, self.callibratedAccXangle] def getRawSensorData(self): """ @@ -78,4 +78,4 @@ def getPitch(self): return math.asin(self.accXnorm) def getRoll(self): - return -math.asin(self.accYnorm/math.cos(self.getPitch)) + return -math.asin(self.accYnorm/math.cos(self.getPitch())) diff --git a/Sensors/berryGyroscope.py b/Sensors/berryGyroscope.py index 027c6d2..45e0997 100644 --- a/Sensors/berryGyroscope.py +++ b/Sensors/berryGyroscope.py @@ -1,4 +1,4 @@ -import sensor +from Sensors.sensor import sensor import time import math @@ -12,8 +12,8 @@ class berryGyroscope(sensor): - def __init__(self): - sensor.__init__(self) + def __init__(self, logger): + sensor.__init__(self, logger) self.timeA = datetime.datetime.now() self.gyroXangle = 0.0 self.gyroYangle = 0.0 @@ -54,7 +54,7 @@ def applyFilter(self, gyroxy, loopPeriod, accxy): self.CFangleX=AA*(self.CFangleX+gyroxy[0]*self.LP) +(1 - AA) * accxy[0] self.CFangleY=AA*(self.CFangleY+gyroxy[1]*self.LP) +(1 - AA) * accxy[1] - def applyCalibration(self, data); + def applyCalibration(self, data): #Apply calibration to generate finalized gyro angle data x,y,z = data self.gyroXangle+=x*self.LP diff --git a/Sensors/berryMagnetometer.py b/Sensors/berryMagnetometer.py index a9369a1..28d4a10 100644 --- a/Sensors/berryMagnetometer.py +++ b/Sensors/berryMagnetometer.py @@ -1,4 +1,4 @@ -import sensor +from Sensors.sensor import sensor import time import math from BerryIMU import IMU @@ -11,8 +11,8 @@ class berryMagnetometer(sensor): - def __init__(self): - sensor.__init__(self) + def __init__(self, logger): + sensor.__init__(self, logger) ################# Compass Calibration values ############ # Use calibrateBerryIMU.py to get calibration values @@ -25,13 +25,13 @@ def __init__(self): self.magYmax = 0 self.magZmax = 0 - def applySensorReadLogic(self): + def applySensorReadLogic(self, pitch, roll): """ Sensor logic defined to retrieve and calibrate raw sensor data, to be called once per logic iteration """ rawSensorData = self.getRawSensorData() calibratedSensorData = self.applyCalibration(rawSensorData) - compensatedTiltValues = self.calculateTiltCompensatedValues(calibratedSensorData) + compensatedTiltValues = self.calculateTiltCompensatedValues(calibratedSensorData, pitch, roll) self.heading = self.calculateTiltCompensatedHeading(compensatedTiltValues) diff --git a/Sensors/sensor.py b/Sensors/sensor.py index f7e193a..875687e 100644 --- a/Sensors/sensor.py +++ b/Sensors/sensor.py @@ -4,8 +4,8 @@ class sensor: - def __init__(self): - logger = rocketLogger() + def __init__(self, logger): + #logger = rocketLogger() IMU.detectIMU() #Detect if BerryIMU is connected. if(IMU.BerryIMUversion == 99): logger.debugLog("No IMU detected!", level=logging.WARNING) diff --git a/Servos/__init__.py b/Servos/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/__pycache__/rocketLogger.cpython-37.pyc b/__pycache__/rocketLogger.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6bfdc5b31e52046d42671df8b1ce514e6c718952 GIT binary patch literal 1583 zcmZuxL66)t6t=3|M|0g7ZUOp9`+*u z;d7YwBUmKiL{iCW%IQlY0~uZu8UD^Vlk9tvN5x}GNP3}{%c@zX=?nGKW|`G`X|rjm zrOK4i#@Ms$O<@}F07;eYS+=oiv8n59p-m?74qngjMh-!Ww!j!(H?^v<=mkoD863VY zswOMz!rJVO-qbRyR%>nAti4p3(dBE^A|PdYpEJ~he*yVa1#%w@T&5UQv|2#2JljL@ z2E=r0k!r0Pi3oM$la#t?)!R0k!bOkr03^ooPp_=qC<}1^1|G@0#C1PzIsOzhif{@% zGvxW2@IZxE(SmxeDIdv5jzAj^+E^ynlqYfw?5A#W_}mgo;Ro&!%r9Zur?9l-hDy4l z9TBV}H-Tg_XvtN$3qTWjO(>%s*u+Q@h&-BaPfw?XE!%3Pa+{q_YxRq&n_@Vvl(oeY zEd0oGh&(8>J%-)RQ1b*NKJleRcF}m!80<`k+xi+h!ZIy9jXo*3bSk-RU z!*w3MnxB8;QVf3K1G*z0zCYyDg;v#zKZqH_ga7?xcBxltwytI`lzrXm_3T@t%F0%{ zxhQ-sXNS~1S^w%1A*!Zog?Jxn8^J>8gg&6#hj%>pUL|}texN7Hp6zEKAln_=(ci)@ zya7(Hf*qx(4JGa9BLbGFi*BOM>p>cIA$oKXFwf@O5zu01vphD~Cj98Us?}Ejx>klG zC%0r7Ov}g1eZTVrtQS})o)%ILck+=*z|VzPJ)S^tv4Ds!@+IZ*WgpsMTBwufuV3&V zVX%=N!n6}u2uwnPu$Fu-5{gdGBj!R7)WA`f~T zLkkZ;j=_8%O|tL8kHOf(x!*E-k9j`EF2gzq;Zh-1T5f8TCqn$ZDg5^(ggL@Ah}p$I zeDU4<)%>Nef Date: Thu, 26 Jan 2023 16:20:53 -0600 Subject: [PATCH 12/40] upload pressure sensor test --- README.md | 6 +- Sensors/pressureSensorTest.py | 220 ++++++++++++++++++++++++++++++++++ requirements.txt | 1 + 3 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 Sensors/pressureSensorTest.py create mode 100644 requirements.txt diff --git a/README.md b/README.md index 07e9d5d..3d715b2 100644 --- a/README.md +++ b/README.md @@ -17,5 +17,7 @@ Controller class, grabs sensor data from sensor.py, sends to both datalogger.py Setup: 1. Clone the repo both on your local machine and the rocket's raspberry pi. -2. On the raspberry pi, enable SSH and GPIO On the raspberry pi. -3. run Autorun/setup_autorunner.sh to allow the code to run on boot +2. Run pip install -r requirements.txt +3. On the raspberry pi, enable SSH and GPIO On the raspberry pi. +4. run Autorun/setup_autorunner.sh to allow the code to run on boot + diff --git a/Sensors/pressureSensorTest.py b/Sensors/pressureSensorTest.py new file mode 100644 index 0000000..7d4819d --- /dev/null +++ b/Sensors/pressureSensorTest.py @@ -0,0 +1,220 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import time +import smbus +import math + +# define BMP388 Device I2C address + +I2C_ADD_BMP388_AD0_LOW = 0x76 +I2C_ADD_BMP388_AD0_HIGH = 0x77 +I2C_ADD_BMP388 = I2C_ADD_BMP388_AD0_HIGH + +BMP388_REG_ADD_WIA = 0x00 +BMP388_REG_VAL_WIA = 0x50 + +BMP388_REG_ADD_ERR = 0x02 +BMP388_REG_VAL_FATAL_ERR = 0x01 +BMP388_REG_VAL_CMD_ERR = 0x02 +BMP388_REG_VAL_CONF_ERR = 0x04 + +BMP388_REG_ADD_STATUS = 0x03 +BMP388_REG_VAL_CMD_RDY = 0x10 +BMP388_REG_VAL_DRDY_PRESS = 0x20 +BMP388_REG_VAL_DRDY_TEMP = 0x40 + +BMP388_REG_ADD_CMD = 0x7E +BMP388_REG_VAL_EXTMODE_EN = 0x34 +BMP388_REG_VAL_FIFI_FLUSH = 0xB0 +BMP388_REG_VAL_SOFT_RESET = 0xB6 + +BMP388_REG_ADD_PWR_CTRL = 0x1B +BMP388_REG_VAL_PRESS_EN = 0x01 +BMP388_REG_VAL_TEMP_EN = 0x02 +BMP388_REG_VAL_NORMAL_MODE = 0x30 + +BMP388_REG_ADD_PRESS_XLSB = 0x04 +BMP388_REG_ADD_PRESS_LSB = 0x05 +BMP388_REG_ADD_PRESS_MSB = 0x06 +BMP388_REG_ADD_TEMP_XLSB = 0x07 +BMP388_REG_ADD_TEMP_LSB = 0x08 +BMP388_REG_ADD_TEMP_MSB = 0x09 + +BMP388_REG_ADD_T1_LSB = 0x31 +BMP388_REG_ADD_T1_MSB = 0x32 +BMP388_REG_ADD_T2_LSB = 0x33 +BMP388_REG_ADD_T2_MSB = 0x34 +BMP388_REG_ADD_T3 = 0x35 +BMP388_REG_ADD_P1_LSB = 0x36 +BMP388_REG_ADD_P1_MSB = 0x37 +BMP388_REG_ADD_P2_LSB = 0x38 +BMP388_REG_ADD_P2_MSB = 0x39 +BMP388_REG_ADD_P3 = 0x3A +BMP388_REG_ADD_P4 = 0x3B +BMP388_REG_ADD_P5_LSB = 0x3C +BMP388_REG_ADD_P5_MSB = 0x3D +BMP388_REG_ADD_P6_LSB = 0x3E +BMP388_REG_ADD_P6_MSB = 0x3F +BMP388_REG_ADD_P7 = 0x40 +BMP388_REG_ADD_P8 = 0x41 +BMP388_REG_ADD_P9_LSB = 0x42 +BMP388_REG_ADD_P9_MSB = 0x43 +BMP388_REG_ADD_P10 = 0x44 +BMP388_REG_ADD_P11 = 0x45 + +class BMP388(object): + + """docstring for BMP388""" + + def __init__(self, address=I2C_ADD_BMP388): + self._address = address + self._bus = smbus.SMBus(0x01) + + # Load calibration values. + + if self._read_byte(BMP388_REG_ADD_WIA) == BMP388_REG_VAL_WIA: + print("Pressure sersor is BMP388!\r\n") + u8RegData = self._read_byte(BMP388_REG_ADD_STATUS) + if u8RegData & BMP388_REG_VAL_CMD_RDY: + self._write_byte(BMP388_REG_ADD_CMD, + BMP388_REG_VAL_SOFT_RESET) + time.sleep(0.01) + else: + print ("Pressure sersor NULL!\r\n") + self._write_byte(BMP388_REG_ADD_PWR_CTRL, + BMP388_REG_VAL_PRESS_EN + | BMP388_REG_VAL_TEMP_EN + | BMP388_REG_VAL_NORMAL_MODE) + self._load_calibration() + + def _read_byte(self, cmd): + return self._bus.read_byte_data(self._address, cmd) + + def _read_s8(self, cmd): + result = self._read_byte(cmd) + if result > 128: + result -= 256 + return result + + def _read_u16(self, cmd): + LSB = self._bus.read_byte_data(self._address, cmd) + MSB = self._bus.read_byte_data(self._address, cmd + 0x01) + return (MSB << 0x08) + LSB + + def _read_s16(self, cmd): + result = self._read_u16(cmd) + if result > 32767: + result -= 65536 + return result + + def _write_byte(self, cmd, val): + self._bus.write_byte_data(self._address, cmd, val) + + def _load_calibration(self): + print ("_load_calibration\r\n") + self.T1 = self._read_u16(BMP388_REG_ADD_T1_LSB) + self.T2 = self._read_u16(BMP388_REG_ADD_T2_LSB) + self.T3 = self._read_s8(BMP388_REG_ADD_T3) + self.P1 = self._read_s16(BMP388_REG_ADD_P1_LSB) + self.P2 = self._read_s16(BMP388_REG_ADD_P2_LSB) + self.P3 = self._read_s8(BMP388_REG_ADD_P3) + self.P4 = self._read_s8(BMP388_REG_ADD_P4) + self.P5 = self._read_u16(BMP388_REG_ADD_P5_LSB) + self.P6 = self._read_u16(BMP388_REG_ADD_P6_LSB) + self.P7 = self._read_s8(BMP388_REG_ADD_P7) + self.P8 = self._read_s8(BMP388_REG_ADD_P8) + self.P9 = self._read_s16(BMP388_REG_ADD_P9_LSB) + self.P10 = self._read_s8(BMP388_REG_ADD_P10) + self.P11 = self._read_s8(BMP388_REG_ADD_P11) + + # print(self.T1) + # print(self.T2) + # print(self.T3) + # print(self.P1) + # print(self.P2) + # print(self.P3) + # print(self.P4) + # print(self.P5) + # print(self.P6) + # print(self.P7) + # print(self.P8) + # print(self.P9) + # print(self.P10) + # print(self.P11) + + def compensate_temperature(self, adc_T): + partial_data1 = adc_T - 256 * self.T1 + partial_data2 = self.T2 * partial_data1 + partial_data3 = partial_data1 * partial_data1 + partial_data4 = partial_data3 * self.T3 + partial_data5 = partial_data2 * 262144 + partial_data4 + partial_data6 = partial_data5 / 4294967296 + self.T_fine = partial_data6 + comp_temp = partial_data6 * 25 / 16384 + return comp_temp + + def compensate_pressure(self, adc_P): + partial_data1 = self.T_fine * self.T_fine + partial_data2 = partial_data1 / 0x40 + partial_data3 = partial_data2 * self.T_fine / 256 + partial_data4 = self.P8 * partial_data3 / 0x20 + partial_data5 = self.P7 * partial_data1 * 0x10 + partial_data6 = self.P6 * self.T_fine * 4194304 + offset = self.P5 * 140737488355328 + partial_data4 \ + + partial_data5 + partial_data6 + + partial_data2 = self.P4 * partial_data3 / 0x20 + partial_data4 = self.P3 * partial_data1 * 0x04 + partial_data5 = (self.P2 - 16384) * self.T_fine * 2097152 + sensitivity = (self.P1 - 16384) * 70368744177664 \ + + partial_data2 + partial_data4 + partial_data5 + + partial_data1 = sensitivity / 16777216 * adc_P + partial_data2 = self.P10 * self.T_fine + partial_data3 = partial_data2 + 65536 * self.P9 + partial_data4 = partial_data3 * adc_P / 8192 + partial_data5 = partial_data4 * adc_P / 512 + partial_data6 = adc_P * adc_P + partial_data2 = self.P11 * partial_data6 / 65536 + partial_data3 = partial_data2 * adc_P / 128 + partial_data4 = offset / 0x04 + partial_data1 + partial_data5 \ + + partial_data3 + comp_press = partial_data4 * 25 / 1099511627776 + return comp_press + + def get_temperature_and_pressure_and_altitude(self): + """Returns pressure in Pa as double. Output value of "6386.2"equals 96386.2 Pa = 963.862 hPa.""" + + xlsb = self._read_byte(BMP388_REG_ADD_TEMP_XLSB) + lsb = self._read_byte(BMP388_REG_ADD_TEMP_LSB) + msb = self._read_byte(BMP388_REG_ADD_TEMP_MSB) + adc_T = (msb << 0x10) + (lsb << 0x08) + xlsb + temperature = self.compensate_temperature(adc_T) + xlsb = self._read_byte(BMP388_REG_ADD_PRESS_XLSB) + lsb = self._read_byte(BMP388_REG_ADD_PRESS_LSB) + msb = self._read_byte(BMP388_REG_ADD_PRESS_MSB) + + adc_P = (msb << 0x10) + (lsb << 0x08) + xlsb + pressure = self.compensate_pressure(adc_P) + altitude = 4433000 * (0x01 - pow(pressure / 100.0 / 101325.0, + 0.1903)) + + return (temperature, pressure, altitude) + +if __name__ == '__main__': + + import time + + print("BMP388 Test Program ...\n") + + bmp388 = BMP388() + + while True: + time.sleep(0.5) + temperature,pressure,altitude = bmp388.get_temperature_and_pressure_and_altitude() + print(' Temperature = %.1f Pressure = %.2f Altitude =%.2f '%(temperature/100.0,pressure/100.0,altitude/100.0)) + + + + + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c550f95 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +smbus \ No newline at end of file From c11a95e12026495ad5a6fff8aaf8716c072afbe5 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Thu, 26 Jan 2023 20:50:21 -0600 Subject: [PATCH 13/40] Integrate pressure sensor, add toString() --- BerryIMU/BMP388.py | 57 +++++++++++++ Sensors/berryAccelerometer.py | 3 + Sensors/berryGyroscope.py | 3 + Sensors/berryMagnetometer.py | 3 +- ...ressureSensorTest.py => pressureSensor.py} | 84 ++----------------- run.py | 16 ++-- 6 files changed, 85 insertions(+), 81 deletions(-) create mode 100644 BerryIMU/BMP388.py rename Sensors/{pressureSensorTest.py => pressureSensor.py} (73%) diff --git a/BerryIMU/BMP388.py b/BerryIMU/BMP388.py new file mode 100644 index 0000000..e9a4c72 --- /dev/null +++ b/BerryIMU/BMP388.py @@ -0,0 +1,57 @@ +# define BMP388 Device I2C address + +I2C_ADD_BMP388_AD0_LOW = 0x76 +I2C_ADD_BMP388_AD0_HIGH = 0x77 +I2C_ADD_BMP388 = I2C_ADD_BMP388_AD0_HIGH + +BMP388_REG_ADD_WIA = 0x00 +BMP388_REG_VAL_WIA = 0x50 + +BMP388_REG_ADD_ERR = 0x02 +BMP388_REG_VAL_FATAL_ERR = 0x01 +BMP388_REG_VAL_CMD_ERR = 0x02 +BMP388_REG_VAL_CONF_ERR = 0x04 + +BMP388_REG_ADD_STATUS = 0x03 +BMP388_REG_VAL_CMD_RDY = 0x10 +BMP388_REG_VAL_DRDY_PRESS = 0x20 +BMP388_REG_VAL_DRDY_TEMP = 0x40 + +BMP388_REG_ADD_CMD = 0x7E +BMP388_REG_VAL_EXTMODE_EN = 0x34 +BMP388_REG_VAL_FIFI_FLUSH = 0xB0 +BMP388_REG_VAL_SOFT_RESET = 0xB6 + +BMP388_REG_ADD_PWR_CTRL = 0x1B +BMP388_REG_VAL_PRESS_EN = 0x01 +BMP388_REG_VAL_TEMP_EN = 0x02 +BMP388_REG_VAL_NORMAL_MODE = 0x30 + +BMP388_REG_ADD_PRESS_XLSB = 0x04 +BMP388_REG_ADD_PRESS_LSB = 0x05 +BMP388_REG_ADD_PRESS_MSB = 0x06 +BMP388_REG_ADD_TEMP_XLSB = 0x07 +BMP388_REG_ADD_TEMP_LSB = 0x08 +BMP388_REG_ADD_TEMP_MSB = 0x09 + +BMP388_REG_ADD_T1_LSB = 0x31 +BMP388_REG_ADD_T1_MSB = 0x32 +BMP388_REG_ADD_T2_LSB = 0x33 +BMP388_REG_ADD_T2_MSB = 0x34 +BMP388_REG_ADD_T3 = 0x35 +BMP388_REG_ADD_P1_LSB = 0x36 +BMP388_REG_ADD_P1_MSB = 0x37 +BMP388_REG_ADD_P2_LSB = 0x38 +BMP388_REG_ADD_P2_MSB = 0x39 +BMP388_REG_ADD_P3 = 0x3A +BMP388_REG_ADD_P4 = 0x3B +BMP388_REG_ADD_P5_LSB = 0x3C +BMP388_REG_ADD_P5_MSB = 0x3D +BMP388_REG_ADD_P6_LSB = 0x3E +BMP388_REG_ADD_P6_MSB = 0x3F +BMP388_REG_ADD_P7 = 0x40 +BMP388_REG_ADD_P8 = 0x41 +BMP388_REG_ADD_P9_LSB = 0x42 +BMP388_REG_ADD_P9_MSB = 0x43 +BMP388_REG_ADD_P10 = 0x44 +BMP388_REG_ADD_P11 = 0x45 \ No newline at end of file diff --git a/Sensors/berryAccelerometer.py b/Sensors/berryAccelerometer.py index 5d5a34c..23bb21c 100644 --- a/Sensors/berryAccelerometer.py +++ b/Sensors/berryAccelerometer.py @@ -79,3 +79,6 @@ def getPitch(self): def getRoll(self): return -math.asin(self.accYnorm/math.cos(self.getPitch())) + + def toString(self): + return "Pitch %s Roll %s Accelerometer X Angle %s Acceleromter Y Angle %s" % (self.getPitch(), self.getRoll, self.callibratedAccXangle, self.callibratedAccYangle) diff --git a/Sensors/berryGyroscope.py b/Sensors/berryGyroscope.py index 45e0997..daa5266 100644 --- a/Sensors/berryGyroscope.py +++ b/Sensors/berryGyroscope.py @@ -73,4 +73,7 @@ def convertDataToDeg(self, data): def getSensorData(self): return [self.gyroXangle, self.gyroYangle, self.gyroZangle] + def toString(self): + return "Gyroscope X Angle, Gyroscope Y Angle, Gyroscope Z Angle %s "%(self.gyroXangle,self.gyroYangle,self.gyroZangle) + diff --git a/Sensors/berryMagnetometer.py b/Sensors/berryMagnetometer.py index 28d4a10..050f9d5 100644 --- a/Sensors/berryMagnetometer.py +++ b/Sensors/berryMagnetometer.py @@ -72,4 +72,5 @@ def applyCalibration(self, data): mag[2] -= (self.magZmin + self.magZmax) /2 return mag - + def toString(self): + return "Heading %s "%(self.heading) \ No newline at end of file diff --git a/Sensors/pressureSensorTest.py b/Sensors/pressureSensor.py similarity index 73% rename from Sensors/pressureSensorTest.py rename to Sensors/pressureSensor.py index 7d4819d..2c59d75 100644 --- a/Sensors/pressureSensorTest.py +++ b/Sensors/pressureSensor.py @@ -4,83 +4,29 @@ import smbus import math -# define BMP388 Device I2C address - -I2C_ADD_BMP388_AD0_LOW = 0x76 -I2C_ADD_BMP388_AD0_HIGH = 0x77 -I2C_ADD_BMP388 = I2C_ADD_BMP388_AD0_HIGH - -BMP388_REG_ADD_WIA = 0x00 -BMP388_REG_VAL_WIA = 0x50 - -BMP388_REG_ADD_ERR = 0x02 -BMP388_REG_VAL_FATAL_ERR = 0x01 -BMP388_REG_VAL_CMD_ERR = 0x02 -BMP388_REG_VAL_CONF_ERR = 0x04 - -BMP388_REG_ADD_STATUS = 0x03 -BMP388_REG_VAL_CMD_RDY = 0x10 -BMP388_REG_VAL_DRDY_PRESS = 0x20 -BMP388_REG_VAL_DRDY_TEMP = 0x40 - -BMP388_REG_ADD_CMD = 0x7E -BMP388_REG_VAL_EXTMODE_EN = 0x34 -BMP388_REG_VAL_FIFI_FLUSH = 0xB0 -BMP388_REG_VAL_SOFT_RESET = 0xB6 - -BMP388_REG_ADD_PWR_CTRL = 0x1B -BMP388_REG_VAL_PRESS_EN = 0x01 -BMP388_REG_VAL_TEMP_EN = 0x02 -BMP388_REG_VAL_NORMAL_MODE = 0x30 - -BMP388_REG_ADD_PRESS_XLSB = 0x04 -BMP388_REG_ADD_PRESS_LSB = 0x05 -BMP388_REG_ADD_PRESS_MSB = 0x06 -BMP388_REG_ADD_TEMP_XLSB = 0x07 -BMP388_REG_ADD_TEMP_LSB = 0x08 -BMP388_REG_ADD_TEMP_MSB = 0x09 - -BMP388_REG_ADD_T1_LSB = 0x31 -BMP388_REG_ADD_T1_MSB = 0x32 -BMP388_REG_ADD_T2_LSB = 0x33 -BMP388_REG_ADD_T2_MSB = 0x34 -BMP388_REG_ADD_T3 = 0x35 -BMP388_REG_ADD_P1_LSB = 0x36 -BMP388_REG_ADD_P1_MSB = 0x37 -BMP388_REG_ADD_P2_LSB = 0x38 -BMP388_REG_ADD_P2_MSB = 0x39 -BMP388_REG_ADD_P3 = 0x3A -BMP388_REG_ADD_P4 = 0x3B -BMP388_REG_ADD_P5_LSB = 0x3C -BMP388_REG_ADD_P5_MSB = 0x3D -BMP388_REG_ADD_P6_LSB = 0x3E -BMP388_REG_ADD_P6_MSB = 0x3F -BMP388_REG_ADD_P7 = 0x40 -BMP388_REG_ADD_P8 = 0x41 -BMP388_REG_ADD_P9_LSB = 0x42 -BMP388_REG_ADD_P9_MSB = 0x43 -BMP388_REG_ADD_P10 = 0x44 -BMP388_REG_ADD_P11 = 0x45 +from BerryIMU.BMP388 import * + class BMP388(object): """docstring for BMP388""" - def __init__(self, address=I2C_ADD_BMP388): + def __init__(self, logger, address=I2C_ADD_BMP388): self._address = address self._bus = smbus.SMBus(0x01) + self.logger = logger # Load calibration values. if self._read_byte(BMP388_REG_ADD_WIA) == BMP388_REG_VAL_WIA: - print("Pressure sersor is BMP388!\r\n") + self.logger.debugLog("Pressure sersor is BMP388!\r\n") u8RegData = self._read_byte(BMP388_REG_ADD_STATUS) if u8RegData & BMP388_REG_VAL_CMD_RDY: self._write_byte(BMP388_REG_ADD_CMD, BMP388_REG_VAL_SOFT_RESET) time.sleep(0.01) else: - print ("Pressure sersor NULL!\r\n") + self.logger.debugLog("Pressure sersor NULL!\r\n") self._write_byte(BMP388_REG_ADD_PWR_CTRL, BMP388_REG_VAL_PRESS_EN | BMP388_REG_VAL_TEMP_EN @@ -127,21 +73,6 @@ def _load_calibration(self): self.P10 = self._read_s8(BMP388_REG_ADD_P10) self.P11 = self._read_s8(BMP388_REG_ADD_P11) - # print(self.T1) - # print(self.T2) - # print(self.T3) - # print(self.P1) - # print(self.P2) - # print(self.P3) - # print(self.P4) - # print(self.P5) - # print(self.P6) - # print(self.P7) - # print(self.P8) - # print(self.P9) - # print(self.P10) - # print(self.P11) - def compensate_temperature(self, adc_T): partial_data1 = adc_T - 256 * self.T1 partial_data2 = self.T2 * partial_data1 @@ -200,6 +131,9 @@ def get_temperature_and_pressure_and_altitude(self): 0.1903)) return (temperature, pressure, altitude) + + def toString(self): + return "temperature %s pressure %s altitude %s "%(self.get_temperature_and_pressure_and_altitude()) if __name__ == '__main__': diff --git a/run.py b/run.py index 7d7a38b..1877cd5 100644 --- a/run.py +++ b/run.py @@ -2,13 +2,16 @@ from Sensors.berryAccelerometer import * from Sensors.berryGyroscope import * from Sensors.berryMagnetometer import * +from Sensors.pressureSensor import * import rocketLogger logger = rocketLogger.rocketLogger() logger.dataLog('AccXangle \t AccYangle \t gyroXangle \t gyroYangle \t gyroZangle \t heading \n ') + accelerometer = berryAccelerometer(logger) gyroscope = berryGyroscope(logger) magnetometer = berryMagnetometer(logger) +tempPressureAltitudeSensor = BMP388() def manageSensors(): callSensorLogics() @@ -19,13 +22,16 @@ def callSensorLogics(): accelerometer.applySensorReadLogic() gyroscope.applySensorReadLogic() magnetometer.applySensorReadLogic(accelerometer.getPitch(), accelerometer.getRoll()) + def logSensorData(): - logger.dataLog(str(accelerometer.getSensorData()[0]) + - " " + str(accelerometer.getSensorData()[1]) + - " " + str(gyroscope.getSensorData()[0]) + - " " + str(gyroscope.getSensorData()[1]) + - " " + str(magnetometer.getSensorData()) + "/n") + temperature,pressure,altitude = bmp388.get_temperature_and_pressure_and_altitude() + logger.dataLog(accelerometer.toString() + + gyroscope.toString() + + magnetometer.toString + + tempPressureAltitudeSensor.toString()+ + "/n") + def main(): From d9f370802683b3790b9648237a7a2e5404624682 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Fri, 27 Jan 2023 10:36:20 -0600 Subject: [PATCH 14/40] rework main runner --- Sensors/berryAccelerometer.py | 4 +++- Sensors/berryGyroscope.py | 5 +++-- Sensors/berryMagnetometer.py | 9 +++++++-- run.py | 26 ++++++-------------------- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/Sensors/berryAccelerometer.py b/Sensors/berryAccelerometer.py index 23bb21c..ec12c5d 100644 --- a/Sensors/berryAccelerometer.py +++ b/Sensors/berryAccelerometer.py @@ -27,6 +27,7 @@ def applySensorReadLogic(self): def getSensorData(self): #returns finalized sensor data for use outside class + self.applySensorReadLogic() return [self.callibratedAccYangle, self.callibratedAccXangle] def getRawSensorData(self): @@ -81,4 +82,5 @@ def getRoll(self): return -math.asin(self.accYnorm/math.cos(self.getPitch())) def toString(self): - return "Pitch %s Roll %s Accelerometer X Angle %s Acceleromter Y Angle %s" % (self.getPitch(), self.getRoll, self.callibratedAccXangle, self.callibratedAccYangle) + x,y = self.getSensorData() + return "Pitch %s Roll %s Accelerometer X Angle %s Acceleromter Y Angle %s" % (self.getPitch(), self.getRoll(), x, y) diff --git a/Sensors/berryGyroscope.py b/Sensors/berryGyroscope.py index daa5266..0b6168e 100644 --- a/Sensors/berryGyroscope.py +++ b/Sensors/berryGyroscope.py @@ -71,9 +71,10 @@ def convertDataToDeg(self, data): return convertedSensorData def getSensorData(self): + self.applySensorReadLogic() return [self.gyroXangle, self.gyroYangle, self.gyroZangle] def toString(self): - return "Gyroscope X Angle, Gyroscope Y Angle, Gyroscope Z Angle %s "%(self.gyroXangle,self.gyroYangle,self.gyroZangle) - + x,y,z = self.getSensorData() + return "Gyroscope X Angle, Gyroscope Y Angle, Gyroscope Z Angle %s "%(x,y,z) diff --git a/Sensors/berryMagnetometer.py b/Sensors/berryMagnetometer.py index 050f9d5..824b6ea 100644 --- a/Sensors/berryMagnetometer.py +++ b/Sensors/berryMagnetometer.py @@ -1,4 +1,6 @@ from Sensors.sensor import sensor +from Sensors.berryAccelerometer import * + import time import math from BerryIMU import IMU @@ -12,7 +14,8 @@ class berryMagnetometer(sensor): def __init__(self, logger): - sensor.__init__(self, logger) + self.logger = logger + sensor.__init__(self, self.logger) ################# Compass Calibration values ############ # Use calibrateBerryIMU.py to get calibration values @@ -37,6 +40,8 @@ def applySensorReadLogic(self, pitch, roll): def getSensorData(self): #returns tilt heading, compensated by calibrated values + accelerometer = berryAccelerometer(self.logger) + self.applySensorReadLogic(accelerometer.getPitch, accelerometer.getRoll) return self.heading @@ -73,4 +78,4 @@ def applyCalibration(self, data): return mag def toString(self): - return "Heading %s "%(self.heading) \ No newline at end of file + return "Heading %s "%(self.getSensorData()) \ No newline at end of file diff --git a/run.py b/run.py index 1877cd5..562fd55 100644 --- a/run.py +++ b/run.py @@ -13,30 +13,16 @@ magnetometer = berryMagnetometer(logger) tempPressureAltitudeSensor = BMP388() -def manageSensors(): - callSensorLogics() - logSensorData() - -def callSensorLogics(): - #add sensor logic calls here - accelerometer.applySensorReadLogic() - gyroscope.applySensorReadLogic() - magnetometer.applySensorReadLogic(accelerometer.getPitch(), accelerometer.getRoll()) - +sensors = [accelerometer, gyroscope, magnetometer, tempPressureAltitudeSensor] def logSensorData(): - temperature,pressure,altitude = bmp388.get_temperature_and_pressure_and_altitude() - logger.dataLog(accelerometer.toString() + - gyroscope.toString() + - magnetometer.toString + - tempPressureAltitudeSensor.toString()+ - "/n") - - - + for sensor in sensors: + logger.dataLog(sensor.toString()) + logger.dataLog("\n") + def main(): while True: - manageSensors() + logSensorData() if __name__=="__main__": main() From b29037f01cac388e1b81dcc14192d76d4c71adad Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Sun, 29 Jan 2023 17:35:51 -0600 Subject: [PATCH 15/40] Round sensor data to x decimal points --- Sensors/berryAccelerometer.py | 2 +- Sensors/berryGyroscope.py | 2 +- Sensors/berryMagnetometer.py | 3 ++- Sensors/sensor.py | 6 ++++++ requirements.txt | 3 ++- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Sensors/berryAccelerometer.py b/Sensors/berryAccelerometer.py index ec12c5d..8f2fdbf 100644 --- a/Sensors/berryAccelerometer.py +++ b/Sensors/berryAccelerometer.py @@ -82,5 +82,5 @@ def getRoll(self): return -math.asin(self.accYnorm/math.cos(self.getPitch())) def toString(self): - x,y = self.getSensorData() + x,y = self.roundDataValuesToDecimal(self.getSensorData()) return "Pitch %s Roll %s Accelerometer X Angle %s Acceleromter Y Angle %s" % (self.getPitch(), self.getRoll(), x, y) diff --git a/Sensors/berryGyroscope.py b/Sensors/berryGyroscope.py index 0b6168e..1057ca0 100644 --- a/Sensors/berryGyroscope.py +++ b/Sensors/berryGyroscope.py @@ -75,6 +75,6 @@ def getSensorData(self): return [self.gyroXangle, self.gyroYangle, self.gyroZangle] def toString(self): - x,y,z = self.getSensorData() + x,y,z = self.roundDataValuesToDecimal(self.getSensorData()) return "Gyroscope X Angle, Gyroscope Y Angle, Gyroscope Z Angle %s "%(x,y,z) diff --git a/Sensors/berryMagnetometer.py b/Sensors/berryMagnetometer.py index 824b6ea..91a0ca7 100644 --- a/Sensors/berryMagnetometer.py +++ b/Sensors/berryMagnetometer.py @@ -42,7 +42,7 @@ def getSensorData(self): #returns tilt heading, compensated by calibrated values accelerometer = berryAccelerometer(self.logger) self.applySensorReadLogic(accelerometer.getPitch, accelerometer.getRoll) - return self.heading + return [self.heading] def calculateTiltCompensatedHeading(self, data): @@ -78,4 +78,5 @@ def applyCalibration(self, data): return mag def toString(self): + heading = self.roundDataValuesToDecimal(self.getSensorData()) return "Heading %s "%(self.getSensorData()) \ No newline at end of file diff --git a/Sensors/sensor.py b/Sensors/sensor.py index 875687e..d697eba 100644 --- a/Sensors/sensor.py +++ b/Sensors/sensor.py @@ -11,6 +11,12 @@ def __init__(self, logger): logger.debugLog("No IMU detected!", level=logging.WARNING) IMU.initIMU() + def roundDataValuesToDecimal(self,data, decimal=3): + roundedData = data + for item in roundedData: + item = round(item, decimal) + return roundedData + def getSensorData(self): #returns finaliozed sensor data pass diff --git a/requirements.txt b/requirements.txt index c550f95..5568551 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -smbus \ No newline at end of file +smbus +gpizero \ No newline at end of file From bc7a2aa51cc22f64c24001b59a9baa1acf885f09 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Sun, 29 Jan 2023 17:37:14 -0600 Subject: [PATCH 16/40] add delay before log (currently 50 milliseconds) --- run.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run.py b/run.py index 562fd55..a5c9de3 100644 --- a/run.py +++ b/run.py @@ -3,6 +3,7 @@ from Sensors.berryGyroscope import * from Sensors.berryMagnetometer import * from Sensors.pressureSensor import * +from time import sleep import rocketLogger logger = rocketLogger.rocketLogger() @@ -22,6 +23,7 @@ def logSensorData(): def main(): while True: + sleep(0.05) #wait 50 miliseconds between data dump logSensorData() if __name__=="__main__": From e1f9ef428a159c4f715971c932713d3e85d8baff Mon Sep 17 00:00:00 2001 From: Emily Thorpe <89881639+emilybthorpe@users.noreply.github.com> Date: Sun, 29 Jan 2023 18:37:41 -0500 Subject: [PATCH 17/40] Delete todo --- todo | 1 - 1 file changed, 1 deletion(-) delete mode 100644 todo diff --git a/todo b/todo deleted file mode 100644 index 98bb38f..0000000 --- a/todo +++ /dev/null @@ -1 +0,0 @@ -Add toString() method for each of the sensors From 454e3896718585efb31921b2bd7e77312dd2ae86 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Mon, 30 Jan 2023 12:44:09 -0600 Subject: [PATCH 18/40] update pressure sensor rounding --- Sensors/pressureSensor.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Sensors/pressureSensor.py b/Sensors/pressureSensor.py index 2c59d75..57d7233 100644 --- a/Sensors/pressureSensor.py +++ b/Sensors/pressureSensor.py @@ -5,13 +5,14 @@ import math from BerryIMU.BMP388 import * +from Sensors.sensor import sensor - -class BMP388(object): +class BMP388(sensor): """docstring for BMP388""" def __init__(self, logger, address=I2C_ADD_BMP388): + sensor.__init__(logger) self._address = address self._bus = smbus.SMBus(0x01) self.logger = logger @@ -133,7 +134,8 @@ def get_temperature_and_pressure_and_altitude(self): return (temperature, pressure, altitude) def toString(self): - return "temperature %s pressure %s altitude %s "%(self.get_temperature_and_pressure_and_altitude()) + temp, pressure, altitude = self.roundDataValuesToDecimal(self.get_temperature_and_pressure_and_altitude()) + return "temperature %.1f pressure %.2f altitude %.2f "%(temp /100.0, pressure/100.0, altitude/100.0) if __name__ == '__main__': From 917cd611bc68cfa13eacece66c2d2df13aa363a2 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Thu, 2 Feb 2023 10:50:22 -0600 Subject: [PATCH 19/40] Initial integration of berryGPS --- Sensors/berryGPS.py | 71 +++++++++++++++++++++++++++++++++++++++++++++ Sensors/gpsi2c.py | 55 +++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 Sensors/berryGPS.py create mode 100644 Sensors/gpsi2c.py diff --git a/Sensors/berryGPS.py b/Sensors/berryGPS.py new file mode 100644 index 0000000..44ebf88 --- /dev/null +++ b/Sensors/berryGPS.py @@ -0,0 +1,71 @@ +from Sensors.sensor import sensor +from BerryIMU import IMU +import time +import smbus +import signal +import sys +BUS = None +address = 0x42 +gpsReadInterval = 0.03 + +class berryGPS(sensor): + + def __init__(self, logger): + super().__init__(logger) + self.logger = logger + signal.signal(signal.SIGINT, self.handle_ctrl_c) + self.connectBus() + + def connectBus(self): + self.bus = smbus.SMBus(1) + + def parseResponse(self, gpsLine): + if(gpsLine.count(36) == 1): # Check #1, make sure '$' doesnt appear twice + if len(gpsLine) < 84: # Check #2, 83 is maximun NMEA sentenace length. + CharError = 0; + for c in gpsLine: # Check #3, Make sure that only readiable ASCII charaters and Carriage Return are seen. + if (c < 32 or c > 122) and c != 13: + CharError+=1 + if (CharError == 0):# Only proceed if there are no errors. + gpsChars = ''.join(chr(c) for c in gpsLine) + if (gpsChars.find('txbuf') == -1): # Check #4, skip txbuff allocation error + gpsStr, chkSum = gpsChars.split('*',2) # Check #5 only split twice to avoid unpack error + gpsComponents = gpsStr.split(',') + chkVal = 0 + for ch in gpsStr[1:]: # Remove the $ and do a manual checksum on the rest of the NMEA sentence + chkVal ^= ord(ch) + if (chkVal == int(chkSum, 16)): # Compare the calculated checksum with the one in the NMEA sentence + self.gpschars = gpsChars + + def handle_ctrl_c(self, signal, frame): + sys.exit(130) + + def readGPS(self): + c = None + response = [] + try: + while True: # Newline, or bad char. + c = BUS.read_byte(address) + if c == 255: + return False + elif c == 10: + break + else: + response.append(c) + self.parseResponse(response) + except IOError: + self.connectBus() + except Exception as err: + self.logger.debugLog(err) + + def toString(self): + self.parseResponse() + return self.gpschars + +if __name__ == '__main__': + import rocketLogger + logger = rocketLogger.rocketLogger() + gps = berryGPS(logger) + while True: + print(gps.toString()) + time.sleep(gpsReadInterval) \ No newline at end of file diff --git a/Sensors/gpsi2c.py b/Sensors/gpsi2c.py new file mode 100644 index 0000000..0ddd96e --- /dev/null +++ b/Sensors/gpsi2c.py @@ -0,0 +1,55 @@ +#! /usr/bin/python +import time +import smbus +import signal +import sys +BUS = None +address = 0x42 +gpsReadInterval = 0.03 +def connectBus(): + global BUS + BUS = smbus.SMBus(1) +def parseResponse(gpsLine): + if(gpsLine.count(36) == 1): # Check #1, make sure '$' doesnt appear twice + if len(gpsLine) < 84: # Check #2, 83 is maximun NMEA sentenace length. + CharError = 0; + for c in gpsLine: # Check #3, Make sure that only readiable ASCII charaters and Carriage Return are seen. + if (c < 32 or c > 122) and c != 13: + CharError+=1 + if (CharError == 0):# Only proceed if there are no errors. + gpsChars = ''.join(chr(c) for c in gpsLine) + if (gpsChars.find('txbuf') == -1): # Check #4, skip txbuff allocation error + gpsStr, chkSum = gpsChars.split('*',2) # Check #5 only split twice to avoid unpack error + gpsComponents = gpsStr.split(',') + chkVal = 0 + for ch in gpsStr[1:]: # Remove the $ and do a manual checksum on the rest of the NMEA sentence + chkVal ^= ord(ch) + if (chkVal == int(chkSum, 16)): # Compare the calculated checksum with the one in the NMEA sentence + print(gpsChars) +def handle_ctrl_c(signal, frame): + sys.exit(130) +#This will capture exit when using Ctrl-C +signal.signal(signal.SIGINT, handle_ctrl_c) +def readGPS(): + c = None + response = [] + try: + while True: # Newline, or bad char. + c = BUS.read_byte(address) + if c == 255: + return False + elif c == 10: + break + else: + response.append(c) + parseResponse(response) + except IOError: + connectBus() + except Exception as err: + print(err) +connectBus() +while True: + readGPS() + time.sleep(gpsReadInterval) + + From 45b1c42f4cdd7d43772bdaa2bbf8f1788e4fcbde Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Thu, 2 Feb 2023 11:07:14 -0600 Subject: [PATCH 20/40] update imports --- BerryIMU/IMU.py | 8 +++++--- Sensors/__init__.py | 1 + run.py | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/BerryIMU/IMU.py b/BerryIMU/IMU.py index dd7dd74..817b24d 100644 --- a/BerryIMU/IMU.py +++ b/BerryIMU/IMU.py @@ -1,5 +1,4 @@ import smbus -bus = smbus.SMBus(1) from BerryIMU.LSM9DS0 import * from BerryIMU.LSM9DS1 import * from BerryIMU.LSM6DSL import * @@ -7,7 +6,10 @@ import time - +try: + bus = smbus.SMBus(1) +except PermissionError: + print("Permission error!") BerryIMUversion = 99 @@ -22,7 +24,7 @@ def detectIMU(): #BerryIMUv3 uses the LSM6DSL and LIS3MDL global BerryIMUversion - + try: #Check for BerryIMUv1 (LSM9DS0) diff --git a/Sensors/__init__.py b/Sensors/__init__.py index e69de29..343f5fc 100644 --- a/Sensors/__init__.py +++ b/Sensors/__init__.py @@ -0,0 +1 @@ +__all__ = ['berryAccelerometer', 'berryGPS', 'berryGyroscope', 'berryMagnetometer', 'sensor', 'pressureSensor'] diff --git a/run.py b/run.py index a5c9de3..9332fac 100644 --- a/run.py +++ b/run.py @@ -3,6 +3,7 @@ from Sensors.berryGyroscope import * from Sensors.berryMagnetometer import * from Sensors.pressureSensor import * +from Sensors.berryGPS import * from time import sleep import rocketLogger @@ -13,6 +14,7 @@ gyroscope = berryGyroscope(logger) magnetometer = berryMagnetometer(logger) tempPressureAltitudeSensor = BMP388() +gps = berryGPS() sensors = [accelerometer, gyroscope, magnetometer, tempPressureAltitudeSensor] From adf895a6801724ba93feb8bc36e1639fee126ff7 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Thu, 2 Feb 2023 15:54:34 -0600 Subject: [PATCH 21/40] add gitignore to project --- .gitignore | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..688c097 --- /dev/null +++ b/.gitignore @@ -0,0 +1,174 @@ +Sensors/__pycache__/__init__.cpython-310.pyc +__pycache__/rocketLogger.cpython-310.pyc +Sensors/__pycache__/berryGPS.cpython-310.pyc +Sensors/__pycache__/pressureSensor.cpython-310.pyc +Sensors/__pycache__/sensor.cpython-310.pyc +Sensors/__pycache__/berryAccelerometer.cpython-310.pyc +Sensors/__pycache__/berryGyroscope.cpython-310.pyc +Sensors/__pycache__/berryMagnetometer.cpython-310.pyc + +# Byte-compiled / optimized / DLL files +__pycache__/ +Sensors/__pycache__/ +BerryIMU/__pycache__/ +*.py[cod] +*$py.class +*.cpython-310.pyc +Sensors/__pycache__/__init__.cpython-310.pyc + + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST +*.pyc +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ \ No newline at end of file From 64acd10e58077e7ee37ed3f16a0075d02d99c970 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Thu, 2 Feb 2023 15:58:04 -0600 Subject: [PATCH 22/40] pre-test gps integration --- Sensors/pressureSensor.py | 4 ++-- run.py | 22 +++++++++------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Sensors/pressureSensor.py b/Sensors/pressureSensor.py index 57d7233..60e696d 100644 --- a/Sensors/pressureSensor.py +++ b/Sensors/pressureSensor.py @@ -7,7 +7,7 @@ from BerryIMU.BMP388 import * from Sensors.sensor import sensor -class BMP388(sensor): +class pressureSensor(sensor): """docstring for BMP388""" @@ -143,7 +143,7 @@ def toString(self): print("BMP388 Test Program ...\n") - bmp388 = BMP388() + bmp388 = pressureSensor() while True: time.sleep(0.5) diff --git a/run.py b/run.py index 9332fac..1b6f406 100644 --- a/run.py +++ b/run.py @@ -1,27 +1,23 @@ -from Sensors import sensor -from Sensors.berryAccelerometer import * -from Sensors.berryGyroscope import * -from Sensors.berryMagnetometer import * -from Sensors.pressureSensor import * -from Sensors.berryGPS import * +from Sensors import * from time import sleep import rocketLogger logger = rocketLogger.rocketLogger() -logger.dataLog('AccXangle \t AccYangle \t gyroXangle \t gyroYangle \t gyroZangle \t heading \n ') +logger.dataLog('AccXangle \t AccYangle \t gyroXangle \t gyroYangle \t gyroZangle \t heading \t temp \t pressure \t altitude \t gps \n ') -accelerometer = berryAccelerometer(logger) -gyroscope = berryGyroscope(logger) -magnetometer = berryMagnetometer(logger) -tempPressureAltitudeSensor = BMP388() -gps = berryGPS() +accelerometer = berryAccelerometer.berryAccelerometer(logger) +gyroscope = berryGyroscope.berryGyroscope(logger) +magnetometer = berryMagnetometer.berryMagnetometer(logger) +tempPressureAltitudeSensor = pressureSensor.pressureSensor(logger) +gps = berryGPS.berryGPS() -sensors = [accelerometer, gyroscope, magnetometer, tempPressureAltitudeSensor] +sensors = [accelerometer, gyroscope, magnetometer, tempPressureAltitudeSensor, gps] def logSensorData(): for sensor in sensors: logger.dataLog(sensor.toString()) logger.dataLog("\n") + def main(): while True: From 25db5c23134bed7d0c37eb539751f3146e1f790d Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Fri, 3 Feb 2023 10:20:40 -0600 Subject: [PATCH 23/40] refactor gps and fix endless loop --- Sensors/berryGPS.py | 77 ++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 25 deletions(-) diff --git a/Sensors/berryGPS.py b/Sensors/berryGPS.py index 44ebf88..00d458a 100644 --- a/Sensors/berryGPS.py +++ b/Sensors/berryGPS.py @@ -18,24 +18,52 @@ def __init__(self, logger): def connectBus(self): self.bus = smbus.SMBus(1) + + def checkForCharError(self, gpsLine): + CharError = 0 + + for c in gpsLine: # Check #3, Make sure that only readiable ASCII charaters and Carriage Return are seen. + if (c < 32 or c > 122) and c != 13: + CharError+=1 + + return CharError == 0 + + def checkGPSLine(self, gpsLine): + """ + basic sanity check on gps line + make sure '$' doesnt appear twice and 83 is maximun NMEA sentenace length + """ + return gpsLine.count(36) == 1 and len(gpsLine) < 84 + + def checkForAllocationError(self, gpsChars): + return gpsChars.find('txbuf') == -1 + + def manualChecksum(self, gpsStr, chkSum): + # Remove the $ and do a manual checksum on the rest of the NMEA sentence + # Compare the calculated checksum with the one in the NMEA sentence + for ch in gpsStr[1:]: + chkVal ^= ord(ch) + return chkVal != int(chkSum, 16) + + def parseResponse(self, gpsLine): - if(gpsLine.count(36) == 1): # Check #1, make sure '$' doesnt appear twice - if len(gpsLine) < 84: # Check #2, 83 is maximun NMEA sentenace length. - CharError = 0; - for c in gpsLine: # Check #3, Make sure that only readiable ASCII charaters and Carriage Return are seen. - if (c < 32 or c > 122) and c != 13: - CharError+=1 - if (CharError == 0):# Only proceed if there are no errors. - gpsChars = ''.join(chr(c) for c in gpsLine) - if (gpsChars.find('txbuf') == -1): # Check #4, skip txbuff allocation error - gpsStr, chkSum = gpsChars.split('*',2) # Check #5 only split twice to avoid unpack error - gpsComponents = gpsStr.split(',') - chkVal = 0 - for ch in gpsStr[1:]: # Remove the $ and do a manual checksum on the rest of the NMEA sentence - chkVal ^= ord(ch) - if (chkVal == int(chkSum, 16)): # Compare the calculated checksum with the one in the NMEA sentence - self.gpschars = gpsChars + if(not self.checkGPSLine): + return + + if(not self.checkForCharError()): + return + + gpsChars = ''.join(chr(c) for c in gpsLine) + if(not self.checkForAllocationError(gpsChars)): + return + + gpsStr, chkSum = gpsChars.split('*',2) # Check #5 only split twice to avoid unpack error + gpsComponents = gpsStr.split(',') + if(not self.manualChecksum(gpsStr, chkSum)): + return + + self.gpschars = gpsChars def handle_ctrl_c(self, signal, frame): sys.exit(130) @@ -44,14 +72,13 @@ def readGPS(self): c = None response = [] try: - while True: # Newline, or bad char. - c = BUS.read_byte(address) - if c == 255: - return False - elif c == 10: - break - else: - response.append(c) + c = BUS.read_byte(address) + if c == 255: + return False + elif c == 10: + self.parseResponse(response) + else: + response.append(c) self.parseResponse(response) except IOError: self.connectBus() @@ -59,7 +86,7 @@ def readGPS(self): self.logger.debugLog(err) def toString(self): - self.parseResponse() + self.readGPS() return self.gpschars if __name__ == '__main__': From 7acad02503bec0815e2721234b767f0bc3ca84b9 Mon Sep 17 00:00:00 2001 From: MacHighPowerRocketry Date: Fri, 17 Feb 2023 13:20:11 -0600 Subject: [PATCH 24/40] fix logger req in pressure sensor --- Sensors/pressureSensor.py | 2 +- run.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sensors/pressureSensor.py b/Sensors/pressureSensor.py index 57d7233..94158dc 100644 --- a/Sensors/pressureSensor.py +++ b/Sensors/pressureSensor.py @@ -12,7 +12,7 @@ class BMP388(sensor): """docstring for BMP388""" def __init__(self, logger, address=I2C_ADD_BMP388): - sensor.__init__(logger) + sensor.__init__(self,logger) self._address = address self._bus = smbus.SMBus(0x01) self.logger = logger diff --git a/run.py b/run.py index a5c9de3..df3ab68 100644 --- a/run.py +++ b/run.py @@ -12,10 +12,10 @@ accelerometer = berryAccelerometer(logger) gyroscope = berryGyroscope(logger) magnetometer = berryMagnetometer(logger) -tempPressureAltitudeSensor = BMP388() - -sensors = [accelerometer, gyroscope, magnetometer, tempPressureAltitudeSensor] +tempPressureAltitudeSensor = BMP388(logger) +#sensors = [accelerometer, gyroscope, magnetometer, tempPressureAltitudeSensor] +sensors = [tempPressureAltitudeSensor, gps] def logSensorData(): for sensor in sensors: logger.dataLog(sensor.toString()) From 444a2604d351102ba18e92a54c54ead883b1b684 Mon Sep 17 00:00:00 2001 From: Emily Thorpe <89881639+emilybthorpe@users.noreply.github.com> Date: Fri, 17 Feb 2023 14:24:51 -0500 Subject: [PATCH 25/40] Delete rocketLogger.cpython-37.pyc --- __pycache__/rocketLogger.cpython-37.pyc | Bin 1583 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 __pycache__/rocketLogger.cpython-37.pyc diff --git a/__pycache__/rocketLogger.cpython-37.pyc b/__pycache__/rocketLogger.cpython-37.pyc deleted file mode 100644 index 6bfdc5b31e52046d42671df8b1ce514e6c718952..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1583 zcmZuxL66)t6t=3|M|0g7ZUOp9`+*u z;d7YwBUmKiL{iCW%IQlY0~uZu8UD^Vlk9tvN5x}GNP3}{%c@zX=?nGKW|`G`X|rjm zrOK4i#@Ms$O<@}F07;eYS+=oiv8n59p-m?74qngjMh-!Ww!j!(H?^v<=mkoD863VY zswOMz!rJVO-qbRyR%>nAti4p3(dBE^A|PdYpEJ~he*yVa1#%w@T&5UQv|2#2JljL@ z2E=r0k!r0Pi3oM$la#t?)!R0k!bOkr03^ooPp_=qC<}1^1|G@0#C1PzIsOzhif{@% zGvxW2@IZxE(SmxeDIdv5jzAj^+E^ynlqYfw?5A#W_}mgo;Ro&!%r9Zur?9l-hDy4l z9TBV}H-Tg_XvtN$3qTWjO(>%s*u+Q@h&-BaPfw?XE!%3Pa+{q_YxRq&n_@Vvl(oeY zEd0oGh&(8>J%-)RQ1b*NKJleRcF}m!80<`k+xi+h!ZIy9jXo*3bSk-RU z!*w3MnxB8;QVf3K1G*z0zCYyDg;v#zKZqH_ga7?xcBxltwytI`lzrXm_3T@t%F0%{ zxhQ-sXNS~1S^w%1A*!Zog?Jxn8^J>8gg&6#hj%>pUL|}texN7Hp6zEKAln_=(ci)@ zya7(Hf*qx(4JGa9BLbGFi*BOM>p>cIA$oKXFwf@O5zu01vphD~Cj98Us?}Ejx>klG zC%0r7Ov}g1eZTVrtQS})o)%ILck+=*z|VzPJ)S^tv4Ds!@+IZ*WgpsMTBwufuV3&V zVX%=N!n6}u2uwnPu$Fu-5{gdGBj!R7)WA`f~T zLkkZ;j=_8%O|tL8kHOf(x!*E-k9j`EF2gzq;Zh-1T5f8TCqn$ZDg5^(ggL@Ah}p$I zeDU4<)%>Nef Date: Fri, 17 Feb 2023 13:31:21 -0600 Subject: [PATCH 26/40] fix super call in gps --- Sensors/berryGPS.py | 10 +++++----- run.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sensors/berryGPS.py b/Sensors/berryGPS.py index 00d458a..d46c9f8 100644 --- a/Sensors/berryGPS.py +++ b/Sensors/berryGPS.py @@ -11,7 +11,7 @@ class berryGPS(sensor): def __init__(self, logger): - super().__init__(logger) + sensor.__init__(self,logger) self.logger = logger signal.signal(signal.SIGINT, self.handle_ctrl_c) self.connectBus() @@ -63,7 +63,7 @@ def parseResponse(self, gpsLine): if(not self.manualChecksum(gpsStr, chkSum)): return - self.gpschars = gpsChars + return gpsChars def handle_ctrl_c(self, signal, frame): sys.exit(130) @@ -86,8 +86,8 @@ def readGPS(self): self.logger.debugLog(err) def toString(self): - self.readGPS() - return self.gpschars + return self.readGPS() + if __name__ == '__main__': import rocketLogger @@ -95,4 +95,4 @@ def toString(self): gps = berryGPS(logger) while True: print(gps.toString()) - time.sleep(gpsReadInterval) \ No newline at end of file + time.sleep(gpsReadInterval) diff --git a/run.py b/run.py index c9a2bec..b0b59d0 100644 --- a/run.py +++ b/run.py @@ -10,7 +10,7 @@ gyroscope = berryGyroscope.berryGyroscope(logger) magnetometer = berryMagnetometer.berryMagnetometer(logger) tempPressureAltitudeSensor = pressureSensor.pressureSensor(logger) -gps = berryGPS.berryGPS() +gps = berryGPS.berryGPS(logger) #sensors = [accelerometer, gyroscope, magnetometer, tempPressureAltitudeSensor, gps] From 88ccb8be1bb0c33982755fbc229eeb4c877c6fd7 Mon Sep 17 00:00:00 2001 From: MacHighPowerRocketry Date: Fri, 17 Feb 2023 13:40:50 -0600 Subject: [PATCH 27/40] create new log file (w/timestamp) at each run --- rocketLogger.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rocketLogger.py b/rocketLogger.py index c312b76..28331e1 100644 --- a/rocketLogger.py +++ b/rocketLogger.py @@ -10,12 +10,14 @@ """ import logging - +from datetime import datetime class rocketLogger: def __init__(self): + now = datetime.now() + dt_string = now.strftime("%m-%d-%Y %H:%M:%S") self.formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') - self.dataLogger = self.setup_logger('data_logger', 'logs/data.log', logging.INFO) + self.dataLogger = self.setup_logger('data_logger', 'logs/data_' + dt_string + '.log', logging.INFO) self.debugLogger = self.setup_logger('debug_logger', 'logs/debug.log') def setup_logger(self, name, log_file, level=logging.WARNING): From 5649ded053220e9bf1de84a7b02cf6e36847f1b6 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Fri, 17 Feb 2023 15:49:51 -0600 Subject: [PATCH 28/40] fix indentation in logger --- Sensors/berryGPS.py | 19 +++++++++++-------- rocketLogger.py | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Sensors/berryGPS.py b/Sensors/berryGPS.py index d46c9f8..0fd6d80 100644 --- a/Sensors/berryGPS.py +++ b/Sensors/berryGPS.py @@ -72,18 +72,21 @@ def readGPS(self): c = None response = [] try: - c = BUS.read_byte(address) - if c == 255: - return False - elif c == 10: - self.parseResponse(response) - else: - response.append(c) - self.parseResponse(response) + while True: # Newline, or bad char. + c = BUS.read_byte(address) + if c == 255: + return False + elif c == 10: + break + else: + response.append(c) + return self.parseResponse(response) except IOError: + self.logger.debugLog("io error") self.connectBus() except Exception as err: self.logger.debugLog(err) + return None def toString(self): return self.readGPS() diff --git a/rocketLogger.py b/rocketLogger.py index 28331e1..50ef331 100644 --- a/rocketLogger.py +++ b/rocketLogger.py @@ -14,8 +14,8 @@ class rocketLogger: def __init__(self): - now = datetime.now() - dt_string = now.strftime("%m-%d-%Y %H:%M:%S") + now = datetime.now() + dt_string = now.strftime("%m-%d-%Y %H:%M:%S") self.formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') self.dataLogger = self.setup_logger('data_logger', 'logs/data_' + dt_string + '.log', logging.INFO) self.debugLogger = self.setup_logger('debug_logger', 'logs/debug.log') From 2fbe065ac0d3ac13f69fcc4a8b8943970560490e Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Mon, 20 Feb 2023 14:06:03 -0600 Subject: [PATCH 29/40] reworked gps, fixing error causing no output --- Sensors/berryGPS.py | 79 +++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 56 deletions(-) diff --git a/Sensors/berryGPS.py b/Sensors/berryGPS.py index 0fd6d80..6aea0f7 100644 --- a/Sensors/berryGPS.py +++ b/Sensors/berryGPS.py @@ -1,78 +1,46 @@ from Sensors.sensor import sensor -from BerryIMU import IMU import time import smbus import signal -import sys BUS = None address = 0x42 gpsReadInterval = 0.03 + class berryGPS(sensor): def __init__(self, logger): - sensor.__init__(self,logger) + sensor.__init__(self, logger) self.logger = logger signal.signal(signal.SIGINT, self.handle_ctrl_c) self.connectBus() + self.gpsString = None def connectBus(self): self.bus = smbus.SMBus(1) - def checkForCharError(self, gpsLine): - CharError = 0 - - for c in gpsLine: # Check #3, Make sure that only readiable ASCII charaters and Carriage Return are seen. - if (c < 32 or c > 122) and c != 13: - CharError+=1 - - return CharError == 0 - - def checkGPSLine(self, gpsLine): - """ - basic sanity check on gps line - make sure '$' doesnt appear twice and 83 is maximun NMEA sentenace length - """ - return gpsLine.count(36) == 1 and len(gpsLine) < 84 - - def checkForAllocationError(self, gpsChars): - return gpsChars.find('txbuf') == -1 - - def manualChecksum(self, gpsStr, chkSum): - # Remove the $ and do a manual checksum on the rest of the NMEA sentence - # Compare the calculated checksum with the one in the NMEA sentence - for ch in gpsStr[1:]: - chkVal ^= ord(ch) - return chkVal != int(chkSum, 16) - - - def parseResponse(self, gpsLine): - if(not self.checkGPSLine): - return - - if(not self.checkForCharError()): - return - - gpsChars = ''.join(chr(c) for c in gpsLine) - if(not self.checkForAllocationError(gpsChars)): - return - - gpsStr, chkSum = gpsChars.split('*',2) # Check #5 only split twice to avoid unpack error - gpsComponents = gpsStr.split(',') - if(not self.manualChecksum(gpsStr, chkSum)): - return - - return gpsChars - - def handle_ctrl_c(self, signal, frame): - sys.exit(130) + if (gpsLine.count(36) == 1): + if len(gpsLine) < 84: + CharError = 0 + for c in gpsLine: + if (c < 32 or c > 122) and c != 13: + CharError += 1 + if (CharError == 0): + gpsChars = ''.join(chr(c) for c in gpsLine) + if (gpsChars.find('txbuf') == -1): + gpsStr, chkSum = gpsChars.split('*', 2) + chkVal = 0 + for ch in gpsStr[1:]: + chkVal ^= ord(ch) + if (chkVal == int(chkSum, 16)): + self.gpsString = gpsChars def readGPS(self): c = None response = [] try: - while True: # Newline, or bad char. + while True: c = BUS.read_byte(address) if c == 255: return False @@ -80,17 +48,16 @@ def readGPS(self): break else: response.append(c) - return self.parseResponse(response) + self.parseResponse(response) except IOError: - self.logger.debugLog("io error") self.connectBus() except Exception as err: self.logger.debugLog(err) - return None def toString(self): - return self.readGPS() - + self.readGPS() + return self.gpsString + if __name__ == '__main__': import rocketLogger From 794c1d3579d01ed4a152e8d65667b75b1c796d27 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Mon, 20 Feb 2023 14:06:18 -0600 Subject: [PATCH 30/40] update gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 688c097..9232850 100644 --- a/.gitignore +++ b/.gitignore @@ -171,4 +171,5 @@ cython_debug/ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ \ No newline at end of file +#.idea/ +.vscode/settings.json From a33f58ea1db46ef05aaa67c9685fe88042823514 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Wed, 1 Mar 2023 16:38:45 -0600 Subject: [PATCH 31/40] fix accelerometer returning y,x values instead of x,y --- Sensors/berryAccelerometer.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/Sensors/berryAccelerometer.py b/Sensors/berryAccelerometer.py index 8f2fdbf..1a1f523 100644 --- a/Sensors/berryAccelerometer.py +++ b/Sensors/berryAccelerometer.py @@ -1,11 +1,7 @@ -from Sensors.sensor import sensor - -import time import math + from BerryIMU import IMU -import datetime -import os -import sys +from Sensors.sensor import sensor RAD_TO_DEG = 57.29578 M_PI = 3.14159265358979323846 @@ -13,22 +9,26 @@ class berryAccelerometer(sensor): - def __init__(self,logger): - sensor.__init__(self,logger) + def __init__(self, logger): + sensor.__init__(self, logger) def applySensorReadLogic(self): rawSensorData = self.getRawSensorData() convertedSensorData = self.convertDataToDeg(rawSensorData) - calibratedSensorData = self.applyCalibration(convertedSensorData) + calibratedSensorData = self.applyCalibration(convertedSensorData) self.callibratedAccYangle = calibratedSensorData[1] self.callibratedAccXangle = calibratedSensorData[0] data = [self.callibratedAccXangle, self.callibratedAccYangle] self.normalizeData(data) - + def getSensorData(self): - #returns finalized sensor data for use outside class + """Gets the latest accelerometer data from sensor + + Returns: + List(float): calibrated X and Y angles + """ self.applySensorReadLogic() - return [self.callibratedAccYangle, self.callibratedAccXangle] + return [self.callibratedAccXangle, self.callibratedAccYangle] def getRawSensorData(self): """ @@ -46,7 +46,6 @@ def applyCalibration(self, data): """ AccXangle = data[0] AccYangle = data[1] - #convert the values to -180 and +180 if AccYangle > 90: AccYangle -= 270.0 else: @@ -58,14 +57,13 @@ def convertDataToDeg(self, data): """ Converts sensor data to degree and returns as array """ - AccXangle = (math.atan2(data[1],data[2])*RAD_TO_DEG) - AccYangle = (math.atan2(data[2],data[0])+M_PI)*RAD_TO_DEG + AccXangle = (math.atan2(data[1],data[2])*RAD_TO_DEG) + AccYangle = (math.atan2(data[2],data[0])+M_PI)*RAD_TO_DEG convertedSensorData = [AccXangle, AccYangle] return convertedSensorData - - def normalizeData(self,data): + def normalizeData(self, data): ACCx = data[0] ACCy = data[1] ACCz = IMU.readACCz() From fc85291b36ce02df2cc9c88b9b9dcb5bc3e4f09b Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Wed, 1 Mar 2023 16:45:57 -0600 Subject: [PATCH 32/40] fix berryGPS not importing sys --- Sensors/berryGPS.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sensors/berryGPS.py b/Sensors/berryGPS.py index 6aea0f7..0670ccf 100644 --- a/Sensors/berryGPS.py +++ b/Sensors/berryGPS.py @@ -2,6 +2,7 @@ import time import smbus import signal +import sys BUS = None address = 0x42 gpsReadInterval = 0.03 @@ -19,6 +20,9 @@ def __init__(self, logger): def connectBus(self): self.bus = smbus.SMBus(1) + def handle_ctrl_c(signal, frame): + sys.exit(130) + def parseResponse(self, gpsLine): if (gpsLine.count(36) == 1): if len(gpsLine) < 84: From edfa4b6da30ac60c16fb30accc6ecff6b50c3672 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Wed, 1 Mar 2023 16:49:16 -0600 Subject: [PATCH 33/40] add connectBus() to init --- Sensors/berryGPS.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sensors/berryGPS.py b/Sensors/berryGPS.py index 0670ccf..e434484 100644 --- a/Sensors/berryGPS.py +++ b/Sensors/berryGPS.py @@ -16,6 +16,7 @@ def __init__(self, logger): signal.signal(signal.SIGINT, self.handle_ctrl_c) self.connectBus() self.gpsString = None + self.connectBus() def connectBus(self): self.bus = smbus.SMBus(1) @@ -34,6 +35,7 @@ def parseResponse(self, gpsLine): gpsChars = ''.join(chr(c) for c in gpsLine) if (gpsChars.find('txbuf') == -1): gpsStr, chkSum = gpsChars.split('*', 2) + gpsComponents = gpsStr.split(',') chkVal = 0 for ch in gpsStr[1:]: chkVal ^= ord(ch) From 4a51e4cd82dcc4cfa3243b3201fb5eba3084d4cb Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Wed, 1 Mar 2023 16:50:09 -0600 Subject: [PATCH 34/40] add debug line --- Sensors/berryGPS.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Sensors/berryGPS.py b/Sensors/berryGPS.py index e434484..12806e0 100644 --- a/Sensors/berryGPS.py +++ b/Sensors/berryGPS.py @@ -41,6 +41,7 @@ def parseResponse(self, gpsLine): chkVal ^= ord(ch) if (chkVal == int(chkSum, 16)): self.gpsString = gpsChars + print(gpsChars) def readGPS(self): c = None From 034898d5df072299605831ed1f251291e6cc8e00 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Wed, 1 Mar 2023 16:51:32 -0600 Subject: [PATCH 35/40] fix bus not being loaded --- Sensors/berryGPS.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sensors/berryGPS.py b/Sensors/berryGPS.py index 12806e0..f7e903e 100644 --- a/Sensors/berryGPS.py +++ b/Sensors/berryGPS.py @@ -3,7 +3,6 @@ import smbus import signal import sys -BUS = None address = 0x42 gpsReadInterval = 0.03 @@ -17,6 +16,7 @@ def __init__(self, logger): self.connectBus() self.gpsString = None self.connectBus() + self.bus = None def connectBus(self): self.bus = smbus.SMBus(1) @@ -48,7 +48,7 @@ def readGPS(self): response = [] try: while True: - c = BUS.read_byte(address) + c = self.bus.read_byte(address) if c == 255: return False elif c == 10: From 1dc6a697e8cef73a462cee41c77a255d8bbab7da Mon Sep 17 00:00:00 2001 From: MacHighPowerRocketry Date: Wed, 1 Mar 2023 17:19:03 -0600 Subject: [PATCH 36/40] completed gps code --- BerryIMU/__pycache__/IMU.cpython-37.pyc | Bin 6697 -> 6778 bytes Sensors/__pycache__/__init__.cpython-37.pyc | Bin 140 -> 251 bytes .../berryAccelerometer.cpython-37.pyc | Bin 2962 -> 3313 bytes Sensors/__pycache__/sensor.cpython-37.pyc | Bin 1508 -> 1738 bytes Sensors/berryGPS.py | 14 +- logs/debug.log | 822 ++++++++++++++++++ run.py | 4 +- 7 files changed, 833 insertions(+), 7 deletions(-) diff --git a/BerryIMU/__pycache__/IMU.cpython-37.pyc b/BerryIMU/__pycache__/IMU.cpython-37.pyc index ee52c31261fbb17b64ba90d3966fe54e8b131832..d72b8d86459a131e4f7be106f0a68457f1fd6c52 100644 GIT binary patch delta 1243 zcma)+O=}ZT6o&7eWYS66$@e5po21riOl0fH@=e@(seeZcQXJ&19dw6MF zRXq%k;^xB0nam?RLb+qzg5~%$BsH}<#}0`D_(=Gy1?<6 z>us~F5O*>|x#=-=&S)5JaNgy7iOsQsbcKOD?*SLI-D7$?DBwoz01vdIs?Y%{su#TA zL-m0l0;qlnLI^bgVbD;65P>La2s$B#8ip?DM%5q=3DgMiX_iiIVH7r%=5;=>#hJ!f zHE_`|7jl-BD;D+`rdc$5*FP+C?x@|69&lb4-yLf_E*?3@cvyULp5RH5kPH2Bv@vZY za8`HUGIJ$kyizh|@YIqJjGMh;UEbgh0j`g+{}w2wF%M%C6N|cd>FE<0cg^p>H6}d` zvxBf#%&R>jzeLPJ`nmJ~~ zyY}U#;U?!UEk3lvUGO#yx0)KD5QBt+t>U0d<%#XG?Q80i5u?81E}g0yc9@}7VUps# z|5?*8*|EvRS9Tf2P}4Gc_z`hO)x`5)E|sA$M+wJT#X`Tz8{4m2Q^gDUX|w;9JcoRm zxE|iEXZ4F6aHJO3X0e4uDPp*KsRqCBM>X*+(v6n>Xqorb?nh^MqR~K&R&L7`a;5Xx znIGb3=PC6Zu1-gF*;=?-w!~B{yQIt0+3~Vvs(7XDYrH&X>D@7dv|EUfB-ooDpjnEL zCLAK*w}zQRgki#Q!U%yj{HL)Sbtxwoicrq?7^gYjVo}E^{O@o`+)G0efv(P9ZdM2& delta 1161 zcma)+OK1~O6o%&{ndBx-npcxJwz09*nxw6^HeLC^q?Gy~E*cAVK%{yi1dLdTLo6`c=$cex^u*v7n@7jM42&1@!*_oO8 zZTZYK3?qDJfFCpX)f!&LNx9oID6e`#^0m-lNPZHF$zi^5igB9J#kEl(*KghYM#-z{ zIjYy%I#(zkxLck4K6DH=w>V#aY6TnX7Hm>}_N^pS93ssa?G}f;8e3KgU%VYln3OgD zQJvP_T27n29i2|dK=4h+K>6%k{i79Vs#~BzI45^Q>&XcYGRZjKEfTpkwyi>b2RjzR zUXS{Y>b15fH^URHJCPgIwz3&5LPGju)8sK5tHDs~eQW{Z?M`WTt*f+Ls$R=4{F39^ zC2f|?yzl;&7@Cr^pIbM1(&mcm^y6Md&Yw67B#1 diff --git a/Sensors/__pycache__/__init__.cpython-37.pyc b/Sensors/__pycache__/__init__.cpython-37.pyc index 3e827c160c388f844a0b92a7ef47bf87c54e12c3..c4fb9646cd6b2598e037514c5bb0a8985a491c13 100644 GIT binary patch delta 183 zcmeBS{LNVJ#LLUY00jA$-zOIU>Bk@r46p$i4nSNi0whuxQW#U1QkYX%Qdra3q8L)x zf*CZ~ZwV!(78O-GCMT!nq!#7prk11@-Qoa?xd#N_;)Ad%i}H(;^9xdM34-~)iRpQ% zB_PH6K-Fx;sd>fuMYs40ic*V1dzy`uW zt{z}MfNcB(h7aJCFW_b4!K+7a-t@giNSNmR-n`$N_d1#1%<16oA$vNX&nP(VfBzfQ zGbeUw^EpOLVGt@Fc{PNF>Zw3;Ez}yir{i4rQY_^e^9nOq`dDFUu7A|LG=o*eHGfgV zB^SEd!pk*uM$DUWBu+k$13S5Rn`6ae#mlonTw9VZ%z`GHunRf))fzef0~-JZxvZ@n z-N7~o%9+wp0R1kYsWla=pnWjUlh{dixD)ybj}yla0v>V^HF&~>!~Dc|wlQ)pf1SxV z|HleXTA~?GT@%DF*5hP+JB<9qopJ&{tiKo7^)Yic9KXq&O~hKr#qEv*@Y5@v5ue^CbS*-)GErn{-vNIWsXnU@ z7G%ZR$~{1`tNU@iDax1{g+)B)Og(wTReUf&GMk$@Ix_xI}#OwF$9#!K-Y!6F6;}F z=pI-^nn|>phKrv}! zs-|XI_+`vIS{ft#1YHT&6m;00In9OG$9Exmx58fSJ&pLu0*{x31rp)6aaCSF~!Qr701XkF|d{WUvrdGYOZq2D3wfv@)BG5x2(iT+!t2j zrtqArAYuDfQ~sm_n@~7;dYlh+2Pwa^d(i*VAJ@N6PFJBjdHXnc z29E*e&2@fY_Pm-C;Syan;4hnwh$EMxL|trygh@oWgPFJ z)1cy7d6Spk9Naapy>1v|u@Jrd=vX&UYQU~JgB8>E+viEr8w6_ziXRShy-DMq+fPUL zhFP{}KKUEG)2x_Z!R=t3S~m%urfc6>zu diff --git a/Sensors/__pycache__/sensor.cpython-37.pyc b/Sensors/__pycache__/sensor.cpython-37.pyc index 20c305c2f1b0cd903b98c00278faae03b3aae6de..5b5b44ad7987e343c657c1c2004b8e531e66a931 100644 GIT binary patch delta 755 zcmZ`%&2G~`5cb;Z*l}Vvh0-=afCH6q1so7(1T;ZH0tA#F$x;u-vyCjdc3HaxB1atP z87bPQKs*8mu822a&s;e30?arEB2d=aZ{(Tz=9`_}pPlc1aM$-e0~g%+k>q?9?9T@6 z2lvn+jEI2|nZUq2F(M0AfrEX*A`UHZ&|`xOZL}@$po7+dF8F9&2w(+m8+yA&cxv`_ z($#Gcl}M`l51(r_Vpj*+N%NF`LsRooWc#|672~mxpA6Ym9~r#=Wnm8q0WBLh$GwBQ zyo6A*sr7cfwuZ)DFy)m|^V)k&6JxVUp@bK4b|lJY#c)mzFj~3@2II_Q0h?SbMP3&2`Z9)k zVx3dBxwB0gA!|BX&}-!Uv8Z;NG9ifHZ3gdkP1TW=r8r;R4d^DcmVMK$;_kH<&?_Z{o=+o+!?g)RNTX5>MaI zsLB3}I*d`1YZ#>&IVaCxOqqO|NlA+nXpJUg5j&770* z68R>JGw(LUqg*7hpdhCbq9G_XF~ui8Ju_KoGBe9+T|Bx3fR+R$mLu$un0%YX)flXU z3GA#}EGapb+2z5xgLR4@3xn2q6#wG8~Bj1yT_+kYEMkVvsHlCJuHE g77jKbWC6=)vPMlVXOop;gDFMQ4mOQz@;Wvd0B&AujQ{`u diff --git a/Sensors/berryGPS.py b/Sensors/berryGPS.py index f7e903e..9d5b82c 100644 --- a/Sensors/berryGPS.py +++ b/Sensors/berryGPS.py @@ -15,16 +15,18 @@ def __init__(self, logger): signal.signal(signal.SIGINT, self.handle_ctrl_c) self.connectBus() self.gpsString = None - self.connectBus() self.bus = None + self.connectBus() def connectBus(self): self.bus = smbus.SMBus(1) + #print(self.bus) def handle_ctrl_c(signal, frame): sys.exit(130) def parseResponse(self, gpsLine): + #print(gpsLine) if (gpsLine.count(36) == 1): if len(gpsLine) < 84: CharError = 0 @@ -40,15 +42,15 @@ def parseResponse(self, gpsLine): for ch in gpsStr[1:]: chkVal ^= ord(ch) if (chkVal == int(chkSum, 16)): - self.gpsString = gpsChars - print(gpsChars) + self.gpsString += "\n" + gpsChars def readGPS(self): c = None response = [] + #print(self.bus) try: while True: - c = self.bus.read_byte(address) + c = self.bus.read_byte(0x42) if c == 255: return False elif c == 10: @@ -62,7 +64,9 @@ def readGPS(self): self.logger.debugLog(err) def toString(self): - self.readGPS() + self.gpsString = "" + for i in range(8): + self.readGPS() return self.gpsString diff --git a/logs/debug.log b/logs/debug.log index e69de29..c3670c7 100644 --- a/logs/debug.log +++ b/logs/debug.log @@ -0,0 +1,822 @@ +2023-03-01 16:45:12,568 WARNING Pressure sersor is BMP388! + +2023-03-01 16:46:08,257 WARNING Pressure sersor is BMP388! + +2023-03-01 16:46:09,332 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:09,385 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:09,439 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:09,493 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:09,546 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:09,600 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:09,653 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:09,707 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:09,761 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:09,814 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:09,868 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:09,922 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:09,975 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,029 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,083 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,136 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,190 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,243 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,297 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,351 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,404 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,458 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,511 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,565 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,619 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,672 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,726 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,780 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,833 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,887 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,941 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:10,995 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,048 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,102 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,156 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,209 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,263 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,317 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,370 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,424 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,477 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,531 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,585 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,638 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,692 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,746 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,799 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,853 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,906 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:11,960 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,014 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,068 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,121 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,175 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,228 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,282 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,336 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,389 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,443 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,496 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,550 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,604 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,661 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,714 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,768 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,822 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,875 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,929 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:12,983 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,036 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,090 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,143 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,197 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,251 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,304 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,358 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,412 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,465 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,519 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,572 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,626 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,680 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,733 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,787 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,841 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,894 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:13,948 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,001 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,055 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,109 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,162 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,216 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,270 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,323 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,377 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,430 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,484 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,538 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,591 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,645 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,698 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,752 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,806 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,859 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,913 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:14,967 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,020 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,074 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,127 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,181 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,235 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,288 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,342 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,395 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,449 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,503 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,556 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,610 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,663 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,717 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,771 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,824 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,878 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,931 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:15,985 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,039 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,092 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,146 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,200 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,253 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,307 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,360 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,414 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,468 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,521 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,575 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,628 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,682 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,736 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,789 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,843 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,897 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:16,951 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:17,004 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:17,058 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:17,112 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:46:17,166 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:32,436 WARNING Pressure sersor is BMP388! + +2023-03-01 16:49:33,509 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:33,569 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:33,624 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:33,678 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:33,732 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:33,786 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:33,839 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:33,893 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:33,947 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,000 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,054 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,108 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,161 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,215 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,269 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,322 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,376 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,429 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,483 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,537 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,590 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,644 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,698 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,751 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,805 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,859 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,913 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:34,967 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,020 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,074 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,128 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,181 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,235 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,289 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,342 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,396 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,450 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,504 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,557 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,611 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,665 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,718 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,772 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,825 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,879 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,933 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:35,986 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,040 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,093 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,147 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,201 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,255 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,308 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,362 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,416 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,469 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,523 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,576 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,630 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,684 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,738 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,791 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,845 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,898 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:36,952 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:37,006 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:37,060 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:49:37,114 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:20,708 WARNING Pressure sersor is BMP388! + +2023-03-01 16:50:21,782 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:21,835 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:21,889 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:21,942 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:21,996 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,050 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,103 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,157 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,210 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,264 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,318 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,371 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,425 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,479 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,532 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,586 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,639 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,693 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,746 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,800 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,854 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,908 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:22,961 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,015 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,069 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,122 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,176 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,229 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,283 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,337 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,390 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,444 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,498 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,551 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,605 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,658 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,712 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,766 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,820 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,874 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,928 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:23,982 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:24,035 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:24,089 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:24,143 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:24,196 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:24,250 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:24,303 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:24,358 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:24,411 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:50:24,465 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:43,842 WARNING Pressure sersor is BMP388! + +2023-03-01 16:51:44,915 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:44,969 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,022 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,076 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,130 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,183 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,237 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,291 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,344 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,398 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,452 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,505 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,559 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,612 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,666 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,720 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,773 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,827 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,881 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,934 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:45,988 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,042 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,095 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,149 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,203 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,256 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,310 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,364 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,417 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,471 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,525 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,578 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,632 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,686 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,739 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,793 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,846 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,900 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:46,954 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,008 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,061 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,115 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,169 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,222 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,276 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,330 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,383 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,437 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,490 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,544 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,598 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,651 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,705 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,759 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,812 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,866 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,920 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:47,973 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,027 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,080 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,134 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,188 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,241 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,295 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,349 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,402 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,456 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,510 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,563 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,617 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,670 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,724 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,778 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,831 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,886 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,941 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:51:48,994 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:30,019 WARNING Pressure sersor is BMP388! + +2023-03-01 16:53:31,093 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,148 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,201 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,255 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,309 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,362 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,416 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,470 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,523 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,577 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,631 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,684 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,738 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,792 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,845 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,899 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:31,953 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,007 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,060 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,114 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,168 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,221 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,275 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,329 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,382 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,436 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,490 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,543 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,597 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,651 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,704 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,758 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,812 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,865 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,919 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:32,973 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,026 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,080 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,134 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,187 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,241 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,295 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,348 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,402 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,456 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,509 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,563 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,617 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,670 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,724 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,778 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,831 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,885 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,939 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:33,992 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,046 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,100 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,153 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,207 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,261 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,315 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,368 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,422 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,476 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,529 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,583 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,637 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,690 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,745 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,800 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,853 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,907 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:34,961 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:35,014 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:35,069 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:35,122 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:54,258 WARNING Pressure sersor is BMP388! + +2023-03-01 16:53:55,333 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:55,387 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:55,440 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:55,493 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:55,547 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:55,601 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:55,655 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:55,708 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:55,762 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:55,815 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:55,869 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:55,923 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:55,976 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,030 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,084 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,137 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,191 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,245 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,298 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,352 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,406 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,459 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,513 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,567 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,620 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,674 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,727 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,781 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,835 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,889 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,942 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:56,996 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:57,049 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:57,103 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:57,156 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:57,210 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:57,264 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:53:57,318 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:22,303 WARNING Pressure sersor is BMP388! + +2023-03-01 16:54:23,377 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:23,431 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:23,485 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:23,538 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:23,591 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:23,645 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:23,699 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:23,752 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:23,806 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:23,860 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:23,913 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:23,967 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,020 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,074 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,128 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,181 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,235 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,289 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,342 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,396 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,450 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,503 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,557 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,611 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,664 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,718 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,771 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,825 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,879 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,932 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:24,991 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:25,046 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:25,100 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:25,153 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:25,207 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:25,261 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:25,314 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:25,368 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:25,422 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:25,475 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:25,529 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:25,582 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:25,636 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:25,690 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:54:25,744 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:27,437 WARNING Pressure sersor is BMP388! + +2023-03-01 16:55:28,511 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:28,566 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:28,620 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:28,675 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:28,729 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:28,783 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:28,837 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:28,891 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:28,946 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:29,000 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:29,055 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:29,110 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:29,164 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:29,219 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:29,273 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:29,328 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:29,383 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:29,438 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:29,492 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:29,547 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:55:29,602 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:41,766 WARNING Pressure sersor is BMP388! + +2023-03-01 16:56:42,841 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:42,895 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:42,948 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,002 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,056 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,109 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,163 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,217 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,271 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,325 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,379 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,433 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,485 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,537 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,590 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,642 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,694 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,747 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,799 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,851 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,903 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:43,956 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,008 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,060 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,112 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,166 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,220 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,273 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,327 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,380 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,434 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,488 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,541 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,595 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,649 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,702 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,756 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,809 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,863 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,917 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:44,970 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,024 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,077 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,131 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,185 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,238 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,292 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,345 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,399 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,452 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,506 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,559 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,613 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,667 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,729 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,782 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,836 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,889 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,943 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:45,997 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:56:46,051 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:47,582 WARNING Pressure sersor is BMP388! + +2023-03-01 16:57:48,656 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:48,710 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:48,764 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:48,817 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:48,870 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:48,924 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:48,978 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,031 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,085 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,139 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,192 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,246 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,299 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,353 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,407 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,460 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,514 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,567 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,621 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,675 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,728 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,782 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,835 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,889 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,943 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:49,996 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,050 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,104 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,157 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,211 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,265 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,318 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,372 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,426 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,479 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,533 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,587 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,640 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,694 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,748 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,801 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,855 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,908 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:50,962 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,018 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,072 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,126 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,179 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,233 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,287 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,340 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,394 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,448 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,501 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,555 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,608 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,662 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,716 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,769 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,823 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,877 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,930 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:51,984 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,037 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,091 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,144 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,198 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,251 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,305 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,359 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,412 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,466 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,519 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,573 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,626 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,680 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,733 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,787 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,840 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,894 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:52,948 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:53,001 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:53,055 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:57:53,109 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:16,013 WARNING Pressure sersor is BMP388! + +2023-03-01 16:58:17,088 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,143 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,198 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,252 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,306 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,360 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,414 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,469 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,523 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,578 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,632 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,686 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,741 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,795 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,849 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,904 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:17,958 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:18,012 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:18,067 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:58:18,121 WARNING 'NoneType' object has no attribute 'read_byte' +2023-03-01 16:59:22,352 WARNING Pressure sersor is BMP388! + +2023-03-01 16:59:44,247 WARNING Pressure sersor is BMP388! + +2023-03-01 17:00:15,625 WARNING Pressure sersor is BMP388! + +2023-03-01 17:00:46,730 WARNING Pressure sersor is BMP388! + +2023-03-01 17:03:46,325 WARNING Pressure sersor is BMP388! + +2023-03-01 17:04:11,597 WARNING Pressure sersor is BMP388! + +2023-03-01 17:05:37,524 WARNING Pressure sersor is BMP388! + +2023-03-01 17:08:34,032 WARNING Pressure sersor is BMP388! + +2023-03-01 17:13:46,719 WARNING Pressure sersor is BMP388! + +2023-03-01 17:13:49,249 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:49,253 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:49,259 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:49,266 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:49,275 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:49,279 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:49,784 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:49,788 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:50,295 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:50,299 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:50,304 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:50,311 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:50,319 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:50,323 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:50,828 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:13:50,832 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:52,246 WARNING Pressure sersor is BMP388! + +2023-03-01 17:14:54,274 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:54,278 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:54,283 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:54,291 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:54,299 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:54,302 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:54,807 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:54,811 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:55,318 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:55,322 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:55,327 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:55,334 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:55,342 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:55,345 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:55,850 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:55,854 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:56,361 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:56,365 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:56,371 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:56,378 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:56,386 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:56,389 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:56,894 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:56,897 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:57,404 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:57,408 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:57,414 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:57,421 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:57,429 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:57,432 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:57,938 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:57,941 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:58,448 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:58,452 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:58,458 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:58,466 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:58,473 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:58,477 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:58,982 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:58,986 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:59,493 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:59,497 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:59,502 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:59,509 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:59,517 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:14:59,520 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:00,025 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:00,029 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:00,536 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:00,540 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:00,546 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:00,553 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:00,561 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:00,564 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:01,069 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:01,072 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:01,076 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:01,080 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:01,085 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:01,091 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:01,600 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:01,604 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:01,607 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:01,611 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:02,117 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:02,120 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:02,125 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:02,131 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:02,138 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:15:02,141 WARNING unsupported operand type(s) for +=: 'NoneType' and 'str' +2023-03-01 17:16:21,779 WARNING Pressure sersor is BMP388! + +2023-03-01 17:17:42,481 WARNING Pressure sersor is BMP388! + diff --git a/run.py b/run.py index b0b59d0..443c6f6 100644 --- a/run.py +++ b/run.py @@ -15,7 +15,7 @@ #sensors = [accelerometer, gyroscope, magnetometer, tempPressureAltitudeSensor, gps] -sensors = [tempPressureAltitudeSensor, gps] +sensors = [gps] def logSensorData(): for sensor in sensors: logger.dataLog(sensor.toString()) @@ -24,7 +24,7 @@ def logSensorData(): def main(): while True: - sleep(0.05) #wait 50 miliseconds between data dump + sleep(0.5) #wait 50 miliseconds between data dump logSensorData() if __name__=="__main__": From 6a067cfe926f8a6eda0f391c74443bb1142ea948 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Thu, 2 Mar 2023 12:16:42 -0600 Subject: [PATCH 37/40] add methods to check if altitude is at least value --- Sensors/berryMagnetometer.py | 5 ++++- Sensors/pressureSensor.py | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Sensors/berryMagnetometer.py b/Sensors/berryMagnetometer.py index 91a0ca7..550f78c 100644 --- a/Sensors/berryMagnetometer.py +++ b/Sensors/berryMagnetometer.py @@ -77,6 +77,9 @@ def applyCalibration(self, data): mag[2] -= (self.magZmin + self.magZmax) /2 return mag + def isHeadingValue(self, value): + return self.roundDataValuesToDecimal(self.getSensorData()) == value + def toString(self): heading = self.roundDataValuesToDecimal(self.getSensorData()) - return "Heading %s "%(self.getSensorData()) \ No newline at end of file + return "Heading %s " % (heading) diff --git a/Sensors/pressureSensor.py b/Sensors/pressureSensor.py index 4ecb4c9..1bd4d4e 100644 --- a/Sensors/pressureSensor.py +++ b/Sensors/pressureSensor.py @@ -133,8 +133,17 @@ def get_temperature_and_pressure_and_altitude(self): return (temperature, pressure, altitude) + def getSensorData(self): + return self.roundDataValuesToDecimal(self.get_temperature_and_pressure_and_altitude()) + + def isAltitudeAtLeastValue(self, value): + return self.getSensorData()[2] >= value + + def isTemperatureAtLeastValue(self, value): + return self.getSensorData()[0] >= value + def toString(self): - temp, pressure, altitude = self.roundDataValuesToDecimal(self.get_temperature_and_pressure_and_altitude()) + temp, pressure, altitude = self.getSensorData() return "temperature %.1f pressure %.2f altitude %.2f "%(temp /100.0, pressure/100.0, altitude/100.0) if __name__ == '__main__': From 9f59834238ed3bdd57c7f0e696d7eeb9ebafdde4 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Fri, 3 Mar 2023 15:27:22 -0600 Subject: [PATCH 38/40] remove old pressure sensor testing code --- Sensors/pressureSensor.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/Sensors/pressureSensor.py b/Sensors/pressureSensor.py index 1bd4d4e..b7d4760 100644 --- a/Sensors/pressureSensor.py +++ b/Sensors/pressureSensor.py @@ -145,21 +145,3 @@ def isTemperatureAtLeastValue(self, value): def toString(self): temp, pressure, altitude = self.getSensorData() return "temperature %.1f pressure %.2f altitude %.2f "%(temp /100.0, pressure/100.0, altitude/100.0) - -if __name__ == '__main__': - - import time - - print("BMP388 Test Program ...\n") - - bmp388 = pressureSensor() - - while True: - time.sleep(0.5) - temperature,pressure,altitude = bmp388.get_temperature_and_pressure_and_altitude() - print(' Temperature = %.1f Pressure = %.2f Altitude =%.2f '%(temperature/100.0,pressure/100.0,altitude/100.0)) - - - - - From 423db66d334f1f4dde83e913051f780a79fb3d08 Mon Sep 17 00:00:00 2001 From: emilybthorpe Date: Fri, 3 Mar 2023 16:01:45 -0600 Subject: [PATCH 39/40] add original imu for testing --- berryIMU.py | 406 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 406 insertions(+) create mode 100644 berryIMU.py diff --git a/berryIMU.py b/berryIMU.py new file mode 100644 index 0000000..638886a --- /dev/null +++ b/berryIMU.py @@ -0,0 +1,406 @@ +#!/usr/bin/python +# +# This program reads the angles from the acceleromteer, gyroscope +# and mangnetometer on a BerryIMU connected to a Raspberry Pi. +# +# This program includes two filters (low pass and median) to improve the +# values returned from BerryIMU by reducing noise. +# +# The BerryIMUv1, BerryIMUv2 and BerryIMUv3 are supported +# +# This script is python 2.7 and 3 compatible +# +# Feel free to do whatever you like with this code. +# Distributed as-is; no warranty is given. +# +# http://ozzmaker.com/ + + + +import sys +import time +import math +import IMU +import datetime +import os + + +RAD_TO_DEG = 57.29578 +M_PI = 3.14159265358979323846 +G_GAIN = 0.070 # [deg/s/LSB] If you change the dps for gyro, you need to update this value accordingly +AA = 0.40 # Complementary filter constant +MAG_LPF_FACTOR = 0.4 # Low pass filter constant magnetometer +ACC_LPF_FACTOR = 0.4 # Low pass filter constant for accelerometer +ACC_MEDIANTABLESIZE = 9 # Median filter table size for accelerometer. Higher = smoother but a longer delay +MAG_MEDIANTABLESIZE = 9 # Median filter table size for magnetometer. Higher = smoother but a longer delay + + + +################# Compass Calibration values ############ +# Use calibrateBerryIMU.py to get calibration values +# Calibrating the compass isnt mandatory, however a calibrated +# compass will result in a more accurate heading value. + +magXmin = 0 +magYmin = 0 +magZmin = 0 +magXmax = 0 +magYmax = 0 +magZmax = 0 + + +''' +Here is an example: +magXmin = -1748 +magYmin = -1025 +magZmin = -1876 +magXmax = 959 +magYmax = 1651 +magZmax = 708 +Dont use the above values, these are just an example. +''' +############### END Calibration offsets ################# + + +#Kalman filter variables +Q_angle = 0.02 +Q_gyro = 0.0015 +R_angle = 0.005 +y_bias = 0.0 +x_bias = 0.0 +XP_00 = 0.0 +XP_01 = 0.0 +XP_10 = 0.0 +XP_11 = 0.0 +YP_00 = 0.0 +YP_01 = 0.0 +YP_10 = 0.0 +YP_11 = 0.0 +KFangleX = 0.0 +KFangleY = 0.0 + + + +def kalmanFilterY ( accAngle, gyroRate, DT): + y=0.0 + S=0.0 + + global KFangleY + global Q_angle + global Q_gyro + global y_bias + global YP_00 + global YP_01 + global YP_10 + global YP_11 + + KFangleY = KFangleY + DT * (gyroRate - y_bias) + + YP_00 = YP_00 + ( - DT * (YP_10 + YP_01) + Q_angle * DT ) + YP_01 = YP_01 + ( - DT * YP_11 ) + YP_10 = YP_10 + ( - DT * YP_11 ) + YP_11 = YP_11 + ( + Q_gyro * DT ) + + y = accAngle - KFangleY + S = YP_00 + R_angle + K_0 = YP_00 / S + K_1 = YP_10 / S + + KFangleY = KFangleY + ( K_0 * y ) + y_bias = y_bias + ( K_1 * y ) + + YP_00 = YP_00 - ( K_0 * YP_00 ) + YP_01 = YP_01 - ( K_0 * YP_01 ) + YP_10 = YP_10 - ( K_1 * YP_00 ) + YP_11 = YP_11 - ( K_1 * YP_01 ) + + return KFangleY + +def kalmanFilterX ( accAngle, gyroRate, DT): + x=0.0 + S=0.0 + + global KFangleX + global Q_angle + global Q_gyro + global x_bias + global XP_00 + global XP_01 + global XP_10 + global XP_11 + + + KFangleX = KFangleX + DT * (gyroRate - x_bias) + + XP_00 = XP_00 + ( - DT * (XP_10 + XP_01) + Q_angle * DT ) + XP_01 = XP_01 + ( - DT * XP_11 ) + XP_10 = XP_10 + ( - DT * XP_11 ) + XP_11 = XP_11 + ( + Q_gyro * DT ) + + x = accAngle - KFangleX + S = XP_00 + R_angle + K_0 = XP_00 / S + K_1 = XP_10 / S + + KFangleX = KFangleX + ( K_0 * x ) + x_bias = x_bias + ( K_1 * x ) + + XP_00 = XP_00 - ( K_0 * XP_00 ) + XP_01 = XP_01 - ( K_0 * XP_01 ) + XP_10 = XP_10 - ( K_1 * XP_00 ) + XP_11 = XP_11 - ( K_1 * XP_01 ) + + return KFangleX + + +gyroXangle = 0.0 +gyroYangle = 0.0 +gyroZangle = 0.0 +CFangleX = 0.0 +CFangleY = 0.0 +CFangleXFiltered = 0.0 +CFangleYFiltered = 0.0 +kalmanX = 0.0 +kalmanY = 0.0 +oldXMagRawValue = 0 +oldYMagRawValue = 0 +oldZMagRawValue = 0 +oldXAccRawValue = 0 +oldYAccRawValue = 0 +oldZAccRawValue = 0 + +a = datetime.datetime.now() + + + +#Setup the tables for the mdeian filter. Fill them all with '1' so we dont get devide by zero error +acc_medianTable1X = [1] * ACC_MEDIANTABLESIZE +acc_medianTable1Y = [1] * ACC_MEDIANTABLESIZE +acc_medianTable1Z = [1] * ACC_MEDIANTABLESIZE +acc_medianTable2X = [1] * ACC_MEDIANTABLESIZE +acc_medianTable2Y = [1] * ACC_MEDIANTABLESIZE +acc_medianTable2Z = [1] * ACC_MEDIANTABLESIZE +mag_medianTable1X = [1] * MAG_MEDIANTABLESIZE +mag_medianTable1Y = [1] * MAG_MEDIANTABLESIZE +mag_medianTable1Z = [1] * MAG_MEDIANTABLESIZE +mag_medianTable2X = [1] * MAG_MEDIANTABLESIZE +mag_medianTable2Y = [1] * MAG_MEDIANTABLESIZE +mag_medianTable2Z = [1] * MAG_MEDIANTABLESIZE + +IMU.detectIMU() #Detect if BerryIMU is connected. +if(IMU.BerryIMUversion == 99): + print(" No BerryIMU found... exiting ") + sys.exit() +IMU.initIMU() #Initialise the accelerometer, gyroscope and compass + + +while True: + + #Read the accelerometer,gyroscope and magnetometer values + ACCx = IMU.readACCx() + ACCy = IMU.readACCy() + ACCz = IMU.readACCz() + GYRx = IMU.readGYRx() + GYRy = IMU.readGYRy() + GYRz = IMU.readGYRz() + MAGx = IMU.readMAGx() + MAGy = IMU.readMAGy() + MAGz = IMU.readMAGz() + + + #Apply compass calibration + MAGx -= (magXmin + magXmax) /2 + MAGy -= (magYmin + magYmax) /2 + MAGz -= (magZmin + magZmax) /2 + + + ##Calculate loop Period(LP). How long between Gyro Reads + b = datetime.datetime.now() - a + a = datetime.datetime.now() + LP = b.microseconds/(1000000*1.0) + outputString = "Loop Time %5.2f " % ( LP ) + + + + ############################################### + #### Apply low pass filter #### + ############################################### + MAGx = MAGx * MAG_LPF_FACTOR + oldXMagRawValue*(1 - MAG_LPF_FACTOR); + MAGy = MAGy * MAG_LPF_FACTOR + oldYMagRawValue*(1 - MAG_LPF_FACTOR); + MAGz = MAGz * MAG_LPF_FACTOR + oldZMagRawValue*(1 - MAG_LPF_FACTOR); + ACCx = ACCx * ACC_LPF_FACTOR + oldXAccRawValue*(1 - ACC_LPF_FACTOR); + ACCy = ACCy * ACC_LPF_FACTOR + oldYAccRawValue*(1 - ACC_LPF_FACTOR); + ACCz = ACCz * ACC_LPF_FACTOR + oldZAccRawValue*(1 - ACC_LPF_FACTOR); + + oldXMagRawValue = MAGx + oldYMagRawValue = MAGy + oldZMagRawValue = MAGz + oldXAccRawValue = ACCx + oldYAccRawValue = ACCy + oldZAccRawValue = ACCz + + ######################################### + #### Median filter for accelerometer #### + ######################################### + # cycle the table + for x in range (ACC_MEDIANTABLESIZE-1,0,-1 ): + acc_medianTable1X[x] = acc_medianTable1X[x-1] + acc_medianTable1Y[x] = acc_medianTable1Y[x-1] + acc_medianTable1Z[x] = acc_medianTable1Z[x-1] + + # Insert the lates values + acc_medianTable1X[0] = ACCx + acc_medianTable1Y[0] = ACCy + acc_medianTable1Z[0] = ACCz + + # Copy the tables + acc_medianTable2X = acc_medianTable1X[:] + acc_medianTable2Y = acc_medianTable1Y[:] + acc_medianTable2Z = acc_medianTable1Z[:] + + # Sort table 2 + acc_medianTable2X.sort() + acc_medianTable2Y.sort() + acc_medianTable2Z.sort() + + # The middle value is the value we are interested in + ACCx = acc_medianTable2X[int(ACC_MEDIANTABLESIZE/2)]; + ACCy = acc_medianTable2Y[int(ACC_MEDIANTABLESIZE/2)]; + ACCz = acc_medianTable2Z[int(ACC_MEDIANTABLESIZE/2)]; + + + + ######################################### + #### Median filter for magnetometer #### + ######################################### + # cycle the table + for x in range (MAG_MEDIANTABLESIZE-1,0,-1 ): + mag_medianTable1X[x] = mag_medianTable1X[x-1] + mag_medianTable1Y[x] = mag_medianTable1Y[x-1] + mag_medianTable1Z[x] = mag_medianTable1Z[x-1] + + # Insert the latest values + mag_medianTable1X[0] = MAGx + mag_medianTable1Y[0] = MAGy + mag_medianTable1Z[0] = MAGz + + # Copy the tables + mag_medianTable2X = mag_medianTable1X[:] + mag_medianTable2Y = mag_medianTable1Y[:] + mag_medianTable2Z = mag_medianTable1Z[:] + + # Sort table 2 + mag_medianTable2X.sort() + mag_medianTable2Y.sort() + mag_medianTable2Z.sort() + + # The middle value is the value we are interested in + MAGx = mag_medianTable2X[int(MAG_MEDIANTABLESIZE/2)]; + MAGy = mag_medianTable2Y[int(MAG_MEDIANTABLESIZE/2)]; + MAGz = mag_medianTable2Z[int(MAG_MEDIANTABLESIZE/2)]; + + + + #Convert Gyro raw to degrees per second + rate_gyr_x = GYRx * G_GAIN + rate_gyr_y = GYRy * G_GAIN + rate_gyr_z = GYRz * G_GAIN + + + #Calculate the angles from the gyro. + gyroXangle+=rate_gyr_x*LP + gyroYangle+=rate_gyr_y*LP + gyroZangle+=rate_gyr_z*LP + + #Convert Accelerometer values to degrees + AccXangle = (math.atan2(ACCy,ACCz)*RAD_TO_DEG) + AccYangle = (math.atan2(ACCz,ACCx)+M_PI)*RAD_TO_DEG + + + #Change the rotation value of the accelerometer to -/+ 180 and + #move the Y axis '0' point to up. This makes it easier to read. + if AccYangle > 90: + AccYangle -= 270.0 + else: + AccYangle += 90.0 + + + + #Complementary filter used to combine the accelerometer and gyro values. + CFangleX=AA*(CFangleX+rate_gyr_x*LP) +(1 - AA) * AccXangle + CFangleY=AA*(CFangleY+rate_gyr_y*LP) +(1 - AA) * AccYangle + + #Kalman filter used to combine the accelerometer and gyro values. + kalmanY = kalmanFilterY(AccYangle, rate_gyr_y,LP) + kalmanX = kalmanFilterX(AccXangle, rate_gyr_x,LP) + + #Calculate heading + heading = 180 * math.atan2(MAGy,MAGx)/M_PI + + #Only have our heading between 0 and 360 + if heading < 0: + heading += 360 + + #################################################################### + ###################Tilt compensated heading######################### + #################################################################### + #Normalize accelerometer raw values. + accXnorm = ACCx/math.sqrt(ACCx * ACCx + ACCy * ACCy + ACCz * ACCz) + accYnorm = ACCy/math.sqrt(ACCx * ACCx + ACCy * ACCy + ACCz * ACCz) + + + #Calculate pitch and roll + pitch = math.asin(accXnorm) + roll = -math.asin(accYnorm/math.cos(pitch)) + + + #Calculate the new tilt compensated values + #The compass and accelerometer are orientated differently on the the BerryIMUv1, v2 and v3. + #This needs to be taken into consideration when performing the calculations + + #X compensation + if(IMU.BerryIMUversion == 1 or IMU.BerryIMUversion == 3): #LSM9DS0 and (LSM6DSL & LIS2MDL) + magXcomp = MAGx*math.cos(pitch)+MAGz*math.sin(pitch) + else: #LSM9DS1 + magXcomp = MAGx*math.cos(pitch)-MAGz*math.sin(pitch) + + #Y compensation + if(IMU.BerryIMUversion == 1 or IMU.BerryIMUversion == 3): #LSM9DS0 and (LSM6DSL & LIS2MDL) + magYcomp = MAGx*math.sin(roll)*math.sin(pitch)+MAGy*math.cos(roll)-MAGz*math.sin(roll)*math.cos(pitch) + else: #LSM9DS1 + magYcomp = MAGx*math.sin(roll)*math.sin(pitch)+MAGy*math.cos(roll)+MAGz*math.sin(roll)*math.cos(pitch) + + + + + + #Calculate tilt compensated heading + tiltCompensatedHeading = 180 * math.atan2(magYcomp,magXcomp)/M_PI + + if tiltCompensatedHeading < 0: + tiltCompensatedHeading += 360 + + + ##################### END Tilt Compensation ######################## + + + if 1: #Change to '0' to stop showing the angles from the accelerometer + outputString += "# ACCX Angle %5.2f ACCY Angle %5.2f # " % (AccXangle, AccYangle) + + if 1: #Change to '0' to stop showing the angles from the gyro + outputString +="\t# GRYX Angle %5.2f GYRY Angle %5.2f GYRZ Angle %5.2f # " % (gyroXangle,gyroYangle,gyroZangle) + + if 1: #Change to '0' to stop showing the angles from the complementary filter + outputString +="\t# CFangleX Angle %5.2f CFangleY Angle %5.2f #" % (CFangleX,CFangleY) + + if 1: #Change to '0' to stop showing the heading + outputString +="\t# HEADING %5.2f tiltCompensatedHeading %5.2f #" % (heading,tiltCompensatedHeading) + + if 1: #Change to '0' to stop showing the angles from the Kalman filter + outputString +="# kalmanX %5.2f kalmanY %5.2f #" % (kalmanX,kalmanY) + + print(outputString) + + #slow program down a bit, makes the output more readable + time.sleep(0.03) + From 07609e0443eae46350373148302a3d2f359091e4 Mon Sep 17 00:00:00 2001 From: MacHighPowerRocketry Date: Fri, 3 Mar 2023 16:19:34 -0600 Subject: [PATCH 40/40] start callibration work --- BerryIMU/IMU.py | 6 +++--- Sensors/berryAccelerometer.py | 2 ++ Sensors/berryGyroscope.py | 2 +- Sensors/berryMagnetometer.py | 13 +++++++------ berryIMU.py | 6 +++--- logs/debug.log | 16 ++++++++++++++++ run.py | 6 +++--- 7 files changed, 35 insertions(+), 16 deletions(-) diff --git a/BerryIMU/IMU.py b/BerryIMU/IMU.py index 817b24d..54d894a 100644 --- a/BerryIMU/IMU.py +++ b/BerryIMU/IMU.py @@ -36,7 +36,7 @@ def detectIMU(): print('') #need to do something here, so we just print a space else: if (LSM9DS0_WHO_G_response == 0xd4) and (LSM9DS0_WHO_XM_response == 0x49): - print("Found BerryIMUv1 (LSM9DS0)") + #print("Found BerryIMUv1 (LSM9DS0)") BerryIMUversion = 1 @@ -51,7 +51,7 @@ def detectIMU(): print('') #need to do something here, so we just print a space else: if (LSM9DS1_WHO_XG_response == 0x68) and (LSM9DS1_WHO_M_response == 0x3d): - print("Found BerryIMUv2 (LSM9DS1)") + #print("Found BerryIMUv2 (LSM9DS1)") BerryIMUversion = 2 try: @@ -65,7 +65,7 @@ def detectIMU(): print('') #need to do something here, so we just print a space else: if (LSM6DSL_WHO_AM_I_response == 0x6A) and (LIS3MDL_WHO_AM_I_response == 0x3D): - print("Found BerryIMUv3 (LSM6DSL and LIS3MDL)") + #print("Found BerryIMUv3 (LSM6DSL and LIS3MDL)") BerryIMUversion = 3 time.sleep(1) diff --git a/Sensors/berryAccelerometer.py b/Sensors/berryAccelerometer.py index 1a1f523..0ed8b42 100644 --- a/Sensors/berryAccelerometer.py +++ b/Sensors/berryAccelerometer.py @@ -74,9 +74,11 @@ def getNormalizedData(self): return [self.accXnorm, self.accYnorm] def getPitch(self): + self.applySensorReadLogic() return math.asin(self.accXnorm) def getRoll(self): + self.applySensorReadLogic() return -math.asin(self.accYnorm/math.cos(self.getPitch())) def toString(self): diff --git a/Sensors/berryGyroscope.py b/Sensors/berryGyroscope.py index 1057ca0..0fd8390 100644 --- a/Sensors/berryGyroscope.py +++ b/Sensors/berryGyroscope.py @@ -76,5 +76,5 @@ def getSensorData(self): def toString(self): x,y,z = self.roundDataValuesToDecimal(self.getSensorData()) - return "Gyroscope X Angle, Gyroscope Y Angle, Gyroscope Z Angle %s "%(x,y,z) + return "Gyroscope X Angle %s, Gyroscope Y Angle %s, Gyroscope Z Angle %s "%(x,y,z) diff --git a/Sensors/berryMagnetometer.py b/Sensors/berryMagnetometer.py index 550f78c..280dee8 100644 --- a/Sensors/berryMagnetometer.py +++ b/Sensors/berryMagnetometer.py @@ -13,10 +13,10 @@ class berryMagnetometer(sensor): - def __init__(self, logger): + def __init__(self, logger, accelerometer): self.logger = logger sensor.__init__(self, self.logger) - + self.accelerometer = accelerometer ################# Compass Calibration values ############ # Use calibrateBerryIMU.py to get calibration values # Calibrating the compass isnt mandatory, however a calibrated @@ -28,20 +28,21 @@ def __init__(self, logger): self.magYmax = 0 self.magZmax = 0 - def applySensorReadLogic(self, pitch, roll): + def applySensorReadLogic(self, pitch, roll, calibration): """ Sensor logic defined to retrieve and calibrate raw sensor data, to be called once per logic iteration """ rawSensorData = self.getRawSensorData() calibratedSensorData = self.applyCalibration(rawSensorData) compensatedTiltValues = self.calculateTiltCompensatedValues(calibratedSensorData, pitch, roll) - self.heading = self.calculateTiltCompensatedHeading(compensatedTiltValues) + self.heading = self.calculateTiltCompensatedHeading(compensatedTiltValues) + calibration + def compensateHeadingBy(self, value): + self.heading = self.heading + value def getSensorData(self): #returns tilt heading, compensated by calibrated values - accelerometer = berryAccelerometer(self.logger) - self.applySensorReadLogic(accelerometer.getPitch, accelerometer.getRoll) + self.applySensorReadLogic(self.accelerometer.getPitch(), self.accelerometer.getRoll(), -55) return [self.heading] diff --git a/berryIMU.py b/berryIMU.py index 638886a..30bad41 100644 --- a/berryIMU.py +++ b/berryIMU.py @@ -20,7 +20,7 @@ import sys import time import math -import IMU +from BerryIMU import IMU import datetime import os @@ -390,13 +390,13 @@ def kalmanFilterX ( accAngle, gyroRate, DT): if 1: #Change to '0' to stop showing the angles from the gyro outputString +="\t# GRYX Angle %5.2f GYRY Angle %5.2f GYRZ Angle %5.2f # " % (gyroXangle,gyroYangle,gyroZangle) - if 1: #Change to '0' to stop showing the angles from the complementary filter + if 0: #Change to '0' to stop showing the angles from the complementary filter outputString +="\t# CFangleX Angle %5.2f CFangleY Angle %5.2f #" % (CFangleX,CFangleY) if 1: #Change to '0' to stop showing the heading outputString +="\t# HEADING %5.2f tiltCompensatedHeading %5.2f #" % (heading,tiltCompensatedHeading) - if 1: #Change to '0' to stop showing the angles from the Kalman filter + if 0: #Change to '0' to stop showing the angles from the Kalman filter outputString +="# kalmanX %5.2f kalmanY %5.2f #" % (kalmanX,kalmanY) print(outputString) diff --git a/logs/debug.log b/logs/debug.log index c3670c7..4ca4c6c 100644 --- a/logs/debug.log +++ b/logs/debug.log @@ -820,3 +820,19 @@ 2023-03-01 17:17:42,481 WARNING Pressure sersor is BMP388! +2023-03-03 15:37:21,726 WARNING Pressure sersor is BMP388! + +2023-03-03 15:38:07,490 WARNING Pressure sersor is BMP388! + +2023-03-03 15:40:04,018 WARNING Pressure sersor is BMP388! + +2023-03-03 15:41:18,927 WARNING Pressure sersor is BMP388! + +2023-03-03 15:47:59,283 WARNING Pressure sersor is BMP388! + +2023-03-03 15:51:00,391 WARNING Pressure sersor is BMP388! + +2023-03-03 15:51:41,833 WARNING Pressure sersor is BMP388! + +2023-03-03 16:18:19,260 WARNING Pressure sersor is BMP388! + diff --git a/run.py b/run.py index 443c6f6..ca5d5a8 100644 --- a/run.py +++ b/run.py @@ -8,14 +8,14 @@ accelerometer = berryAccelerometer.berryAccelerometer(logger) gyroscope = berryGyroscope.berryGyroscope(logger) -magnetometer = berryMagnetometer.berryMagnetometer(logger) +magnetometer = berryMagnetometer.berryMagnetometer(logger, accelerometer) tempPressureAltitudeSensor = pressureSensor.pressureSensor(logger) gps = berryGPS.berryGPS(logger) #sensors = [accelerometer, gyroscope, magnetometer, tempPressureAltitudeSensor, gps] +print("Finished loading sensors") - -sensors = [gps] +sensors = [accelerometer,gyroscope,magnetometer] def logSensorData(): for sensor in sensors: logger.dataLog(sensor.toString())