Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a few DS18B20 temperature sensors. These are normally used in Arduino but I don't see why not to use them in a Pi. There is a software called DigiTemp that seems to drive the device and I have compiled and installed it in the Pi. The not so clear thing is, how do I connect them? Directly to the UART?

share|improve this question
up vote 5 down vote accepted

Adafruit has released a distro called occidentalis which has 1-wire support built in.

One wire is most commonly used for DS18B20 temp sensors. The Pi does not have 'hardware' 1-wire support but it can bitbang it with some success. Connect a DS18B20 with VCC to 3V, ground to ground and Data to GPIO #4. Then connect a 4.7K resistor from Data to VCC.

This will allow you to read the temperature with commands like

cat /sys/bus/w1/devices/28-*/w1_slave

I don't know if digitemp can be made to work with those, but it should be fairly straightforward to write a munin plugin if you just want to get the temperature graphs

share|improve this answer
Is there any way to use the 1-wire driver in Arch Linux? – Tomas Aug 14 '12 at 3:30
@Tomas, I'm not using Arch Linux, but I expect they'll get the module in there eventually. In the meantime you'll have to patch the kernel yourself. – John La Rooy Aug 14 '12 at 3:38
1 wire on GPIO 4 is now supported by official kernel (update from Aug 23) so any distribution that is using it will have this supported. You have to update the kernel however (ensure it's based on kernel 3.2). Then insert wire and w1-therm modules. – Krzysztof Adamski Aug 24 '12 at 9:10
Thanks @KrzysztofAdamski! – Tomas Sep 19 '12 at 13:13

I think the secret sauce is the last line on this page

It links to DS9097U which does the UART to 1-wire conversion

I have previously use the "pic arbiter" with these devices. It works in a similar role getting the data from the 1-wire devices and making it suitable for consumption by the UART

It's also possible to connect I2C devices such as the MCP9804 directly to GPIO pins. The downside is that you need 4 wires

share|improve this answer
Thanks. If it is possible, I'd want to use the sensor without adding yet another IC. I don't mind spending 3 GPIO pins. Is it easy to interface a 1-wire device using GPIO directly? – Tomas Jul 26 '12 at 21:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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