Accurate Raspberry Pi Temperature Profiling with Python, SQLite, and LabVIEW
On my Raspberry Pi, I mounted a DS18B20 sensor just above the processor to capture the board’s internal temperature. My goal was to map this profile inside the enclosure and present it in a clear visual format. I achieved this by integrating a lightweight Python script, an SQLite3 database, and LabVIEW.
Because the Pi itself runs relatively cool and I only have a single sensor, the resulting temperature variations are subtle—an exaggeration in the accompanying image. Nonetheless, the methodology scales to any setup.
I began by writing a Python routine that runs continuously on the Pi. It reads the DS18B20 value and writes the timestamped temperature into an SQLite3 database located on a shared folder mounted from a USB flash drive. The same database also stores accelerometer data (to be added later).
On the host side, a LabVIEW application queries the remote SQLite3 database to retrieve the most recent temperature reading. I use the simple SQLite Toolkit for LabVIEW, which streamlines the connection and query process. Initially, the query returns the entire dataset; in future iterations I’ll refine it to pull only the last entry.
For visualization, I employ Sensor Mapping Express VI. The workflow is straightforward: point the VI to a .stl model of the Pi, designate the sensor locations, and feed in the temperature array. I converted a high‑resolution 3‑D model of the board using Google SketchUp, then added four dummy sensor nodes to illustrate temperature gradients. The external four sensors are held at a fixed 0 °C, while the central sensor pulls live data from the database. With additional sensors, the map becomes increasingly accurate.
The application refreshes every 100 ms: it queries the database, constructs an array of temperature values, and updates the Sensor Mapping Express VI. The result is a dynamic surface plot that changes in real time to reflect the Pi’s internal temperature.
Temperature‑to‑Colour Mapping:
- 0 °C – R0 G0 B255
- 21.25 °C – R0 G255 B255
- 42.5 °C – R0 G255 B60
- 63.75 °C – R255 G255 B85
- 85 °C – R255 G0 B0
In addition to temperature, I’ve connected an ADXL345 accelerometer to capture tilt and pitch data. The next phase will link this motion data to the 3‑D model in LabVIEW, allowing the virtual representation to mirror the physical Raspberry Pi’s orientation.
For a deeper dive into the code, database schema, and LabVIEW configuration, see the full article on Raspberry Pi temperature profiling using LabVIEW.
Manufacturing process
- Build a Raspberry Pi Temperature Logger with a $5 I2C Sensor
- How to Read Temperature with a DS18B20 on Raspberry Pi 2
- Professional Raspberry Pi Temperature Monitoring with DS18B20
- TMP006 Infrared Temperature Sensor with Raspberry Pi: Python Library & Setup Guide
- Build a Remote Temperature Sensor with Raspberry Pi and Python – Step‑by‑Step Guide
- Accurate Temperature Monitoring in a Server Closet with Raspberry Pi
- Control an LED with a PIR Motion Sensor on Raspberry Pi
- Monitor Your Home Temperature with a Raspberry Pi Dashboard
- Build a Raspberry Pi Home Temperature Monitor with MCP9808, InfluxDB & Grafana
- Using an MCP3008 ADC to Read Analog Sensors with Raspberry Pi