Skip to content
deftioPublic

Firebrat logo Firebrat

An open-source thermal camera you can build in an afternoon. An MLX90640 heat sensor plus a LilyGO T-Display-S3 (or any ESP32-S3). Watch the heat map on its screen, or in a browser over WiFi, USB or Bluetooth.

Version License CI Platform

Website · Live camera · WiFi setup · Docs · Quick start

A hand seen by Firebrat: fingers at about 36 °C against a 25 °C room, iron palette, bicubic, with the colour scale and max / min readouts

What you get

On the device A live false-colour heat map on the 320×170 LCD, with max / center / min temperatures, a colour scale and a crosshair.
In a browser, over WiFi The camera serves its own web app. Open its address on any phone or laptop; several can watch at once, all in sync.
In a browser, over USB or Bluetooth No WiFi needed: open the live camera page in Chrome or Edge and connect over a USB cable or over Bluetooth.

Plus: five palettes, nearest / bilinear / bicubic interpolation, live-tunable denoising (chess-pattern fix, temporal filter, median), auto or held range, true full frames at up to 16 per second, snapshots (PNG, CSV) and recordings (video, raw data), from the browser or the command line. WiFi is set up from the USB console or from your phone over Bluetooth. The screen is optional, and the firmware also runs on screenless ESP32-S3 boards.

The UI is built with bitwrench.js. The name comes from the firebrat, a small insect that loves the heat.

Quick start

  1. Connect an MLX90640 breakout to either 4-pin connector on a LilyGO T-Display-S3.
  2. Flash with PlatformIO:
    git clone https://github.com/deftio/firebrat
    cd firebrat
    pio run -e t-display-s3 -t upload
    The heat map appears on the screen straight away. No PlatformIO? Each release has two images. On a new board, flash -full.bin at 0x0. To upgrade, flash -upgrade.bin at 0x10000, which keeps your WiFi and settings (the full image erases them).
  3. Join WiFi. Type wifi "My Network" "my password" in the console (pio device monitor), or use the WiFi setup page on your phone.
  4. Open the address shown on the screen, or http://firebrat.local/.

Hardware

Part Notes
LilyGO T-Display-S3 ESP32-S3R8, 16 MB flash, 8 MB PSRAM, 1.9" 170×320 LCD. Any ESP32-S3 with 4 MB+ flash works for a build without a screen.
MLX90640 breakout 3.3 V, I2C address 0x33 (Adafruit, Pimoroni, SparkFun...). Choose 55° (BAA) for general use, or 110° (BAB) for wide scenes.
JST-SH 4-pin cable Qwiic / STEMMA QT style, or four jumper wires: 3V3, GND, SDA, SCL.
USB-C cable Power, flashing, the console and the USB view.

Wiring. There's no configuration to do. At boot, Firebrat looks for the sensor on these SDA/SCL pins and uses whichever answers:

SDA / SCL Where
18 / 17 (and 17 / 18) T-Display-S3 I2C connector
43 / 44 (and 44 / 43) T-Display-S3 second connector
8 / 9 Arduino's default Wire pins on generic ESP32-S3 boards

status shows the pins it found. To force others, type i2c <sda> <scl>; they are saved, and the board reboots.

Builds

Build Command Use it for
t-display-s3 (default) pio run -e t-display-s3 -t upload T-Display-S3 with its screen
t-display-s3-headless pio run -e t-display-s3-headless -t upload T-Display-S3, screen off: web and USB only
esp32s3-headless pio run -e esp32s3-headless -t upload Any ESP32-S3 board; no PSRAM needed

The web app is compiled into the firmware, so there is no filesystem image to upload. Headless builds use the board's native USB port for the console.

Watching

On the screen

Button Short press Long press (1.5 s)
BOOT (GPIO 0) Next palette Next interpolation mode
KEY (GPIO 14) Auto range / hold the current range Open Bluetooth WiFi setup for 5 minutes

The side panel shows max, center and min temperatures, the colour range, the frame rate, the interpolation mode, and the WiFi address (or the Bluetooth name while setup is open).

In a browser over WiFi

The Firebrat web app in dark mode: live thermal image, max / center / min, palette, interpolation, frame rate and image-quality controls

Open the address on the screen, or http://firebrat.local/. mDNS works on macOS, iOS, Linux and Windows 10+, but often not on Android. Every change made in one browser, or with the buttons, shows up everywhere straight away. The page starts in dark mode; the ◐ button switches to light, and the browser remembers your choice.

