{"id":13801834,"url":"https://github.com/peterhinch/micropython-amg88xx","last_synced_at":"2025-06-10T20:36:00.863Z","repository":{"id":37359047,"uuid":"187793852","full_name":"peterhinch/micropython-amg88xx","owner":"peterhinch","description":"Driver for Grid-EYE thermal infra red array sensor (Adafruit 3538)","archived":false,"fork":false,"pushed_at":"2020-06-17T08:05:28.000Z","size":505,"stargazers_count":21,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T15:33:24.676Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peterhinch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-21T08:23:20.000Z","updated_at":"2024-12-19T06:12:21.000Z","dependencies_parsed_at":"2022-09-06T15:40:57.980Z","dependency_job_id":null,"html_url":"https://github.com/peterhinch/micropython-amg88xx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython-amg88xx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython-amg88xx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython-amg88xx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython-amg88xx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peterhinch","download_url":"https://codeload.github.com/peterhinch/micropython-amg88xx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython-amg88xx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259146877,"owners_count":22812326,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:01:28.412Z","updated_at":"2025-06-10T20:36:00.814Z","avatar_url":"https://github.com/peterhinch.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"readme":"# micropython-amg88xx\nDriver for Grid-EYE 8x8 pixel thermal infra red array sensor (Adafruit 3538).\n\nNow provides optional bicubic interpolation for camera displays.\n\nThe driver is a port of the\n[Adafruit CircuitPython driver](https://github.com/adafruit/Adafruit_CircuitPython_AMG88xx)\nmodified for MicroPython.\n\nOriginal author(s): Dean Miller, Scott Shawcroft.  \nAdapted by Peter Hinch. Dependencies on Adafruit libraries removed, coding\nadapted to conform to MicroPython conventions. Extended to provide additional\nfunctionality.\n\nA typical camera build:  \n![Image](images/build.jpg)  \nInterpolated images (a cup of coffee):  \n![Image](images/coffee.jpg)  \nMy chair a while after I had got up:  \n![Image](images/chair.jpg)  \nA re-creation of the Adafruit [fingers](https://www.adafruit.com/product/3538)\ndemo. Note that their version uses numpy and scipy on a Raspberry Pi as against\nbicubic interpolation on a Pyboard.\n![Image](images/fingers.jpg)\n\nThe update rate with bicubic interpolation is just over 3Hz.\n\n# 1. Files\n\n * `amg88xx.py` The device driver.\n * `amg_test.py` Simple text based test program.\n\nFor thermal camera use:\n * `cam.py` Thermal camera demo for Adafruit 0.96 inch OLED display.\n * `cam_lcd.py` Thermal camera demo for official LCD160CR display.\n * `mapper.py` Provides a class to convert temperature values to rgb colors.\n Required for both demos.\n * `ssd1331.py` Driver for\n [Adafruit 0.96 OLED display](https://www.adafruit.com/product/684).\n\nThe Adafruit OLED display driver is from\n[this repo](https://github.com/peterhinch/micropython-nano-gui.git)\nwhich also has drivers for their larger displays based on the SSD1351 chip.\nThe repo has optional drivers supporting 16 bit color: these trade improved\ncolor against a larger frame buffer, and so are best suited to platforms\nwith plenty of RAM.\n\nThe driver for the official LCD160CR is included in Pyboard firmware. Source is\n[here](https://github.com/micropython/micropython/blob/master/drivers/display/lcd160cr.py).\n\nThe `my_cam` directory contains a complete set of files for my camera project.\n\n## 1.1 Interpolation\n\nIn camera applications the 8x8 matrix of the AMG8833 gives a \"blocky\" effect.\nThis can be reduced by using bicubic interpolation. Files and\n[doc](./interpolate/README.md) for this are in the `interpolate` directory.\n\n# 2. Wiring\n\nIf used with a Pyboard\n\n| pyboard | amg8833 |\n|:-------:|:-------:|\n| 3V3     | VIN     |\n| GND     | GND     |\n| SCL X9  | SCL     |\n| SDA X10 | SDA     |\n\n# 3. AMG88XX class\n\nThis maintains an internal `bytearray` object holding a single frame of raw\ndata from the sensor. It is populated by the `refresh` method. The contents may\nbe retrieved as integer temperatures in °C by means of array access syntax.\n\nConstructor:  \nThis takes the following arguments:\n * `i2c` An `I2C` instance created using the `machine` module.\n * `address=0x69` The default device address. If you solder the jumper on the\n back of the board labeled `Addr`, the address will change to 0x68.\n\nData access methods:\n * `refresh` Takes an optional arg which is ignored. This method causes the\n internal array to be updated with data from the sensor. On a Pyboard 1.x this\n method blocks for 2.9ms. This method does not allocate RAM and may be called\n by an interrupt service routine. The dummy arg facilitiates use as a timer\n callback (see commented out code in `cam.py`).\n * `__getitem__` Args `row`, `col`. Enables access to the data retrieved by\n `refresh`. Return value is a signed integer representing the temperature of\n that pixel in °C (or °C x 4 in high resolution mode).\n * `temperature` No args. Returns the device temperature in °C as a float.\n\nMode setting methods:\n * `hi_res=None` By default pixel temperatures are returned in °C. If `True` is\n passed, future readings will be in 0.25°C increments. This is the fundamental\n resolution of the chip, although its absolute accuracy is +-2.5°C. If `False`\n is passed, future readings will be in °C. By default no change is made. In all\n cases the method returns `True` if in high resolution mode.\n * `ma_mode=None` If `True` is passed the chip operates in moving average mode.\n This reduces noise at the expense of response speed. If `False` is passed,\n moving average mode is cancelled. By default no change is made. In all cases\n the current mode is returned.\n\nExample usage:  \nAfter issuing the `refresh` method, a set of pixel data may be read by means of\narray access.\n\n```python\nimport machine\nimport utime\nfrom amg88xx import AMG88XX\n\ni2c = machine.I2C(1)\nsensor = AMG88XX(i2c)\nwhile True:\n    utime.sleep(0.2)\n    sensor.refresh()\n    for row in range(8):\n        print()\n        for col in range(8):\n            print('{:4d}'.format(sensor[row, col]), end='')\n```\n\n# 4. Camera demo cam.py\n\nThis assumes a Pyboard linked to an\n[Adafruit 0.96 OLED display](https://www.adafruit.com/product/684). Wiring is\nas follows:\n\n| pyboard | OLED |\n|:-------:|:----:|\n| 3V3     | VCC  |\n| GND     | GND  |\n| X8 MOSI | SDA  |\n| X6 SCL  | SCL  |\n| X3      | RES  |\n| X2      | CS   |\n| X1      | DC   |\n\nThe sensor is wired as in [section 2](./README.md#2-wiring).\n\nOrientation of the display may be adjusted to match the physical layout of the\ndevices by setting the following program booleans:\n * `invert` Swap top and bottom.\n * `reflect` Swap left and right.\n * `transpose` Exchange row and column.\n\nThe limits of temperature display may be adjusted by assigning integer values\nto these program values:\n * `TMAX` Temperatures \u003e= `TMAX` appear red.\n * `TMIN` Temperatures \u003c= `TMIN` appear blue.\n\n# 5 Camera demo cam_lcd.py\n\nAs written this assumes a Pyboard 1.x with the LCD fitted in the 'Y' position\nand the sensor wired as in [section 2](./README.md#2-wiring).\n\nOrientation of the display may be adjusted to match the physical layout of the\ndevices by setting the following program booleans:\n * `invert` Swap top and bottom.\n * `reflect` Swap left and right.\n * `transpose` Exchange row and column.\n\nThe limits of temperature display may be adjusted by assigning integer values\nto these program values:\n * `TMAX` Temperatures \u003e= `TMAX` appear red.\n * `TMIN` Temperatures \u003c= `TMIN` appear blue.\n\n# 6. Mapper class for cameras\n\nThis simple class converts a temperature in °C to 8 bit rgb color values\ncompatible with most display drivers. Conversion uses a predefined mapping with\nblue for low temperatures through green to red, with constant overall\nbrightness. Out of range temperature values are clipped to the maximum or\nminimum as required. The range covered may be dynamically altered.\n\nConstructor  \nThis takes the following args:\n * `tmin` Minimum temperature to represent (°C).\n * `tmax` Maximum temperature to represent (°C).\n * `ncolors=30` Number of color gradations.\n\nMethods:\n * `set_range(tmin, tmax)` Allows the temperature range to be altered\n dynamically.\n * `__call__(t)` Function call syntax takes a temperature in °C and returns\n `(r, g, b)`. Red, green and blue values are in range 0..255.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterhinch%2Fmicropython-amg88xx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterhinch%2Fmicropython-amg88xx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterhinch%2Fmicropython-amg88xx/lists"}