Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

Build a Remote Temperature Sensor with Raspberry Pi and Python – Step‑by‑Step Guide

Build a Remote Temperature Sensor with Raspberry Pi and Python – Step‑by‑Step Guide

After years of refining this project based on community feedback, this updated guide delivers a ready‑to‑use IoT temperature sensor that runs on any embedded Linux board with Python and 1‑wire support. From a simple LED demo to a full‑featured remote monitor, you’ll learn how to assemble, configure, and deploy your own sensor in just a few hours.

What You’ll Create

Using a Raspberry Pi, a DS18B20 1‑wire temperature sensor, and a basic LED, you’ll build:

Hardware List

The schematic is straightforward: power the sensor from the Pi’s 5 V pin (pin 2). No external power is required.

Step 1 – Set Up Your Raspberry Pi

  1. Flash a fresh Raspbian image onto an SD card and boot the Pi.
  2. Use a reliable 5 V/1 A micro‑USB charger (a smartphone charger usually works).
  3. Configure network access: you can skip HDMI and USB peripherals by connecting via Ethernet, obtaining a DHCP address, and accessing the Pi with SSH (default credentials: pi/raspberry).
  4. Wire the sensor and LED to the breadboard according to the schematic.
  5. Load the 1‑wire kernel modules:
    sudo modprobe w1-gpio
    sudo modprobe w1_therm
  6. Persist the modules across reboots by adding them to /etc/modules:
    echo "w1-gpio" | sudo tee -a /etc/modules
    echo "w1_therm" | sudo tee -a /etc/modules
  7. Locate your sensor ID:
    ls /sys/bus/w1/devices/
    The directory will resemble 28-00000393268a.
  8. Verify the sensor works:
    cat /sys/bus/w1/devices/28-00000393268a/w1_slave

Step 2 – Install DeviceHive on the Pi

  1. Download the latest DeviceHive package from devicehive.com.
  2. SSH into your Pi and create a working directory:
    mkdir ~/devicehive
  3. Transfer the Python source from your host machine using scp:
    scp -r ~/Downloads/devicehive/python/device/Source/* [email protected]:~/devicehive
  4. Visit DeviceHive Playground and sign up for a free account to receive your API key.

Step 3 – Run the Sample

Navigate to the devicehive/python/device/Source folder, edit the configuration with your API key, and launch the script. The sensor data will stream to DeviceHive, where you can visualize it on the web dashboard or trigger actions via the mobile app.

Expand the Project

With the basic framework in place, you can:

Enjoy building your first IoT device and explore endless possibilities with Raspberry Pi and Python!

Manufacturing process

  1. Build a Raspberry Pi Temperature Logger with a $5 I2C Sensor
  2. Accurate Raspberry Pi Temperature Profiling with Python, SQLite, and LabVIEW
  3. Connect Multiple DS18B20 1‑Wire Sensors to a Raspberry Pi for Accurate Temperature Monitoring
  4. TMP006 Infrared Temperature Sensor with Raspberry Pi: Python Library & Setup Guide
  5. Control an LED with a PIR Motion Sensor on Raspberry Pi
  6. Build a Multi‑Sensor Temperature & Light Monitoring System with Raspberry Pi & DS18B20
  7. Raspberry Pi–Based Bathroom Occupancy Sensor with Voice & SMS Alerts via Twilio
  8. Mastering Raspberry Pi Sensor & Actuator Control: Accelerometer, Servo, and Data Streaming
  9. Build a Raspberry Pi Home Temperature Monitor with MCP9808, InfluxDB & Grafana
  10. Build a Robot with Raspberry Pi and Python: A Complete Guide