Home

Awesome

micropython-amg88xx

Driver for Grid-EYE 8x8 pixel thermal infra red array sensor (Adafruit 3538).

Now provides optional bicubic interpolation for camera displays.

The driver is a port of the Adafruit CircuitPython driver modified for MicroPython.

Original author(s): Dean Miller, Scott Shawcroft.
Adapted by Peter Hinch. Dependencies on Adafruit libraries removed, coding adapted to conform to MicroPython conventions. Extended to provide additional functionality.

A typical camera build:
Image
Interpolated images (a cup of coffee):
Image
My chair a while after I had got up:
Image
A re-creation of the Adafruit fingers demo. Note that their version uses numpy and scipy on a Raspberry Pi as against bicubic interpolation on a Pyboard. Image

The update rate with bicubic interpolation is just over 3Hz.

1. Files

For thermal camera use:

The Adafruit OLED display driver is from this repo which also has drivers for their larger displays based on the SSD1351 chip. The repo has optional drivers supporting 16 bit color: these trade improved color against a larger frame buffer, and so are best suited to platforms with plenty of RAM.

The driver for the official LCD160CR is included in Pyboard firmware. Source is here.

The my_cam directory contains a complete set of files for my camera project.

1.1 Interpolation

In camera applications the 8x8 matrix of the AMG8833 gives a "blocky" effect. This can be reduced by using bicubic interpolation. Files and doc for this are in the interpolate directory.

2. Wiring

If used with a Pyboard

pyboardamg8833
3V3VIN
GNDGND
SCL X9SCL
SDA X10SDA

3. AMG88XX class

This maintains an internal bytearray object holding a single frame of raw data from the sensor. It is populated by the refresh method. The contents may be retrieved as integer temperatures in °C by means of array access syntax.

Constructor:
This takes the following arguments:

Data access methods:

Mode setting methods:

Example usage:
After issuing the refresh method, a set of pixel data may be read by means of array access.

import machine
import utime
from amg88xx import AMG88XX

i2c = machine.I2C(1)
sensor = AMG88XX(i2c)
while True:
    utime.sleep(0.2)
    sensor.refresh()
    for row in range(8):
        print()
        for col in range(8):
            print('{:4d}'.format(sensor[row, col]), end='')

4. Camera demo cam.py

This assumes a Pyboard linked to an Adafruit 0.96 OLED display. Wiring is as follows:

pyboardOLED
3V3VCC
GNDGND
X8 MOSISDA
X6 SCLSCL
X3RES
X2CS
X1DC

The sensor is wired as in section 2.

Orientation of the display may be adjusted to match the physical layout of the devices by setting the following program booleans:

The limits of temperature display may be adjusted by assigning integer values to these program values:

5 Camera demo cam_lcd.py

As written this assumes a Pyboard 1.x with the LCD fitted in the 'Y' position and the sensor wired as in section 2.

Orientation of the display may be adjusted to match the physical layout of the devices by setting the following program booleans:

The limits of temperature display may be adjusted by assigning integer values to these program values:

6. Mapper class for cameras

This simple class converts a temperature in °C to 8 bit rgb color values compatible with most display drivers. Conversion uses a predefined mapping with blue for low temperatures through green to red, with constant overall brightness. Out of range temperature values are clipped to the maximum or minimum as required. The range covered may be dynamically altered.

Constructor
This takes the following args:

Methods: