Grafic Monitorizare Temperatura [repack] (Trusted 2025)

ser = serial.Serial(port, baud)

import serial import matplotlib.pyplot as plt import matplotlib.animation as animation from collections import deque MAX_POINTS = 100 port = 'COM3' # adjust to your port baud = 9600 Data buffer temp_data = deque(maxlen=MAX_POINTS) time_data = deque(maxlen=MAX_POINTS) grafic monitorizare temperatura

def update_plot(frame): line = ser.readline().decode().strip() try: temp = float(line) temp_data.append(temp) time_data.append(len(time_data)) # sample index ax.clear() ax.plot(time_data, temp_data, 'b-', label='Temperature') ax.axhline(y=25, color='r', linestyle='--', label='Upper limit') ax.axhline(y=15, color='g', linestyle='--', label='Lower limit') ax.set_ylim(0, 50) ax.set_ylabel('Temp (°C)') ax.set_xlabel('Sample number') ax.set_title('Real-time Temperature Monitor') ax.legend() ax.grid(True) except: pass ser = serial