-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathheatplusaws.py
More file actions
66 lines (46 loc) · 1.51 KB
/
heatplusaws.py
File metadata and controls
66 lines (46 loc) · 1.51 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
55
56
57
58
59
60
61
62
63
64
65
66
import boto3
from botocore.exceptions import NoCredentialsError
ACCESS_KEY = 'AKIAX4F3GCZSM6TRSRXS'
SECRET_KEY = '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'
def upload_to_aws(local_file, bucket, s3_file):
s3 = boto3.client('s3', aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY)
try:
print(s3.upload_file(local_file, bucket, s3_file))
return True
except FileNotFoundError:
return False
except NoCredentialsError:
return False
import serial
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
PORT = '/dev/ttyUSB0'
BaudRate = 9600
ARD = serial.Serial(PORT,BaudRate)
array=[]
buf=[]
cnt = 0
def Ardread(cnt): # return list [Ard1,Ard2]
if ARD.readable():
LINE = ARD.readline()
data = LINE.decode('utf-8')
data = data.strip('\n')
data = data.strip('\r')
splitData = data.split(',')
print(splitData)
for i in range(0,16) :
splitData[i] = int(splitData[i])
splitData = np.reshape(splitData,(4,4))
ax = sns.heatmap(splitData, cmap='Blues', cbar=False , vmin = 0, vmax = 1000)
ax.tick_params(left=False, bottom=False)
ax.axes.xaxis.set_visible(False)
ax.axes.yaxis.set_visible(False)
fname = 'savefig_200dpi' + str(cnt) +'.png'
plt.savefig(fname, dpi=200)
uploaded = upload_to_aws(fname, 'bucektmin', fname)
else :
print("Fail from _Ardread_")
while (True):
Ardread(cnt)
cnt+=1