ESP8266 Thermal Imaging Sensor Project

This project demonstrates how to interface an ESP8266 microcontroller with a thermal imaging sensor module using I2C communication to measure and display temperature readings. Thermal imaging sensors are used to detect and visualize temperature distributions across surfaces, making them suitable for various applications in industrial, medical, and environmental monitoring fields.

How It Works

A thermal imaging sensor is an array of infrared thermopiles rather than a single detector. The AMG8833 Grid-EYE carries an 8×8 grid — 64 pixels — each measuring the long-wave infrared radiated by whatever is in its field of view. Everything above absolute zero emits such radiation, and its intensity rises with temperature, so each pixel reports a temperature without touching anything.

Sixty-four pixels sounds trivially small, and as an image it is. But it is enough to tell a person from a radiator, to locate the warmest point in a scene, and to track movement — which is what most projects actually need. The AMG8833 covers 0–80 °C with roughly ±2.5 °C accuracy at about 10 frames per second.

The MLX90640 is the step up, at 32×24 pixels — 768 in total — with a wider temperature range. It costs considerably more and needs more RAM to hold a frame, which matters on a board with roughly 80 KB usable of SRAM.

Both communicate over I²C, on D2 (SDA, GPIO4) and D1 (SCL, GPIO5) by default for this board. Thermopiles respond to emitted infrared, so they see through darkness and smoke but not through glass, which is opaque at these wavelengths.

Components Needed

  • ESP8266 (NodeMCU)
  • Thermal Imaging Sensor Module
  • Jumper Wires
  • ESP8266 (NodeMCU)

Wiring to the ESP8266 (NodeMCU)

Connect SDA and SCL to D2 (SDA, GPIO4) and D1 (SCL, GPIO5) by default, VIN to the 3.3 V rail and GND to ground. The AMG8833 die runs at 3.3 V but Adafruit-style breakouts include a regulator and level shifting, so either supply works on those boards.

The default I²C address is 0x69, with 0x68 selectable by tying the AD_SELECT pin. If a scanner finds nothing, check that address first.

This board's roughly 80 KB usable of SRAM comfortably holds a Grid-EYE frame and leaves room for processing.

Module pinESP8266 (NodeMCU) pinFunction
SDAD2 (SDA, GPIO4)I²C data
SCLD1 (SCL, GPIO5) by defaultI²C clock
VIN3V3Supply (board has a regulator)
GNDGNDCommon ground

Example Code

Reading the 8×8 thermal grid and locating the hottest pixel. Upload it with the board set to ESP8266 (NodeMCU) and open the Serial Monitor at 115200 baud.

Reading the 8×8 thermal grid and locating the hottest pixel
#include <Wire.h>
#include <Adafruit_AMG88xx.h>

Adafruit_AMG88xx amg;
float pixels[AMG88xx_PIXEL_ARRAY_SIZE];   // 64 values

void setup() {
  Serial.begin(115200);
  Wire.begin();

  if (!amg.begin(0x69)) {                 // try 0x68 if this fails
    Serial.println("AMG8833 not found — check wiring and address");
    while (1) delay(1000);
  }
  delay(100);
}

void loop() {
  amg.readPixels(pixels);

  float hottest = -100, coldest = 500;
  int hotIndex = 0;

  for (int i = 0; i < AMG88xx_PIXEL_ARRAY_SIZE; i++) {
    if (pixels[i] > hottest) { hottest = pixels[i]; hotIndex = i; }
    if (pixels[i] < coldest) coldest = pixels[i];
  }

  Serial.print("hottest ");
  Serial.print(hottest, 1);
  Serial.print(" C at row ");
  Serial.print(hotIndex / 8);
  Serial.print(", col ");
  Serial.print(hotIndex % 8);
  Serial.print("   coldest ");
  Serial.print(coldest, 1);
  Serial.println(" C");

  delay(500);
}

Applications

