14

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?

Maria Zverina
  • 5,168
  • 5
  • 30
  • 42
chrisrhoden
  • 243
  • 1
  • 2
  • 7
  • With the GPIO? Seems plausible to me. – Jivings Jul 15 '12 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. – chrisrhoden Jul 15 '12 at 22:37
  • You might be able to use a 1-wire to serial chip, such as the DS2480B – Alex L Jul 16 '12 at 08: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. – Chris Stratton Aug 09 '12 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. – chrisrhoden Oct 03 '12 at 20:28
  • As I already said, the pi is cost adventageous when it provides something a bare micro cannot without expensive accessories, such as ethernet. But for something that can be solved with a simpler device, it introduces cost, complexity, size, power, supply, etc disadvantages. – Chris Stratton Oct 04 '12 at 01:13

5 Answers5

8

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.

Avio
  • 1,217
  • 2
  • 14
  • 25
mauorrizze
  • 96
  • 1
  • 2
1

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.

Malvineous
  • 1,874
  • 14
  • 20
0

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

John La Rooy
  • 11,947
  • 9
  • 47
  • 75
0

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

pdp7
  • 161
  • 2
0

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

raspi-ninja
  • 879
  • 2
  • 8
  • 15