Shop OBEX P1 Docs P2 Docs Learn Events
Reading HS1101 Humidity Sensor with Propeller — Parallax Forums

Reading HS1101 Humidity Sensor with Propeller

bomberbomber Posts: 297
edited 2014-05-27 17:02 in Propeller 1
I am working on a Sprinkler Controller Device using the Propeller. The goal of the device is to sample Relative Humidity, and then decide wether to turn on the sprinklers or not. I considered using the Sensirion Temperature/Humidity Sensor, but I realized it would put me above my budget. The HS1101 humidity sensor fit the bill perfectly. The only problem is that I cannot find an object to read the sensor. If possible, I would like to use the same schematic to connect the HS1101 to the Propeller that would be used to connect it to a Basic Stamp. you can find the schematic Here (scroll down to page 2).

Comments

  • JonnyMacJonnyMac Posts: 9,105
    edited 2011-10-02 11:20
    The only problem is that I cannot find an object to read the sensor.

    I have a friend in the special effects business who heard a young animator say, "Where's the dinosaur plug-in?" Sometimes you have to step up and be the first to create an object because nobody else has taken the time. And why wait on others who may not code as well as you, anyway? ;)

    Here's a bit of code that should be helpful. Not having one of those sensors, though, it's not tested. And as the thresholds of the Stamp and Propeller are different you're going to have to do your own calibration.
    pub read_hs1101(pin) | t
    
      outa[pin] := 1                                                ' make pin high (charge C)
      dira[pin] := 1
      waitcnt(clkfreq / 1000 + cnt)                                 ' wait 1ms
      dira[pin] := 0                                                ' make pin an input
      t := -cnt                                                     ' start timing
      repeat while ina[pin]                                         ' let cap discharge
      t += cnt                                                      ' stop timing
    
      return t / (clkfreq / 1_000_000)                              ' return microseconds
    
  • ChrisGaddChrisGadd Posts: 310
    edited 2011-10-02 12:23
    I used one of those in an old SX project. I used the sensor as part of the RC circuit to control the output of a 555, which the SX then measured. This datasheet has an example of the circuit I used.

    The only tricky part that I remember was finding resistor values that produced a significant swing on the output; the sensor only varies from ~161pF to ~193pF according to the datasheet.
  • bomberbomber Posts: 297
    edited 2011-10-02 13:33
    JonnyMac wrote: »
    And why wait on others who may not code as well as you, anyway? ;)

    I forgot to mention that I am a novice spin programmer. Anyway, I will try to calibrate your code.
  • John KauffmanJohn Kauffman Posts: 653
    edited 2014-05-27 10:01
    Did you get this working on prop? I'm looking for sample code with C language.
  • bomberbomber Posts: 297
    edited 2014-05-27 15:29
    Unfortunately, no. The project got cancelled a couple weeks after this. :( A good place to start is some C code for RCtime. Not sure where to find the C version, since haven't worked with C for the propeller yet. Good luck anyways!

    -Roger
  • John KauffmanJohn Kauffman Posts: 653
    edited 2014-05-27 17:02
    Thanks. Right, RCTime no problem. I was checking if anything written, tested and polished before I start.
Sign In or Register to comment.