日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python实时显示温度变化_python实时温度绘制

發(fā)布時間:2025/3/15 python 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python实时显示温度变化_python实时温度绘制 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我目前正在做一個項目,它需要實時監(jiān)控各種量,如溫度、壓力、濕度等。我正在采用一種方法,即使用matplotlib和drwnow繪制一個圖形。在HOST = "localhost"

PORT = 4223

UID1 = "tsJ" # S1

from tinkerforge.ip_connection import IPConnection

from tinkerforge.bricklet_ptc import BrickletPTC

import numpy as np

import serial

import matplotlib

from matplotlib.ticker import ScalarFormatter, FormatStrFormatter

import matplotlib.pyplot as plt

from matplotlib import style

style.use('ggplot')

from drawnow import *

# creating arrays to feed the data

tempC1 = []

def makeafig():

# creating subplots

fig1 = plt.figure(1)

a = fig1.add_subplot(111)

#setting up axis label, auto formating of axis and title

a.set_xlabel('Time [s]', fontsize = 10)

a.set_ylabel('Temperature [°C]', fontsize = 10)

y_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)

a.yaxis.set_major_formatter(y_formatter)

title1 = "Current Room Temperature (Side1): " + str(temperature1/100) + " °C"

a.set_title(title1, fontsize = 10)

#plotting the graph

a.plot(tempC1, "#00A3E0")

#saving the figure

fig1.savefig('RoomTemperature.png', dpi=100)

while True:

ipcon = IPConnection() # Create IP connection

ptc1 = BrickletPTC(UID1, ipcon) # S1

ipcon.connect(HOST, PORT) # Connect to brickd

#setting the temperature from PTC bricklet

temperature1 = ptc1.get_temperature()

#processing data from a temperature sensor to 1st array

dataArray1=str(temperature1/100).split(',')

temp1 = float(dataArray1[0])

tempC1.append(temp1)

#making a live figure

drawnow(makeafig)

plt.draw()

這是我在互聯(lián)網上發(fā)現(xiàn)的很好的方法,它正在起作用。我所面臨的唯一問題是,如果我為其他傳感器制作更多的陣列,那么它會耗費更多的時間,而且與秒表相比,所繪制的繪圖會滯后于實時。在

對于任何一個有效率的實時圖像獲取方法都是有效的。

或者任何命令來清除已經打印的數(shù)組值?在

如果有人能幫我解決這個問題,我將不勝感激。在

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結

以上是生活随笔為你收集整理的python实时显示温度变化_python实时温度绘制的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。