In a browser over USB or Bluetooth

Open deftio.github.io/firebrat/camera.html in Chrome or Edge. You get the same app as over WiFi, carried another way:

Rate Notes
Connect over USB (Web Serial) 16 fps Desktop Chrome or Edge. Close any serial monitor first: only one program can use the port.
Connect over Bluetooth (Web Bluetooth) up to about 15 fps Chrome or Edge on desktop or Android; Bluefy on iOS. Frames are sent in a compact 8-bit form (about 1 KB each); the rate depends on your phone or computer's Bluetooth.

The camera is always discoverable over Bluetooth for viewing. WiFi credentials can only be changed during the setup window (see below).

WiFi setup

From the console:

wifi "My Network" "my password"
status

From your phone, over Bluetooth: open deftio.github.io/firebrat/setup.html. It works in Chrome or Edge on desktop or Android; on iOS, use the Bluefy browser. Connect to Firebrat-XXXX, scan, pick a network and enter the password. The page then shows the camera's address.

For safety, the camera only accepts WiFi credentials over Bluetooth for 5 minutes after power-up, while WiFi is down or not set, or for 5 minutes after a long press on KEY (or ble on). Viewing over Bluetooth works at any time. The password can be written but never read back.

Image settings

All of these can be set from the web app, the console or the buttons. They are saved in flash.

