# DHT12 i2c ir one wire use

**URL:** <https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707>\
**Category:** Hardware\
**Created:** [6 March 2020 12:41 UTC](https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707 "2020-03-06T12:41:12Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![nahuavrilero](https://avatars.discourse-cdn.com/v4/letter/n/4491bb/32.png) [@nahuavrilero](https://discourse.nodered.org/u/nahuavrilero)\
**Post date:** [6 March 2020 12:41 UTC](https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707/1 "2020-03-06T12:41:12Z")

</div>

Hey there. I'm trying to use Aosong DHT12 sensor.  
This sensor can be used with i2c and one wire connections.  
I've tried one wire with DHT11/22 node but couldn't make it work.  
I tried i2c too, but didn't work neither.  
Is there a library or node that works with this sensor?

By the way, I'm using raspberry pi 3 b, last version of raspbian and Node Red. And I have enabled both I2C and one wire interfaces as well remote gpio.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [6 March 2020 12:46 UTC](https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707/2 "2020-03-06T12:46:23Z")

</div>

Always good to search the flows library - [https://flows.nodered.org/search?term=dht](https://flows.nodered.org/search?term=dht)

---

<div class="post-metadata">

**Author:** ![nahuavrilero](https://avatars.discourse-cdn.com/v4/letter/n/4491bb/32.png) [@nahuavrilero](https://discourse.nodered.org/u/nahuavrilero)\
**Post date:** [6 March 2020 13:04 UTC](https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707/3 "2020-03-06T13:04:22Z")

</div>

Thanks for the reply.  
In fact I have installed that node. And even used it before with DHT11 sensor.  
But I have a DHT12 Wich is slightly different and I can't make it work.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [6 March 2020 13:54 UTC](https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707/4 "2020-03-06T13:54:55Z")

</div>

I've never come across a DHT12. DHT11 and DHT22 is all I've used and I stopped using them a long time ago because of accuracy and drift issues.

If that node doesn't work, you may need to reach out to the author but if they don't have a DHT12, it may be difficult for them to support it.

Is there an Arduino library that supports it or maybe a Python library? That might at least give some clues as to what is needed. Additionally, it is often seems easier to do IoT sensors using an Arduino or ESP8266/ESP32 rather than directly on the Pi.

---

<div class="post-metadata">

**Author:** ![nahuavrilero](https://avatars.discourse-cdn.com/v4/letter/n/4491bb/32.png) [@nahuavrilero](https://discourse.nodered.org/u/nahuavrilero)\
**Post date:** [6 March 2020 14:28 UTC](https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707/5 "2020-03-06T14:28:27Z")

</div>

There's no python library.  
But there's an Arduino library. [https://github.com/xreef/DHT12\_sensor\_library](https://github.com/xreef/DHT12_sensor_library)

Could it be portable to Python?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [6 March 2020 17:34 UTC](https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707/6 "2020-03-06T17:34:48Z")

</div>

I expect it could be translated by someone who knows both C++ and Python very well. Of course, they would need to want to do it as well.

As I've not come across this sensor previously, perhaps it isn't commonly used, at least in home automation?

Otherwise, I'm afraid that your other options are to get a better supported sensor or use an Arduino or ESP device (they can be programmed using the Arduino IDE and so can use the same libraries) instead.

---

<div class="post-metadata">

**Author:** ![nahuavrilero](https://avatars.discourse-cdn.com/v4/letter/n/4491bb/32.png) [@nahuavrilero](https://discourse.nodered.org/u/nahuavrilero)\
**Post date:** [6 March 2020 18:06 UTC](https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707/7 "2020-03-06T18:06:06Z")

</div>

This sensor is the actualization of DHT11. So I'm guessing it's relatively new. It may be because of that that It isn't well supported.  
I'm gonna keep trying with Python and I2C and if I don't succeed I will try with another sensor.

Anyway, thank you so much for your help.

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [6 March 2020 18:25 UTC](https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707/8 "2020-03-06T18:25:44Z")

</div>

AS Julian (@TotallyInformation) said, the DHT series of sensors are pretty poor for accuracy. The DHT12 is an I2C sensor, NOT 1-wire. Have a look at the SHT31 from Sensirion, this is available on a breakout board from many suppliers.

---

<div class="post-metadata">

**Author:** ![nahuavrilero](https://avatars.discourse-cdn.com/v4/letter/n/4491bb/32.png) [@nahuavrilero](https://discourse.nodered.org/u/nahuavrilero)\
**Post date:** [7 March 2020 16:05 UTC](https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707/9 "2020-03-07T16:05:41Z")

</div>

SHT31 is way out of my budget.  
But anyway, i managed to make it work with one wire and the DHT22 node.

Thanks everyone for your help.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [7 March 2020 17:27 UTC](https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707/10 "2020-03-07T17:27:48Z")

</div>

These should be in the right price range:

- HTU21D (replaces SHT21, SI7021, HDC1080) - should be around the same accuracy if not slightly better than the BME280/BMP280

- BMP280 - high-accuracy, low drift, low cost.

- DHT11, SHT11, DHT22, AM2301/dht21, AM2302, AM2303/dht22

[Cheapest DHT12](https://www.aliexpress.com/item/33017960241.html?spm=a2g0o.productlist.0.0.18bb5f9d54qvd4&algo_pvid=321a75fa-6e14-4c56-9c85-22e1d2675ea1&algo_expid=321a75fa-6e14-4c56-9c85-22e1d2675ea1-11&btsid=0b0a01f815836015563854076e961a&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_) I could find in stock was about £0.92 + £0.48 shipping to the UK.

So actually, you would be better off with a BMP280 which is well supported and cheap.

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [7 March 2020 20:57 UTC](https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707/11 "2020-03-07T20:57:38Z")

</div>

> [@nahuavrilero](#):
>
> But anyway, i managed to make it work with one wire and the DHT22 node.

Could you post your flow please?

---

<div class="post-metadata">

**Author:** ![nahuavrilero](https://avatars.discourse-cdn.com/v4/letter/n/4491bb/32.png) [@nahuavrilero](https://discourse.nodered.org/u/nahuavrilero)\
**Post date:** [9 March 2020 14:19 UTC](https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707/12 "2020-03-09T14:19:53Z")

</div>

Thanks for the info. I will look into these.

And ghayne, I can't right now.  
I can't access to my flow editor.  
When I fix it I'll post it. 😉

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 May 2020 14:20 UTC](https://discourse.nodered.org/t/dht12-i2c-ir-one-wire-use/22707/13 "2020-05-08T14:20:04Z")

</div>

Closed on 8 May 2020 14:20 UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
