This commit is contained in:
fengbh 2024-07-07 19:02:36 +08:00
parent 8ea43ebed0
commit b11383c5bb
4 changed files with 15 additions and 2 deletions

View File

@ -38,8 +38,14 @@ uart_temp是用于8051单片机上的一个项目用于获取温度并使
4. 打开串口软件,接收来自单片机的数据
串口波特率9600
```bash
minicom -D /dev/ttyUSB0 -b 9600
```
5. 运行`process.py`解析数据生成图片
```bash
# 新建虚拟环境
virtualenv env

BIN
SimHei.ttf Normal file

Binary file not shown.

View File

@ -21,7 +21,11 @@ for line in lines:
timedelta(minutes=int(time_str.split(':')[1])) + \
timedelta(hours=int(time_str.split(':')[0]))
temperature = float(temp_str)
if temperature >= 10 and temperature <= 40:
if len(temperatures) > 0:
pre_temp = temperatures[-1]
else:
pre_temp = temperature
if pre_temp-0.5 < temperature < pre_temp+0.5:
times.append(time)
temperatures.append(temperature)

3
test.py Normal file
View File

@ -0,0 +1,3 @@
import matplotlib
print(matplotlib.matplotlib_fname())
print(matplotlib.get_cachedir())