Setting Options Notes
Palette iron, rainbow, gray, hot, arctic Iron is the default.
Interpolation nearest, bilinear, bicubic How 32×24 is scaled up: 7× on the LCD, 10× in the browser. Nearest shows the real pixels; bicubic (Catmull-Rom) looks smoothest.
Denoise on (auto-tuned), off Temporal filter: averages still parts of the scene, shows changes bigger than the motion threshold at once. Auto-tune picks blend and threshold for the frame rate; the Blend and Motion sliders override them.
Chess fix on, off Removes the offset between the two half-frames the sensor reads (a checkerboard that flips every frame).
Median off, cross, 3×3 Spatial median on the 32×24 image. Cross (5-point) keeps 1-pixel details; 3×3 is smoother. Max, min and center are taken before the median, so a small hot spot still counts.
Range auto, held Auto follows the scene but is anchored to real temperature (half the scene's own range, half a fixed 15–42 °C scale), so cold things look dark and hot things bright. It ignores a few noisy pixels and glides rather than jumps. Held keeps the current range, for comparing scenes.
Frame rate 2, 4, 8, 16 fps Always complete frames: the screen and browsers update only when both halves of a frame are in. 8 and 16 fps use 1 MHz I2C. Lower rates are less noisy (with denoise: about 0.27 °C frame-to-frame at 16 fps, 0.18 °C at 8).
Flip horizontal, vertical To match how you mount the sensor.

Interpolation only changes the picture. Readouts, hover temperatures and CSV exports use the 32×24 values.

Tuning live. The web app's Image quality card has the denoise switches, the Blend and Motion sliders, the median buttons, and live Change/frame and Speckle figures, so you can see each setting's effect. Measured on a still scene at 16 fps:

Speckle Frame-to-frame
All filters off 0.87 °C 0.87 °C
Chess fix + temporal (auto) 0.39 °C 0.25 °C
+ median cross (default) 0.16 °C 0.16 °C
+ median 3×3 instead 0.10 °C 0.14 °C

Snapshots and recordings

In the web app (WiFi, USB or Bluetooth), the buttons under the image:

Button Saves
Snapshot PNG of the image with its colour scale, range, max / min, palette, interpolation and time
CSV The 32×24 temperatures (°C) of the current frame
● Record video WebM video of that composed view (MP4 in Safari); press again to stop and save
● Record data Every frame's raw temperatures as JSON (firebrat-frames format); press again to stop and save

From the command line, with the camera on USB (tools/firebrat.py; needs pyserial, which PlatformIO ships):

python3 tools/firebrat.py snap                          # firebrat-<time>.png + .json (all values and settings)
python3 tools/firebrat.py snap -o hand.png --csv hand.csv --palette rainbow --interp nearest
python3 tools/firebrat.py record --seconds 10           # firebrat-<time>.json, every frame (16 fps over USB)
python3 tools/firebrat.py record --seconds 5 --png-dir frames/
python3 tools/firebrat.py render rec.json --png-dir frames/   # PNGs from any recording, web or CLI
python3 tools/firebrat.py cmd "rate 8"                  # any console command

The PNGs are rendered on the computer with the camera's own palettes and interpolation, so they match the screen. At the device console, snap prints one SNAP:{json} line with the frame and its settings; snap csv prints the grid.

Recordings from the web app and from firebrat.py share one JSON format:

{"format": "firebrat-frames", "version": 1, "w": 32, "h": 24, "fps": 15.9,
 "frames": [{"ms": 0, "lo": 23.1, "hi": 29.6, "px": "<base64 int16 centi-degrees C, little-endian>"}, ...]}

Frames recorded over Bluetooth carry q/qlo/qhi (8-bit steps between qlo and qhi) instead of px.

Console

The console is xelp, with line editing, history (up/down arrows) and help. It runs twice, with the same commands:

Where How to connect
USB Any serial terminal at 115200 baud (pio device monitor, screen, the Arduino IDE)
Bluetooth Any BLE terminal app that speaks the Nordic UART Service (nRF Connect, Serial Bluetooth Terminal, Bluefruit Connect); pick Firebrat-XXXX

Over Bluetooth, commands that could lock you out (wifi changes, name, i2c pins, ble, reboot) only work while the setup window is open. Separate commands with ; to run several at once: rate 8; median 3x3; palette hot.

status                      WiFi, web, BLE and sensor state
wifi <ssid> [password]      save WiFi and connect (quote names with spaces)
wifi scan | wifi forget
name <hostname>             mDNS name (default firebrat -> http://firebrat.local/)
palette [name]              iron | rainbow | gray | hot | arctic
interp [name]               nearest | bilinear | bicubic
denoise on | off | auto      temporal filter; auto = tuned per frame rate
blend <0.05-1>              denoise: weight of each new frame (manual)
motion <C>                  denoise: changes above this show at once (manual)
chess on | off
median off | cross | 3x3
rate [fps]                  1 | 2 | 4 | 8 | 16
range auto | range <lo> <hi>
flip h | flip v
snap [csv]                  one snapshot: SNAP:{json} line (or the CSV grid)
frame                       print the current 32x24 frame as CSV (degrees C)
ui                          print the UI messages a browser receives
i2c scan | i2c <sda> <scl>
ble on | ble off            open or close the Bluetooth setup window
stream on | off             send the web app over USB (used by the USB camera page)
reboot

How it works

The camera never sends HTML. Its web app is built with bitwrench.js using the bwserve protocol:

  1. The page in flash is a small bootstrap: it loads bitwrench.js (also from flash) and connects.
  2. The firmware mounts the whole interface in one JSON message, composed in C++ with bitwrench.h.
  3. Each thermal frame is one more message: a call that hands the frame to the page's painter, plus patches for the readouts.
  4. Buttons post their action names back. The camera applies them and updates every viewer, and the LCD.
{v:1, type:'batch', ops:[
  {v:1, type:'call',  name:'thermal', args:[{w:32, h:24, pal:'iron', interp:'bicubic', lo:22.1, hi:30.3, px:'<base64>'}]},
  {v:1, type:'patch', ref:'fb-max', text:'30.3'},
  {v:1, type:'patch', ref:'fb-min', text:'22.2'}
]}

The same messages travel over three transports:

Camera side Browser side
WiFi Server-Sent Events on GET /bw/events; actions arrive by POST /bw/events bw.connect('/bw/events')
USB stream on sends lines prefixed UI:; actions arrive as act <json> Web Serial + bw.apply()
Bluetooth stream on written to the UI command characteristic; lines arrive as notifications (compact frames) Web Bluetooth + bw.apply()

Other endpoints: GET /api/frame returns the current frame as JSON in °C, and GET /api/status returns device status.

The website's How it works page goes through every connection in depth: first-time setup and the Bluetooth setup window, the web app, the USB console and live view, the three Bluetooth services, the protocol, settings and security.

Project layout

src/        firmware: thermal (sensor + denoise), display (LCD), net (WiFi, web, UI), ble, cli, settings
web/        index.html: the camera's bootstrap page (served from flash)
docs/       the website (GitHub Pages), no build step: HTML pages, site.js, thermal.js (the frame painter,
            also embedded in the firmware), images, vendored bitwrench.js
lib/        vendored: bitwrench embedded headers, Adafruit MLX90640
tools/      firebrat.py (host CLI), embed_web.py, version.py, make_lcd_logo.py, deps_snapshot.py,
            render_images.js, mock_device.js, fixtures/
case/       printable case (OpenSCAD, parametric; draft, not yet printed)
VERSION     the only place the version is set (`make version` writes the copies)
test/       native C++ unit tests (Unity)
tests/      js/ (node:test), py/ (unittest), hw/ (a camera on USB)

Tests

make test        # host tests, no hardware: C++ (native), JavaScript, Python
make test-hw     # a real camera on USB
make build       # all three firmware targets
Suite What it checks
C++, pio test -e native (Unity) The imaging core (src/imaging.cpp): palettes, upscaling taps, nearest / bilinear / bicubic, chess fix, temporal filter, median, base64, full and compact frame encoding
JavaScript, node --test (no npm packages) The browser painter; every message in a real device capture parses with bitwrench, every UI it mounts passes bitwrench-verify (wire mode), and every button has a handler; every website page (SEO tags, links, assets, sitemap, manifest); and consistency across C++, JS, Python and docs (palettes, names, Bluetooth UUIDs, element ids, version)
Python, unittest tools/firebrat.py: rendering, PNG output, frame decoding, the recording format
Hardware, make test-hw The console, the sensor (no read errors), snapshots, 16 fps over USB with no skipped frames, button actions; over Bluetooth (with pip install bleak): the setup status and that a WiFi change outside the setup window is refused, not ignored. Never sends credentials or forget

CI runs only the host tests (make test), on pushes to main and on pull requests. Run make build locally before a release.

Development

Task Command
Work on the website Edit docs/*.html (no build step); preview with python3 -m http.server in docs/. The site's Docs page renders this README with quikdown.js, so keep its headings stable (they are anchor links)
Re-render website images node tools/render_images.js (needs Playwright)
Snapshots, recordings, commands from a computer python3 tools/firebrat.py --help
Run the web app without hardware node tools/mock_device.js tools/fixtures/ui-capture.txt, then open http://localhost:8080/
See what a browser receives ui at the console

To publish the website, go to Settings → Pages → Deploy from a branch → main / /docs. Then submit https://deftio.github.io/firebrat/sitemap.xml in Google Search Console.

Working with an AI coding agent? See AGENTS.md. For a one-page summary for LLMs, see llms.txt.

Troubleshooting

Problem Fix
"MLX90640 not found" Check 3V3 and GND, then run i2c scan; the sensor answers at 0x33. Set the pins with i2c <sda> <scl>.
Speckled or noisy image Check the Image quality card: denoise auto, chess fix on, median cross or 3×3. Try 8 fps rather than 16, and give the scene some contrast; a flat room is mostly noise.
firebrat.local will not open Use the IP address on the screen or from status; Android often lacks mDNS.
The setup page cannot find the camera The setup window has closed: long-press KEY, or type ble on.
The USB camera page cannot open the port Close the serial monitor or any other program using it.
The image is mirrored Run flip h / flip v, or use the Flip buttons.

Contributing

Bug reports, hardware reports and pull requests are welcome: see CONTRIBUTING.md and the Code of Conduct. Security issues go through SECURITY.md, not public issues. What the camera and the website do with your data: PRIVACY.md (in short, nothing leaves your network).

Version and licence

Version 0.1.5. Changes are listed in CHANGELOG.md.

Firebrat is © 2026 M. A. Chatterjee (deftio), released under the BSD-2-Clause licence. Vendored code keeps its own licence:

Component Licence Where
bitwrench 2.1.16 (embedded headers, browser build; bitwrench-verify for tests) BSD-2-Clause lib/bitwrench/, docs/vendor/, tests/js/vendor/
quikdown 1.3.3 BSD-2-Clause docs/vendor/
Adafruit MLX90640 1.1.1, with the Melexis driver BSD; Apache-2.0 (Melexis) lib/Adafruit_MLX90640/

Libraries fetched at build time (pinned in platformio.ini): xelp 0.3.5 (BSD-2-Clause), LovyanGFX 1.2.7 (MIT and BSD-2-Clause), ESPAsyncWebServer and AsyncTCP (LGPL-3.0). If you distribute compiled firmware, the LGPL-3.0 terms of the last two apply to that binary.

Releases

Packages

Used by

Contributors

Languages