The AMG8833 is a small 8x8 grid of thermopile sensors. The grid gives back values on the IR radiation readings for each point on the grid. Using this I’ve created a primitive thermal camera.
For this project I used the LEDMatrix Block and the Breadboard Block.
Configuring the Breadboard Block
To configure the breadboard block to connect to the AMG8833 sensor the pins are set up as below:
|IO3 -GND||IO2 - Vcc||IO1 -I2cSDA||IO0 - I2cSCL|
Now that the pins are configured we can connect the sensor to the corresponding pins on the Breadboard block.
onReload + setting up constants
First the constants were set up for the IR array sensor. The onReload function was used to call the functions that would initialise the AMG8833 sensor, read the data and check the received data before updating the LED matrix.
The IR sensor was initialised up as per the datasheet.
The AMG8833 has an upper and lower byte for each coordinate in the 8*8 array. The format of the two bytes are shown below from the datasheet.
Each of these sets of array values can be read from the sensor by sending the address of the point and then requesting to read from the I2C address. Once given an initial address to start the master can continue to request data which will pull the information out of the following address.
The first address of the IR matrix is 0x80, so that value is sent to initialise the position that we are trying to read from. From there we can continue to read in order of the addresses. The only issue is that the Hardware API i2c_request only allows for 127 bytes to be read at one time. Since there are 64 points in the 8*8 IR matrix and each has a high and low value it equates to 128 bytes needing to be read. Due to this limitation the readings were split into two loops.
On the first pass we read the first half of the data using the address 0x80 as the starting address and on the second pass we use the address 0xC2 since it is the starting address of the second half of the array values.
Before the temperature data can be saved to an array it must first be converted to the correct form. Firstly the data is separated over two bytes. So the upper byte is shifted and combined with the lower byte. Since the number is in two’s complement form it is fed into the sign() function which will return the value as a positive or negative integer. After this point, the conversion factor is applied to convert the sensor reading to a temperature.
Once the reading has been converted to the correct format it is saved into an array. This loops over the whole 128 values and the array is returned by the function.
Converts the two's complement 16 bit value returned from the IR array into a positive or negative value.
This function sorts through the temperature array given from the IR sensor and adds a LED to an array when the temperature is above a threshold value. The corresponding LEDs are then turned on to represent the hot spots.
The LED matrix only allows for two states, either ON or OFF, which limits the representation of the sensor readings. Using an RGB LED matrix the temperature readings could be mapped to different colours, which could show hot and cold spots.