-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0824171
commit d9024aa
Showing
8 changed files
with
37 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import annotations | ||
|
||
from adafruit_bus_device.i2c_device import I2CDevice | ||
from busio import I2C # type: ignore | ||
|
||
from pioreactor import hardware | ||
|
||
|
||
class TMP1075: | ||
""" | ||
Driver for the TI TMP1075 temperature sensor. | ||
See datasheet: http://www.ti.com/lit/ds/symlink/tmp1075.pdf | ||
""" | ||
|
||
TEMP_REGISTER = bytearray([0x00]) | ||
CONFIG_REGISTER = bytearray([0x01]) | ||
|
||
def __init__(self, address: int = 0x4F): | ||
comm_port = (I2C(hardware.SCL, hardware.SDA),) | ||
self.i2c = I2CDevice(comm_port, address) | ||
|
||
def get_temperature(self) -> float: | ||
b = bytearray(2) | ||
self.i2c.write_then_readinto(self.TEMP_REGISTER, b) | ||
return ((b[0] << 4) + (b[1] >> 4)) * 0.0625 | ||
|
||
@property | ||
def temperature(self): | ||
"""alias for get_temperature""" | ||
return self.get_temperature() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters