From 251c5aaa88489e7478c702078a3e044801845b4f Mon Sep 17 00:00:00 2001 From: pstruebi Date: Mon, 24 Nov 2025 15:34:24 +0100 Subject: [PATCH] add temperature logging script add dependencies --- .gitignore | 3 ++- poetry.lock | 28 ++++++++++++++++++++++++-- pyproject.toml | 3 ++- src/scripts/log_temperature.py | 36 ++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 src/scripts/log_temperature.py diff --git a/.gitignore b/.gitignore index 49984d1..2f43ec2 100644 --- a/.gitignore +++ b/.gitignore @@ -48,4 +48,5 @@ pcm1862-i2s.dtbo ch1.wav ch2.wav src/auracast/available_samples.txt -src/auracast/server/stream_settings2.json \ No newline at end of file +src/auracast/server/stream_settings2.json +src/scripts/temperature_log* diff --git a/poetry.lock b/poetry.lock index dba8f46..c609b04 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand. [[package]] name = "aioconsole" @@ -2443,6 +2443,30 @@ files = [ {file = "rpds_py-0.25.1.tar.gz", hash = "sha256:8960b6dac09b62dac26e75d7e2c4a22efb835d827a7278c34f72b2b84fa160e3"}, ] +[[package]] +name = "samplerate" +version = "0.2.2" +description = "Monolithic python wrapper for libsamplerate based on pybind11 and NumPy" +optional = false +python-versions = ">=3.7" +groups = ["main"] +files = [ + {file = "samplerate-0.2.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:99b47c238ef7216b87ccf5e8860b94b527cceef7a8add38f146e75f6efec257f"}, + {file = "samplerate-0.2.2-cp310-cp310-win_amd64.whl", hash = "sha256:0aa6ae933cb85eac5ffdebc38abc198be890c2bcbac263c30301699d651e9513"}, + {file = "samplerate-0.2.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:a41fe7a8c68101bf9900ba415cf2a0a58199bba9cac15e0a3b22b70006705b29"}, + {file = "samplerate-0.2.2-cp311-cp311-win_amd64.whl", hash = "sha256:86fb8eb9a6c75d4c17f8125e203d29bf2d87bf5ce0e671184ba5111f015c9264"}, + {file = "samplerate-0.2.2-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:3f30fea3e42b51e2441cf464e24c4744fa0b9a837b7beefb6a8eb6cc72af1e51"}, + {file = "samplerate-0.2.2-cp312-cp312-win_amd64.whl", hash = "sha256:1170c5e4f68d9c1bbec2fce1549108838a473058f69cca7bc377e053ee43457b"}, + {file = "samplerate-0.2.2-cp38-cp38-macosx_11_0_universal2.whl", hash = "sha256:567dfe3888634435b8da1ac4bc06ad289ba777876f446760249e923e6b3585c5"}, + {file = "samplerate-0.2.2-cp38-cp38-win_amd64.whl", hash = "sha256:6c819b0360e9632be0391ec3eecc15510e30775632f4022e384e28908f59648c"}, + {file = "samplerate-0.2.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:d072b658e438d55fed1224da9b226be1328ff9aea4268d02dbc7d864a72ce4f4"}, + {file = "samplerate-0.2.2-cp39-cp39-win_amd64.whl", hash = "sha256:bdae4f21890378f3886816800c8ef3395dabaa13fcac07bb0de7ad413703bfef"}, + {file = "samplerate-0.2.2.tar.gz", hash = "sha256:40964bfa28d33bc948389d958c2e742585f21891d8372ebba89260f491a15caa"}, +] + +[package.dependencies] +numpy = "*" + [[package]] name = "six" version = "1.17.0" @@ -2952,4 +2976,4 @@ test = ["pytest", "pytest-asyncio"] [metadata] lock-version = "2.1" python-versions = ">=3.11" -content-hash = "6b5300c349ed045e8fd3e617e6262bbd7e5c48c518e4c62cedf7c17da50ce8c0" +content-hash = "3c9f92c7a5af40f98da9c7824d9c2a6f7eb809e91e43cfef4995761b2e887256" diff --git a/pyproject.toml b/pyproject.toml index 799f3ce..e93c66d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,8 @@ dependencies = [ "aiortc (>=1.13.0,<2.0.0)", "sounddevice (>=0.5.2,<0.6.0)", "python-dotenv (>=1.1.1,<2.0.0)", - "smbus2 (>=0.5.0,<0.6.0)" + "smbus2 (>=0.5.0,<0.6.0)", + "samplerate (>=0.2.2,<0.3.0)" ] [project.optional-dependencies] diff --git a/src/scripts/log_temperature.py b/src/scripts/log_temperature.py new file mode 100644 index 0000000..75420af --- /dev/null +++ b/src/scripts/log_temperature.py @@ -0,0 +1,36 @@ +import csv +import time +from datetime import datetime +from pathlib import Path + +from auracast.utils.read_temp import read_case_temp, read_cpu_temp + + +def main() -> None: + script_path = Path(__file__).resolve() + log_dir = script_path.parent + + start_time = datetime.now() + filename = start_time.strftime("temperature_log_%Y%m%d_%H%M%S.csv") + log_path = log_dir / filename + + with log_path.open("w", newline="") as csvfile: + writer = csv.writer(csvfile) + writer.writerow(["timestamp", "cpu_temp_c", "case_temp_c"]) + + try: + while True: + now = datetime.now().isoformat(timespec="seconds") + cpu_temp = read_cpu_temp() + case_temp = read_case_temp() + + writer.writerow([now, cpu_temp, case_temp]) + csvfile.flush() + + time.sleep(30) + except KeyboardInterrupt: + pass + + +if __name__ == "__main__": + main()