-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiletest.py
More file actions
54 lines (48 loc) · 1.08 KB
/
filetest.py
File metadata and controls
54 lines (48 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/python3
import math
import os
import random
import re
import sys
import serial
import matplotlib.pyplot as plt
import time
#f= open("guru99.txt","w+")
#fh = open("welcome.txt","r")
#print (f.read())
def plotFunctionList(dataToBePlotted):
""" função que serve para plotar"""
plt.plot(dataToBePlotted)
plt.show()
time.sleep(3)
plt.cla()
plt.clf()
plt.close()
#Variable declarations
humidity_list = []
temperatureList = []
xAxysList = []
rcv = [0]
#Setup Serial Port
port = serial.Serial("COM4", baudrate=115200, timeout=3.0)
rcv = port.read(100)
rcv = rcv.decode('ASCII')
port.close
t=0 #numero de amostras de temperatura e umidade antes de plotar
while t<100:
# buffer de x tamanho
port.write(b'O')
port.close
rcv = port.read(100)
#decodificando de byte para ASCII
rcv = rcv.decode('ASCII')
port.close
print(rcv)
temperature = int(rcv[0:2])
print(t)
#humidity_list.append(humidity)
temperatureList.append(temperature)
xAxysList.append(t)
t = t+1
time.sleep(5)
plotFunctionList(temperatureList)