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

Measuring Temperature on Raspberry Pi with Maxim 1‑Wire Sensors and DS2482 I2C Bridge

Measuring Temperature on Raspberry Pi with Maxim 1‑Wire Sensors and DS2482 I2C Bridge

Accurate temperature monitoring is essential for many Raspberry Pi projects, from climate control to data logging. The Maxim Integrated 1‑Wire family of sensors, such as the DS18B20, offers a simple, low‑pin solution. By using the DS2482 1‑Wire‑to‑I2C bridge you can attach up to ten sensors to a single I2C bus, keeping the Pi’s GPIO footprint minimal.

Hardware Overview

Software Prerequisites

These instructions assume a standard Raspbian installation with kernel source available. You will need to rebuild the kernel after making the following changes.

Step 1 – Enable the DS2482 on the I2C Bus

Modify arch/arm/mach-bcm2708/bcm2708.c in the kernel source to register the DS2482 as an I2C device. Add the following platform device definition and board info array:

static struct platform_device bcm2708_bsc1_device = {
    .name = "bcm2708_i2c",
    .id = 1,
    .num_resources = ARRAY_SIZE(bcm2708_bsc1_resources),
    .resource = bcm2708_bsc1_resources,
};

static struct i2c_board_info __initdata pi_i2c_devs[] = {
    { I2C_BOARD_INFO("ds1307", 0x68)},
    { I2C_BOARD_INFO("ds2482", 0x18)},
};
...
bcm_register_device(&bcm2835_thermal_device);

After adding the device, recompile and install the kernel.

Step 2 – Handle 1‑Wire Pull‑ups in the Kernel

Modify drivers/w1/w1_io.c to allow the DS2482 to control the pull‑up resistor during conversions. Replace the w1_post_write function with:

static void w1_post_write(struct w1_master *dev)
{
    if (dev->pullup_duration) {
        if (dev->enable_pullup && dev->bus_master->set_pullup) {
            dev->bus_master->set_pullup(dev->bus_master->data, 0);
            msleep(dev->pullup_duration);
        } else {
            msleep(dev->pullup_duration);
        }
        dev->pullup_duration = 0;
    }
}

Step 3 – Add Pull‑up Control to the DS2482 Driver

In drivers/w1/masters/ds2842.c add a helper that activates the DS2482’s strong pull‑up when a delay is requested:

static u8 ds2482_w1_set_pullup(void *data, int delay)
{
    struct ds2482_w1_chan *pchan = data;
    struct ds2482_data *pdev = pchan->pdev;
    u8 retval = 1;
    u8 cfg;

    if (delay) {
        /* Ensure the bus is idle before changing config */
        ds2482_wait_1wire_idle(pdev);
        /* Enable both SPU and APU for a strong pull‑up */
        retval = ds2482_send_cmd_data(pdev, DS2482_CMD_WRITE_CONFIG,
                     ds2482_calculate_config(DS2482_REG_CFG_SPU | DS2482_REG_CFG_APU));
        ds2482_wait_1wire_idle(pdev);
    }
    return retval;
}

Final Steps

With these kernel tweaks in place, the Raspberry Pi can reliably read up to ten 1‑Wire temperature sensors through a single DS2482 bridge, making it ideal for multi‑sensor monitoring projects.

Additional Resources

Manufacturing process

  1. Build a Raspberry Pi Temperature Logger with a $5 I2C Sensor
  2. Connect Multiple DS18B20 1‑Wire Sensors to a Raspberry Pi for Accurate Temperature Monitoring
  3. How to Read Temperature with a DS18B20 on Raspberry Pi 2
  4. Professional Raspberry Pi Temperature Monitoring with DS18B20
  5. Accurate Temperature Monitoring in a Server Closet with Raspberry Pi
  6. Build a ThingSpeak Temperature Monitor with Raspberry Pi & BrickPi
  7. Build a Multi‑Sensor Temperature & Light Monitoring System with Raspberry Pi & DS18B20
  8. Build a Raspberry Pi Home Temperature Monitor with MCP9808, InfluxDB & Grafana
  9. Build a Self‑Balancing Segway with Raspberry Pi
  10. Accurate Solar Radiation Measurement Using Arduino UNO and Ethernet Shield