Shop OBEX P1 Docs P2 Docs Learn Events
DHT 11 Code Help Needed — Parallax Forums

DHT 11 Code Help Needed

NWCCTVNWCCTV Posts: 3,629
edited 2015-03-03 19:24 in General Discussion
I seem to be having another brain spasm here. Can someone tell me what Pin I am suppose to use in the attached program? I see the call to "APin" but I do not see which pin that is connected to. Thanks for the help.

Comments

  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-03-03 18:50
    Propeller objects 101: the object.start() method is generally used to pass relevant information for the application to the object.

    In this case you need to pass the pin connected to the sensor, and pointers to longs that hold the temperature, humidity, and parity error code. While I don't condone direct pin # use (i.e., magic # in listing), I will in this example
    dht11.start(15, @temp, @humid, @error)
    


    ...where the sensor is connected to P15, and you have the longs temp, humid, and error defined in your top object.

    Proper objects do not force you to use specific IO pins (there are a few reasonable exceptions); YOU decide which pin to use and then tell the object what it is.

    Easy-peasy.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-03-03 19:24
    I thank you kindly for the info.
  • Roxanna77Roxanna77 Posts: 18
    edited 2016-01-16 00:49
    Wondering if you had any luck with the example code and diver? I kept thinking my dht11 sensors were no good, as I could not get them to read consistently with the example. About 9 of 10 resets of my Quickstart board would show Read Error, and when it would show a temp and humidity, it would not change. I even found that pulling the sensor lead would not change the value, or produce an error. I got an Arduino Uno the other day and tried the sensors on it with the Adafruit library, and the sensor reads perfect. I want to use it on a Propeller though.

    So, what is wrong with this code? The way it is written, I can't make heads nor tails of it (no surprise, I'm not that good of a programmer). I tried different pins, same results.
    Any help I can get would be greatly appreciated!
Sign In or Register to comment.