0. Introduction
I’m currently developing a project that needs a thermal camera and I found the AMG8833 IR Thermal Camera from Adafruit. In order to test it, I connected it to an Arduino board and uploaded the example sketch from their library, but I didn’t like it too much and for this reason I developed this simple script you can download from my GitHub repo in order to get a better visualization of the data.
1. Install the library and upload the script on the Arduino
In order to make my script interface with the arduino, I used the Adafruit_AMG88xx library. You can download it from the Arduino IDE itself:
- click on Sketch –> #include library –> Manage Library;
- insert AMG8833 as filter
- Click on Adafruit AMG88xx Library and click “Install”
Now the library is installed inside your Arduino IDE and you can open and upload the library example called “pixels_test” (you find it on File/Examples/Adafruit AMG88xx Library/pixels_test).
2. Install all necessary python libraries
In order to install all libraries faster, I use a tool named “pip”. You can find all the documentation about it on this page The libraries you need to install are NumPy, MatPlotLib and PySerial. Just open a terminal and type:
sudo pip install numpy #or pip2 if using python2.7
sudo pip install matplotlib
sudo pip install pyserial
3. Running the code
After installing all the library, you can finally run your script. Before doing that, be sure edit line 7 in order to connect to your arduino serial port:
ser = serial.Serial('/dev/ttyUSB0') #change '/dev/ttyUSB0' with your serial port
After doing this, you are ready to run the code. Just open a terminal and type:
python thermal_camera.py
And after few seconds it should open a window like this: (the last picture will also be saved in png format in the directory you launched the script).
Now you can use this script to visualize in realtime the output of the thermal camera.
I hope this tutorial could be useful to someone out there and if you have any doubts or issues don’t be afraid to ask in the comment section below this post.
November 23, 2018 at 3:50 am
I hope this tutorial could be useful to someone out there and if you have any doubts or issues don’t be afraid to ask in the comment section below this post.
February 1, 2019 at 6:49 am
Hey! Thanks a lot for this! I got the libraries installed and the code running as well. But I am facing an issue where the output is always at zero and is showing a totally purple background. Also, what changes have to be made to this code to obtain real time images on screen? TIA.
February 1, 2019 at 7:50 am
Did you upload the correct Arduino Sketch on your board? Have you insered the correct serial port as shown in part 3?
February 1, 2019 at 3:23 pm
The pixels_test from the adafruit amg88xx library? yes! but there seems to be no output, only a blank plot. Please help me out
February 1, 2019 at 3:42 pm
What do you get from the Arduino serial terminal? Can you copy the output here?
February 1, 2019 at 3:51 pm
[28.50, 28.75, 29.00, 31.75, 33.25, 33.50, 34.00, 34.00,
28.75, 29.25, 31.50, 33.00, 33.75, 33.75, 33.75, 33.75,
28.25, 30.00, 32.75, 33.50, 33.50, 33.50, 33.75, 34.25,
29.25, 31.25, 32.75, 33.25, 33.25, 33.50, 33.75, 33.75,
29.25, 31.75, 32.75, 33.25, 33.50, 33.75, 33.50, 34.00,
29.00, 31.25, 33.25, 33.25, 33.50, 33.50, 33.75, 32.50,
29.50, 30.25, 32.50, 33.25, 33.25, 32.75, 32.50, 29.75,
29.25, 29.50, 29.75, 29.75, 30.00, 30.25, 29.75, 30.75,
]
February 2, 2019 at 8:40 am
Are you sure it’s the right Serial Port? Is the Serial Port at line 7 the same as the one you are using in Arduino?
February 2, 2019 at 8:57 am
Yes. I mentioned “COM3”
February 2, 2019 at 9:00 am
ser = serial.Serial(“COM3”,9600)
Or
ser = serial.Serial(‘COM3’)
Or
ser = serial.Serial(“COM3”)
March 12, 2019 at 8:41 pm
Do you get any output from this code?
import serial
from numpy import *
import matplotlib.pyplot as plt
from pylab import *
ser = serial.Serial('/dev/ttyUSB0')
char = ser.read()
print(char)
November 5, 2020 at 2:58 pm
I’m using Anaconda environment (spyder editor) but the code don’t work as expected… it runs, but don’t show window with the output. Don’t save image file too… but the serial output from arduino shows normal data.
November 5, 2020 at 8:01 pm
Are you sure you have the right permissions to read from the serial port? Have you tried to print the matrix?
November 12, 2020 at 10:37 pm
Yes, i can read from serial port with python, but nothing happens when i run this script, no output (window ou image in disk). I have tested in mac and linux