Build a Raspberry Pi Temperature Logger with a $5 I2C Sensor
Follow these concise steps to turn a $5 I2C temperature sensor into a reliable data logger on a Raspberry Pi. The recorded values are written to the SD card, making them ready for Excel or any data‑analysis tool.
Components
- Raspberry Pi (any model with GPIO)
- SF‑SEN‑09418 I2C temperature sensor ($5)
- Solderless breadboard
- Hook‑up wires (male‑to‑female or female‑to‑female as needed)
Note: The Zagros Raspberry Pi starter kit contains everything except the sensor.
Step 1: Wire the Temperature Sensor
Connect the sensor to the Pi’s GPIO pins as shown. The ADD0 pin set to GND gives the sensor a unique I2C address (0x48). More than one sensor can share the bus as long as each has a distinct address.
| Sensor Pin | RPi GPIO |
|---|---|
| VCC | 3.3 V |
| SDA | SDA (GPIO 2) |
| SCL | SCL (GPIO 3) |
| GND | GND |
| ADD0 | GND (sets I2C address) |
| ALT | N/C |
Safety note: Do not power the sensor with +5 V; this will permanently damage it.
Step 2: Enable the I2C Bus
By default the Pi disables the I2C interface. Edit the blacklist file:
sudo nano /etc/modprobe.d/raspi-blacklist.conf
Change the content from:
# blacklist spi and i2c by default (many users don’t need them)
blacklist spi-bcm2708
blacklist i2c-bcm2708
to:
# blacklist spi and i2c by default (many users don’t need them)
blacklist spi-bcm2708
#blacklist i2c-bcm2708
Step 3: Load the I2C Module at Boot
Add the module to /etc/modules so it loads automatically:
sudo nano /etc/modules
Append the line:
i2c-dev
Step 4: Install I2C Utilities
Install the necessary tools and Python bindings:
sudo apt update && sudo apt install -y i2c-tools python3-smbus
Verify the sensor appears on the bus:
i2cdetect -y 1 – you should see a device at address 0x48.
With the I2C stack ready, you can now run a Python script (not included here) that reads the temperature and appends it to a CSV file on the SD card. The CSV can be opened directly in Excel for analysis.
Manufacturing process
- DS18B20 Temperature Sensor – Precise 1‑Wire Digital Thermometer for Industrial & Consumer Use
- 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
- How to Connect a DS1820 One‑Wire Temperature Sensor to a Raspberry Pi Using GPIO
- How to Connect a DS18B20 One‑Wire Digital Thermometer to a Raspberry Pi – A Step‑by‑Step Guide
- Build a Multi‑Sensor Temperature & Light Monitoring System with Raspberry Pi & DS18B20
- Build a Raspberry Pi Home Temperature Monitor with MCP9808, InfluxDB & Grafana
- Arduino Temperature Sensor Project: Read, Convert, and Display Fahrenheit