Arduino uno Temperature sensor module LM35 LM75
This project utilizes the MLX90640 thermal imaging sensor to capture temperature data from its field of view. The Arduino Uno communicates with the MLX90640 sensor over I2C to receive temperature readings, which are then printed to the serial monitor.
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 2 KB of SRAM.
Both communicate over I²C, on A4 (SDA) and A5 (SCL) 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
- Arduino Uno
- Thermal Imaging Sensor module
- Arduino Uno
- USB cable for programming and power
- Arduino Uno
Wiring to the Arduino Uno
Connect SDA and SCL to A4 (SDA) and A5 (SCL), VIN to the 5 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.
With only 2 KB of SRAM, a 64-pixel float array consumes 256 bytes before anything else — workable, but an MLX90640 frame at 768 pixels will not fit. Use a board with more memory for the larger sensor.
| Module pin | Arduino Uno pin | Function |
|---|---|---|
| SDA | A4 | I²C data |
| SCL | A5 | I²C clock |
| VIN | 5V | Supply (board has a regulator) |
| GND | GND | Common ground |
Example Code
Reading the 8×8 thermal grid and locating the hottest pixel. Upload it with the board set to Arduino Uno and open the Serial Monitor at 9600 baud.
#include <Wire.h>
#include <Adafruit_AMG88xx.h>
Adafruit_AMG88xx amg;
float pixels[AMG88xx_PIXEL_ARRAY_SIZE]; // 64 values
void setup() {
Serial.begin(9600);
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 Arduino Uno
The Arduino Uno is built around the ATmega328P and runs on 5 V logic with 2 KB of SRAM and 32 KB 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 Uno runs at 5 V, so most hobby sensor modules connect directly with no level shifting.
With only 2 KB of SRAM, avoid large buffers and prefer the F() macro for constant strings.
The single hardware UART is shared with the USB connection, so heavy Serial printing competes with uploads.
| Arduino Uno characteristic | Value | Why it matters here |
|---|---|---|
| Logic voltage | 5 V | Matches most hobby modules directly |
| ADC resolution | 10-bit (0–1023) | Sets how finely an analog reading can be resolved |
| Analog inputs | A0–A5 (six channels) | Determines how many analog sensors can share the board |
| PWM outputs | D3, D5, D6, D9, D10 and D11 | Needed for brightness, speed and tone control |
| I²C pins | A4 (SDA) and A5 (SCL) | Fixed by hardware — wiring copied from another board may not match |
| Interrupt pins | D2 and D3 only | Required for counting fast or asynchronous events |
| Serial | a single hardware UART shared with USB | Monitor runs at 9600 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.
- Code written for an ESP board gives odd analog values — the Arduino Uno uses a 10-bit ADC returning 0–1023; rescale any constant taken from a 12-bit example.
- An I²C sensor is not found after copying wiring from another Arduino — on the Arduino Uno I²C is on A4 (SDA) and A5 (SCL).
Taking It Further on the Arduino Uno
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 Arduino Uno specifically:
The Uno’s shield ecosystem is its real advantage. Once the circuit works on a breadboard, a prototyping shield turns it into something permanent that still stacks with a data-logging or Ethernet shield without rewiring.
Logging to an SD card via a shield is the natural next step, since the Uno has no onboard storage and no network. Timestamp each reading with a DS3231 real-time clock so the log survives power cuts with correct times.
Because SRAM is limited to 2 KB, keep logged strings short and write them out immediately rather than buffering. Building a long String in memory is the most common cause of an Uno sketch that runs for hours and then freezes.
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.