Commit 81e52a54 authored by Wijesundara W.M.S.G's avatar Wijesundara W.M.S.G

Add new file

parent 7f898536
import time,sys
sys.path.append('../')
# Load AMG8833
import amg8833_i2c
import numpy as np
import matplotlib.pyplot as plt
from scipy import interpolate
# Initialization of Sensor
t0 = time.time()
sensor = []
while (time.time()-t0)<1:
try:
# AD0 = GND, addr = 0x68 | AD0 = 5V, addr = 0x69
sensor = amg8833_i2c.AMG8833(addr=0x69) # Start AMG8833
except:
sensor = amg8833_i2c.AMG8833(addr=0x68)
finally:
pass
time.sleep(0.1)
if sensor==[]:
print("No AMG8833 Found")
sys.exit();
pix_res = (8,8) # Pixel Resolution
xx,yy = (np.linspace(0,pix_res[0],pix_res[0]),
np.linspace(0,pix_res[1],pix_res[1]))
zz = np.zeros(pix_res) # Zero array
pix_mult = 8 # Resolution Multiply
interp_res = (int(pix_mult*pix_res[0]),int(pix_mult*pix_res[1]))
grid_x,grid_y = (np.linspace(0,pix_res[0],interp_res[0]),
np.linspace(0,pix_res[1],interp_res[1]))
def interp(z_var):
f = interpolate.interp2d(xx,yy,z_var,kind='cubic')
return f(grid_x,grid_y)
grid_z = interp(zz)
plt.rcParams.update({'font.size':16})
fig_dims = (10,9)
fig,ax = plt.subplots(figsize=fig_dims)
fig.canvas.set_window_title('AMG8833 Thermal Output')
im1 = ax.imshow(grid_z,vmin=18,vmax=37,cmap=plt.cm.RdBu_r)
cbar = fig.colorbar(im1,fraction=0.0475,pad=0.03)
cbar.set_label('Temperature [C]',labelpad=10)
fig.canvas.draw()
ax_bgnd = fig.canvas.copy_from_bbox(ax.bbox)
fig.show()
pix_to_read = 64
while True:
status,pixels = sensor.read_temp(pix_to_read)
if status:
continue
T_thermistor = sensor.read_thermistor() # Read Thermistor Temperature
fig.canvas.restore_region(ax_bgnd) # Restore Background
new_z = interp(np.reshape(pixels,pix_res))
im1.set_data(new_z)
ax.draw_artist(im1)
fig.canvas.blit(ax.bbox)
fig.canvas.flush_events()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment