Is it possible to use a cheap temperature sensor such as the DHT-22 with the Raspberry Pi? I have found Arduino drivers for this and many similar things, and would be comfortable porting the code to the Raspberry Pi, but my understanding is that because it requires such specific timings that having a dedicated microcontroller without a full OS makes it much simpler.

Without the ability to disable interrupts (a'la cli() and sei(), in AVRs), is the level of timing required even possible?

I am attempting to build a controller for a climate control system for aging, for instance, cheese. It would need to be connected to a couple of relays and a temperature and humidity sensor, and this seems like it would be an extremely cost effective way to do it.

Specifically — has anyone seen or written drivers for 1-wire type temperature sensors that run on the 'pi?

  • With the GPIO? Seems plausible to me.
    – Jivings
    Jul 15, 2012 at 22:35
  • That's the goal, but I haven't been able to find any drivers. Luckily the least expensive sensors seem to be digital so it should be technically possible to have a driver that works for one, but I haven't seen any hard evidence that they exist, just people hand waving and saying that 1-wire devices work well. Jul 15, 2012 at 22:37
  • You might be able to use a 1-wire to serial chip, such as the DS2480B
    – Alex L
    Jul 16, 2012 at 8:38
  • 1
    Outside of inteface difficulties, you have to consider the fact that a pi + sdcard is going to cost 2-3 times what a solution based on a small microcontroller (you don't even need a whole arduino) would cost; it's also going to generate heat and waste power. Is there some other part of the problem which justifies dedicating a pie to this? If you needed for example ethernet, then the pie suddenly becomes cheaper than any current small micro solution. Aug 9, 2012 at 19:51
  • @ChrisStratton I suspect you've long since stopped watching this question, but it's definitely worth noting that (a) I have a pi and (b) it is significantly more capable than a small microcontroller. Even just adding ethernet to a microcontroller setup will set your costs above what I am looking at here. Oct 3, 2012 at 20:28

5 Answers 5


Adafruit now even has a tutorial to connect the DHT22 to the pi. The example code works on most Pis, I had to tweak the C code a little like posted in the raspberrypi.org forums (increase a sleep timer).

For other working sensors (including 1-wire and I²C) take a look at my blog. But e.g. the TMP102 is still missing in the list.


If you were to run your process in real-time, it's possible you would get the timing tight enough to work most of the time. Maybe to be more reliable you could use a buffer IC to receive data from the device, so the Pi can then query the buffer IC at a more irregular rate.

I'm not familiar enough with the device, but perhaps it would be possible to connect it to the Pi's serial port instead, if the speeds are compatible? Then the timing and buffering is already taken care of for you, and all you have to do is decode the bits arriving in from the serial port when it suits you.


Microchip MCP950X have a logic output that changes state at a particular temperature

Available switching temperature are

-35°C,-25°C, -15°C, -5°C, 5°C, 15°C, 25°C, 35°C, 45°C,
55°C, 65°C, 75°C, 85°C, 95°C, 105°C, 115°C, 125°C


re: 1-wire, Adafruit's new image has support and I've used it to read 1-wire DS18B20 temp sensor.


Yes adafruit has. but I would recommend a better sensor then that. This has a comparison of the sensor to others along with links to libraries and datasheets: http://simplyautomationized.blogspot.com/2015/10/the-raspberry-pi-temperature-sensors.html

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.