I've got my 4 Maxim DS18B20 devices up and working using the w1-gpio and w1-therm modules.

I would however like to change the temperature resolution by writing to the config register of the devices, as described on page 8 of the Maxim spec here

Is there a way to achieve this using the file system interface? I don't really fancy having to recompile the driver to do this. I've searched high and low but can't find anything.

Thanks in advance for any help.

  • Welcome to Raspberry Pi Stack Exchange! Could you include some of what you've tried already? Mar 9, 2014 at 1:10

4 Answers 4


On Raspberry Pi 1

(ignore any errors:)

wget https://raw.githubusercontent.com/blogmotion/BitBangingDS18B20/master/configDS18B20.c
gcc -o configDS18B20 configDS18B20.c
sudo ./configDS18B20

Now type 9,10,11, or 12 to change resolution:

  • 9 bit : 0.5°c
  • 10 bit : 0.25°c
  • 11 bit : 0.125°c
  • 12 bit : 0.0625°c

On Raspberry Pi 2

(ignore any errors:)

wget https://raw.githubusercontent.com/blogmotion/BitBangingDS18B20/master/configDS18B20.c
sudo nano configDS18B20.c

Change "BCM2708_PERI_BASE "0x20000000" to BCM2708_PERI_BASE "0x3F000000" (ignore any errors)
Save (Ctrl+X, Y, ENTER)

gcc -o configDS18B20 configDS18B20.c
sudo ./configDS18B20

Now type 9,10,11, or 12 to change resolution:

  • 9 bit : 0.5°c
  • 10 bit : 0.25°c
  • 11 bit : 0.125°c
  • 12 bit : 0.0625°c
  • 1
    This does change the resolution correctly(tried&confirmed on 1st gen model B), but it doesn't speed up the process, sadly...
    – Kraay89
    Nov 8, 2016 at 21:25
  • Please see the answer by @fran below, it reflects recent status. Changing resolution is now supported natively by dtoverlay.
    – vadipp
    Nov 21, 2022 at 17:34

This isn't the right answer to my original question, however, it does solve the original problem.

There are two reasons why one would want to change the DS18B20 resolution: 1. To read a single device much more quickly than 750ms 2. To read a bunch of devices more frequently than (#devices * 750ms)

If you want to do 1, then you're stuck - as far as I can tell from the w1_therm source code here there is no support for writing to the config register, and in any case the w1_therm driver has the 750ms wait value hard coded in it.

However, it appears that the w1_therm driver does support multiple calls to devices concurrently. As a read operation is really three steps:

  1. Issue read command to device
  2. Wait 750ms
  3. Read temperature reading

it is actually possible to issue a read command to all your devices, and provided you're not using parasitic power mode there should be enough juice for all your devices to do the temperature conversion concurrently.

How does this work?

readAllSlow looks like this - this is the slow way of reading your devices.

tN is a symbolic link to the file you'd normally read the temperature from the command line.

cat t1
cat t2
cat t3
cat t4

If we run this with time command, on my Pi it takes 3s+ - this is 750ms for each device plus overhead.

However, if we do the reads concurrently like this:


cat t1 &

cat t2 &

cat t3 &

cat t4 &

wait $PID1
wait $PID2
wait $PID3
wait $PID4

Then timing the script using time takes only 900ms - 1s.

Some caveats - I can't see how w1_therm achieves this as as far as I can see it goes to sleep with the mutex held (so I'm surprised this works).

And an apology for the formatting - I've spent 20 mins trying to figure out how to do formatted code and failed. Hope this helps.

  • You can write code by making a new paragraph and then adding four spaces to the beginning of each line.
    – LuWi
    Apr 7, 2014 at 9:54
  • 1
    There is a lot of other things that are hardcoded in the w1-gpio and w1-therm drivers that really limit the use of 1-wire for some particular applications.
    – Marco Poli
    Apr 8, 2014 at 17:36

(Posting this here as it's the top result on google.)

As of rpi-5.4.y this functionlity is baked in and does reduce the read times and resolution as it should.

To change the resolution of all the sensors;

cd /sys/bus/w1/devices/
sudo su
for dir in 28-*; do echo 11 > "$dir"/resolution; echo "$dir"; done

then check the settings took;

cat 28-*/resolution

If not, which may happen with lots of sensors or long wires, try again.

That change will be temporary and be lost if the sensors are power cycled. To make the settings stick you need to save them to eeprom;

for dir in 28-*; do echo save > "$dir"/eeprom; echo "$dir"; done

Remove power from the RaspberryPi to give the sensors a chance to propwerl discharge, reboot and check the settings again.

  • Thanks! This works fine, until the resolution seems to reset back to 12 bits by itself (even after saving to eeprom). I'm using owserver 3.2p3+dfsg1-2+deb10u1 on raspbian 10.13 on a Raspberry pi 4B.
    – vadipp
    Nov 21, 2022 at 19:06

Some folks have mentioned in the comments that w1-gpio and w1-therm limit that range of applications for your ds18b20. It's not clear whether that's due to not being able to change the resolution or because they only support one resolution. But let me add that I came here with the same problem - I need to change some ds18b20s. I'm running w1-gpio and w1-therm and some of my sensors (one brand) was set to 12-bit default, and some of them (another brand) was set to 9-bit default, which is too imprecise for my application.

So, I can at least confirm that w1-gpio and w1-therm not only support various resolutions, but can support using multiple resolutions at the same time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.