Skip to content

Commit

Permalink
adding Temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
jposada202020 committed Apr 26, 2023
1 parent 7a5e7cd commit b4c3f79
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions micropython_icm20948/icm20948.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from time import sleep
from micropython import const
from i2c_helpers import CBits, RegisterStruct
from micropython_icm20948.i2c_helpers import CBits, RegisterStruct

__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/jposada202020/MicroPython_ICM20948.git"
Expand Down Expand Up @@ -140,7 +140,7 @@ class ICM20948:

_raw_accel_data = RegisterStruct(_ACCEL_XOUT_H, ">hhh")
_raw_gyro_data = RegisterStruct(_GYRO_XOUT_H, ">hhh")
_raw_temp_data = RegisterStruct(_TEMP_OUT, ">h")
_raw_temp_data = RegisterStruct(_GYRO_XOUT_H, ">hhhh")

# Register REG_BANK_SEL (0x7F)
# | ---- | ---- | USER_BANK(1) | USER_BANK(0) | ---- | ---- | ---- | ---- |
Expand Down Expand Up @@ -170,11 +170,8 @@ def __init__(self, i2c, address=_REG_WHOAMI):
# print("bank", self._bank)
# print("accelerometer", self.accelerometer_range)
print(self._raw_temp_data)
print(self.accelerometer_range)
print("temp enabled", self._temp_enabled)
print(self.acceleration)

print(self._raw_temp_data / 333)
# print(self._raw_temp_data/333)

@property
def clock_select(self):
Expand Down Expand Up @@ -347,7 +344,7 @@ def gyro(self):
@property
def power_bank(self):
"""
Returns the current power bank
Power bank selected
"""
return self._user_bank

Expand Down Expand Up @@ -420,7 +417,8 @@ def gyro_full_scale(self, value):
@property
def temperature(self):
"""
Temperature Value. This did not work with the sensor that I have
Temperature Value. In the setup tested, there is the need to read either the values from acceleration,
gyro and temperature or gyro and temperature at the same time in order to have a logic temperature value.
"""
return (self._raw_temp_data / 333) + 21
return (self._raw_temp_data[3] / 333.87) + 21

0 comments on commit b4c3f79

Please sign in to comment.