Drivers for AMG8833 Grid-eye Infrared Sensor

These drivers support the AMG8833 Infrared Array Sensor Grid-EYE.

_images/floop-amg8833.png

This is a grid-eye infrared camera that can measure the temperature of an 8-by-8 grid of pixels (64 total). The sensor can measure temperatures between -0 °C and 80 °C with an accuracy of 2.5 °C.

Prerequisites

  • Linux device with an AMG8833 connected via I2C, such as any version of Forward Loop Zero with the optional grid-eye infrared.
  • (Optional) Docker on the Linux device. We recommend you check out floop, our simple, open-source tool for working with embedded Docker on multiple devices at the same time.

Install

In order to use the drivers with floop, you configure the drivers and your application on a host device then push the source code and build instructions to each target device using floop.

On your host, install floop using pip:

pip install --upgrade floopcli

Clone the driver repository:

git clone --recursive https://github.com/ForwardLoopLLC/amg8833

The clone needs to be recursive in order to clone the appropriate I2C drivers.

Change directory into driver directory:

cd amg8833

Configure floop to allow access to I2C devices on the target device. For example, if you have one target device available over SSH at the address 192.168.1.100, your floop.json in the mlx90614 directory could be:

{
   "groups":{
      "group0":{
         "cores":{
            "default":{
               "host_network":false,
               "hardware_devices":[

               ],
               "privileged":true,
               "build_file":"Dockerfile.linux",
               "test_file":"Dockerfile.test",
               "docker_socket":"",
               "host_source":"./"
            },
            "core2":{
               "address":"192.168.1.109",
               "target_source":"/home/floop/floop/",
               "host_key":"~/.ssh/id_rsa",
               "user":"floop",
               "port":"22"
            }
         }
      },
      "default":{
         "host_rsync_bin":"/usr/bin/rsync",
         "host_docker_machine_bin":"/usr/local/bin/docker-machine"
      }
   }
}

Notice that privileged is true, so floop has access to target device hardware.

In order to check that installation succeeded, you can run the simple example included in the driver repository. You will need to tell the driver which bus holds the MLX90614.

Edit the file run.sh.linux:

#!/bin/bash
BUS=0 # change this value to match the i2c bus where your amg8833 is connected
mkdir -p /drivers/i2c/
mkdir -p /drivers/amg8833/
cp /floop/include/i2c/linux/*.h /drivers/i2c/
cp /floop/amg8833/*.h /drivers/amg8833/
g++ /floop/example/main.cpp -I/drivers -o /floop/amg8833/amg8833 && \
    AMG8833_BUS=$BUS /floop/amg8833/amg8833

Make sure to change the value of BUS to match the bus to which your AMG8833 is connected. The value of BUS is the same as the integer that corresponds to the /dev/i2c-* entry for your device.

Now run the example:

floop run -v

If the example returns with no error, then the installation succeeded.

You can install the C++ header files for use in your own applications.

In order to use the drivers with Linux, you need to install some I2C dependencies:

sudo apt-get install -y python-smbus python-dev i2c-tools libi2c-dev

You need to install the AMG8833 and I2C headers, then include them during compilation of your application. Inside of your application folder, you can install both headers at the same time:

mkdir -p ./floop/i2c/ && \
mkdir -p ./floop/amg8833/ && \
wget -O ./floop/i2c/i2c.h https://github.com/ForwardLoopLLC/i2c/blob/master/i2c/i2c.h && \
wget -O ./floop/amg8833/amg8833.h https://github.com/ForwardLoopLLC/amg8833/blob/master/amg8833/amg8833.h

When you compile your application, make sure to include the path to the driver headers. For example, add -I./floop/ during compilation. You can then access the drivers by including the amg8833 header:

#include "amg8833/amg8833.h"

Note that you can also use these steps to install the drivers inside of a Docker container.

Example

The example shows the major functionality of the drivers.

#include "amg8833/amg8833.h" //drivers
#include <stdlib.h> // getenv

int main() {
    AMG8833 amg8833(getenv("AMG8833_BUS")[0] - '0');
    if (amg8833.error()) {
        printf("Error: AMG8833 did not initialize\n");
        return 1;
    }
    // reset all registers and settings 
    if(!amg8833.resetInitial()) {
        printf("Error: failed to reset registers\n");
    }
    // turn off moving average mode
    if(!amg8833.setNormalMode()) {
        printf("Error: failed to set normal mode\n");
    }
    // disable interrupt, so the sensor reads the temperature values
    // (instead of triggering an interrupt if the temperature fails below
    // or above a certain threshold)
    if(!amg8833.disableInterrupt()) {
        printf("Error: failed to disable interrupt\n");
    }
    // the sensor will sample ten times per second
    if(!amg8833.setFrameRate10Hz()) {
        printf("Error: failed to set frame rate\n");
    }

    printf("AMG8833 initialized\n");

    // Thermistor (sensor board) temperature
    printf("Thermistor temperature: %f\n", amg8833.thermistorTemperature());

    // Grid temperature for all pixels
    double grid[64];
    printf("Grid Temperature\n");
    amg8833.gridTemperature(grid);
    for (int row = 0; row < 8; row++) {
        for (int col = 0; col < 8; col++) {
            printf("%2.6f ", grid[row*col + col]);
        }
        printf("\n");
    }
    printf("AMG8833 installation succeeded.\n");
    return 0;
}

API Documentation

C++ API
Driver interface for AMG8833
Source Code
Our MIT license lets you use, change, and sell the drivers for free
Forward Loop Docs
Check out other drivers, develop tools, and code