A thermal imaging sensor turns up in a wide range of projects. These are the uses where it is the right choice rather than a compromise:

  • Presence and occupancy detection that works in complete darkness
  • Finding overheating components, bearings and electrical joints
  • People counting that preserves privacy, since 64 pixels identify nobody
  • Fire and hotspot detection in workshops and storage areas
  • Thermal insulation and draught surveys in buildings

Working with the ESP8266 (NodeMCU)

The ESP8266 (NodeMCU) is built around the ESP8266 and runs on 3.3 V logic with roughly 80 KB usable of SRAM and 4 MB on most NodeMCU boards of program flash. These details change how this circuit is wired and what the sketch can do, so they are worth stating plainly before you build.

The ESP8266 is a 3.3 V part and is not 5 V tolerant — feeding a 5 V sensor output straight into a GPIO can damage the chip. Use a divider or level shifter.

There is only one ADC channel, so reading several analog sensors needs an external multiplexer such as a CD4051 or an ADS1115.

D3 (GPIO0), D4 (GPIO2) and D8 (GPIO15) are strapping pins sampled at boot; holding them at the wrong level stops the board starting.

Built-in WiFi means the same sketch can publish readings to a dashboard without extra hardware.

ESP8266 (NodeMCU) characteristicValueWhy it matters here
Logic voltage3.3 VSensor outputs above this level need a divider or level shifter
ADC resolution10-bit (0–1023)Sets how finely an analog reading can be resolved
Analog inputsa single analog channel, A0Determines how many analog sensors can share the board
PWM outputsany GPIO via software PWMNeeded for brightness, speed and tone control
I²C pinsD2 (SDA, GPIO4) and D1 (SCL, GPIO5) by defaultFixed by hardware — wiring copied from another board may not match
Interrupt pinsany GPIO except D0 (GPIO16)Required for counting fast or asynchronous events
Serialone hardware UART plus a transmit-only second portMonitor runs at 115200 baud by default

Troubleshooting

Most problems with this module fall into a handful of categories. Work through these before suspecting the part itself:

  • The sensor is not detected — the address is 0x69 by default, not the 0x68 many examples assume.
  • Everything reads roughly the same temperature — the field of view is filled by one surface. Point it at a scene with real contrast.
  • A person behind glass is invisible — glass blocks long-wave infrared. This is physical, not fixable in software.
  • Readings are noisy frame to frame — average two or three frames; thermopiles are inherently noisy at this price point.
  • The sketch fails to compile on a board with little RAM — the float array is too large; use a board with more SRAM.
  • The sketch compiles but the board resets or behaves erratically — a 5 V module output is being driven into a 3.3 V pin. Measure the signal before connecting it.
  • Readings differ from an Arduino tutorial for the same part — the 10-bit ADC returns 0–1023, not 0–1023, so any constant copied from an Uno example needs rescaling.

Taking It Further on the ESP8266 (NodeMCU)

Once the basic reading works, where you go next depends very much on which board you are using. These are the directions that suit the ESP8266 (NodeMCU) specifically:

The obvious extension on an ESP8266 is to stop printing to Serial and publish instead. A few lines using ESP8266WiFi and an HTTP client will push each reading to a dashboard such as ThingSpeak, or to an MQTT broker for home automation.

Running an onboard web server turns the board into its own display: serve a small HTML page that fetches the latest reading over AJAX, and any phone on the network becomes the instrument panel.

For battery operation, deep sleep is essential — the ESP8266 draws around 70 mA with WiFi active but under 20 µA asleep. Wire D0 (GPIO16) to RST so the board can wake itself, take a reading, publish and sleep again.

Notes and Practical Limits

Interpolating 8×8 up to a smooth image is cosmetic. It looks better on a display but adds no information, and a hot pixel in the raw grid is more trustworthy than a smoothed blob.

Absolute accuracy of ±2.5 °C makes these parts unsuitable for medical temperature screening, whatever product listings claim. They are reliable for relative comparisons — which of these things is hottest — and that covers most genuine uses.