Giter Site home page Giter Site logo

Adafruit_DHT_Driver incorrect readings on long wires (10m) using DHT11 + possible code fix about adafruit-raspberry-pi-python-code HOT 8 CLOSED

adafruit avatar adafruit commented on June 12, 2024
Adafruit_DHT_Driver incorrect readings on long wires (10m) using DHT11 + possible code fix

from adafruit-raspberry-pi-python-code.

Comments (8)

gunkl avatar gunkl commented on June 12, 2024 1

@tdicola Fail, the new code in 1.3.1 also doesn't work for DHT11 over a long cable, in my case a rasp pi 1.

I made these changes and fixed it:
// Set pin at input.
pi_mmio_set_input(pin);
// Need a very short delay before reading pins or else value is sometimes still low.
//for (volatile int i = 0; i < 50; ++i) {
for (volatile int i = 0; i < 500; ++i) {
}

from adafruit-raspberry-pi-python-code.

bayshorebeachboy avatar bayshorebeachboy commented on June 12, 2024 1

First thanks for this thread it seems to address the issue I am having with the dht-22, however; a question.

I made the changes to pi_2_dht_read.c and assume that this should be compiled but am unclear what (executable) to compile it to.

Or if it is compiled at runtime e.g. I am not getting the desired result i.e. I still get the same bad data on a long cable

from adafruit-raspberry-pi-python-code.

talkleasy avatar talkleasy commented on June 12, 2024

Great piece of detective work! Solved the problem I was having on a 20 metre cable to the sensor.

Thanks very much for posting the solution.

from adafruit-raspberry-pi-python-code.

tdicola avatar tdicola commented on June 12, 2024

Thanks for raising the issue and apologies that it couldn't be reviewed earlier. We've actually deprecated this Adafruit_DHT_Driver code and refactored the DHT sensor reading C code into the Adafruit_Python_DHT library here: https://github.com/adafruit/Adafruit_Python_DHT The timing functions in the new library are slightly refactored to use nanosleep for longer delays and busy waiting for shorter delays. I'm curious if this helps with stability over long wires. I'll close this issue for now, but it's great to have as a reference to point folks towards if they are also using very long wires. Thanks again for raising the issue.

from adafruit-raspberry-pi-python-code.

etatus avatar etatus commented on June 12, 2024

Thank you very much @gunkl!!!. Your fix worked like a charm for DHT22 over long cable in my RaspPi 1. (Adafruit_Python_DHT version 1.3.1)

from adafruit-raspberry-pi-python-code.

travc avatar travc commented on June 12, 2024

@tdicola, This should be reopened and @gunkl's fix (or something based on it) adopted.

from adafruit-raspberry-pi-python-code.

gunkl avatar gunkl commented on June 12, 2024

created pull request adafruit/Adafruit_Python_DHT#98

from adafruit-raspberry-pi-python-code.

etatus avatar etatus commented on June 12, 2024

@gunkl approach stopped working for me and I find a new solution here: #161

from adafruit-raspberry-pi-python-code.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.