add case temperature readout
This commit is contained in:
11
README.md
11
README.md
@@ -189,6 +189,17 @@ sudo ldconfig # refresh linker cache
|
||||
- disable pw login
|
||||
- reboot
|
||||
|
||||
# Use temperature sensor
|
||||
- uncomment in config.txt:
|
||||
- dtparam=i2c_arm=on
|
||||
- reboot
|
||||
- load drivers
|
||||
- sudo modprobe i2c_bcm2835
|
||||
- sudo modprobe i2c-dev
|
||||
- echo i2c_bcm2835 | sudo tee -a /etc/modules
|
||||
- echo i2c-dev | sudo tee -a /etc/modules
|
||||
- read temp /src/scripts/temp
|
||||
|
||||
# Known issues:
|
||||
- When running on a laptop there might be issues switching between usb and browser audio input since they use the same audio device
|
||||
|
||||
|
||||
18
poetry.lock
generated
18
poetry.lock
generated
@@ -2453,6 +2453,22 @@ files = [
|
||||
{file = "six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smbus2"
|
||||
version = "0.5.0"
|
||||
description = "smbus2 is a drop-in replacement for smbus-cffi/smbus-python in pure Python"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "smbus2-0.5.0-py2.py3-none-any.whl", hash = "sha256:1a15c3b9fa69357beb038cc0b5d37939702f8bfde1ddc89ca9f17d8461dbe949"},
|
||||
{file = "smbus2-0.5.0.tar.gz", hash = "sha256:4a5946fd82277870c2878befdb1a29bb28d15cda14ea4d8d2d54cf3d4bdcb035"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
docs = ["sphinx (>=1.5.3)"]
|
||||
qa = ["flake8"]
|
||||
|
||||
[[package]]
|
||||
name = "smmap"
|
||||
version = "5.0.2"
|
||||
@@ -2934,4 +2950,4 @@ test = ["pytest", "pytest-asyncio"]
|
||||
[metadata]
|
||||
lock-version = "2.1"
|
||||
python-versions = ">=3.11"
|
||||
content-hash = "723981c612b424756f0338604c35c9cef37fd44ffd208e15c7865b1f5e83bc05"
|
||||
content-hash = "9fe0e4746a6fca45e5aa9117ca177a5587c3a7b83cacb9427bdb960c4f0c7036"
|
||||
|
||||
@@ -15,7 +15,8 @@ dependencies = [
|
||||
"streamlit (>=1.45.1,<2.0.0)",
|
||||
"aiortc (>=1.13.0,<2.0.0)",
|
||||
"sounddevice (>=0.5.2,<0.6.0)",
|
||||
"python-dotenv (>=1.1.1,<2.0.0)"
|
||||
"python-dotenv (>=1.1.1,<2.0.0)",
|
||||
"smbus2 (>=0.5.0,<0.6.0)"
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
|
||||
@@ -669,7 +669,7 @@ if __name__ == "__main__":
|
||||
#config.transport='serial:/dev/serial/by-id/usb-ZEPHYR_Zephyr_HCI_UART_sample_95A087EADB030B24-if00,115200,rtscts' #nrf52dongle hci_uart usb cdc
|
||||
#config.transport='usb:2fe3:000b' #nrf52dongle hci_usb # TODO: iso packet over usb not supported
|
||||
#config.transport= 'auto'
|
||||
config.transport='serial:/dev/ttyAMA4,1000000,rtscts' # transport for raspberry pi
|
||||
config.transport='serial:/dev/ttyAMA3,1000000,rtscts' # transport for raspberry pi
|
||||
|
||||
# TODO: encrypted streams are not working
|
||||
|
||||
|
||||
8
src/scripts/read_case_temp.py
Normal file
8
src/scripts/read_case_temp.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from smbus2 import SMBus
|
||||
addr = 0x48 # change if your scan shows different
|
||||
with SMBus(1) as bus:
|
||||
msb, lsb = bus.read_i2c_block_data(addr, 0x00, 2)
|
||||
raw = ((msb << 8) | lsb) >> 4
|
||||
if raw & 0x800: # sign bit for 12-bit
|
||||
raw -= 1 << 12
|
||||
print(f"{raw * 0.0625:.2f} °C")
|
||||
Reference in New Issue
Block a user