Shop OBEX P1 Docs P2 Docs Learn Events
HS1101 humidity sensor code problem — Parallax Forums

HS1101 humidity sensor code problem

HighlandtinkerHighlandtinker Posts: 50
edited 2010-05-12 03:23 in Accessories
·Hi everybody

···· I have been expermenting with the HS1101 humidity sensor that I got from Parallax. I am trying to build a in home Enviroment monitor·idea.gif·. ·I am also using a DS1620 Digital Thermometer. Also outputting to both Debug and an LCD. My problem is that when I run the code the output is OK one time thru, then next tme through it is messed up. ( Example: first tme it reads 27.18% then the next time through it will read 00.09% ). The out put is this way on both Debug screen as well as LCD. I have this problem even with the sample code from Parallax. The circuits are the sample ones from Parallax and using a BS2e on the PDB. Any idea as what to do to fix this would be appreciated. Thanks·smile.gif

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-05-03 19:00
    You might try sending a clear display before each loop and maybe do the setup also.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • HighlandtinkerHighlandtinker Posts: 50
    edited 2009-05-03 20:35
    ·

    · Stephen:

    ········ Thanks for the response. I will try your suggestions and post the results.yeah.gif
  • HighlandtinkerHighlandtinker Posts: 50
    edited 2009-05-03 21:01
    ··



    ·· Well tried the suggestions but still have problem. The out -put cycles at the rate of the pause statment and each time it rewrites the humidity it may be the same two times in a row but most likely it will not.

    ······················· Example display:······ Rel Humidity· = 27.26%

    ··············································································· 27.24%

    ················································································· 0.01%

    ·················································································27.25%

    ················································································ 27.23%

    ·················································································· 0.00%

    ·················································································· 0.05%

    ·····························continues this way on both LCD and PC (Debug)freaked.gif

    ···························· Thanks again

    ···············································································
  • Jessica UelmenJessica Uelmen Posts: 490
    edited 2009-05-04 21:04
    Hello,

    Have you tried testing the sensor alone without the temperature sensor integrated?· Does it work then?· Another thing that we have found when working with this sensor is that you may need to calibrate it for different conditions.· Have you tried testing the results against a known humidity reading and adjusted the RHconstant accordingly?

    Also,·how accurate are you expecting this sensor to be?· According to our documentation, you can recieve up to a·+/-5% error.· If you are trying to receive accuracy within hundreths of a percent, it really isn't feasible with this setup.

    However, if you want to display the results simply for aesthetics,·you will have to rethink some of your code.··Remember·in the·documentation that all·results were obtained through linear·approximation with the equation:·%RH = (time - 1216.9) / 2.4

    Since the BASIC Stamp only works with integer math, in order for higher accuracy, each value was multiplied by 10.··Because of this,

    %RH = ((time * 10) - 12169)/24.

    When·using this equation for the BASIC Stamp,·the rules of integer math still apply.··For example, say you're realtive humidity is 45.14%, after·calculating the result, the value that will be·stored to the "humidity" variable will be 45.··Using the code you've written to·display the value:·
    DEBUG HOME, "Relative Humidity = ", DEC (humidity/100),".",DEC2 Humidity, "%"   
    

    The Debug terminal will display 0.45.· This is because you're asking for 45/100 for the first value - which is 0.45 - or 0 in integer math; and the second value is the humidity value,·or·45.

    If you would like to display a decimal, you can do this using ideas introduced in Chapter 3 of our Basic Analog and Digital book.· Starting on page 56, integer math is explained in depth, and it also explains how to display digits after the decimal.

    I hope this helps, happy developing!

    - Jessica

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jessica Uelmen
    Education Department
    Parallax, Inc.
  • HighlandtinkerHighlandtinker Posts: 50
    edited 2009-05-04 23:29
    ·Jessica,

    ········ Thank you for the info and suggestions. I tried the humidity sensor by it'self using the code that came with the download documentation, which I have as an attachment. It gives 4 digit output (2725% then might repeat same or might be 6%30% ...·etc), so that is why I tryed to show it the way I did. At this point I am not concerned with accuracy, just playing with some ideas for the house. I will read up on the decimal point display per your suggestion. Maybe I am doing something wrong with the sample code so will mess with it some more.

    ········ If any body else has suggestions or ideas please help. Thanks
  • Jessica UelmenJessica Uelmen Posts: 490
    edited 2009-05-05 15:28
    Interesting. Would it be possible to post a schematic of how you have everything wired?

    Thanks!

    Jessica

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jessica Uelmen
    Education Department
    Parallax, Inc.
  • HighlandtinkerHighlandtinker Posts: 50
    edited 2009-05-05 21:25
    ····

    ···· Jessica,



    ··· The circuit I am using,· at this time, to test the HS1101 Relative Humidity Sensor (#27920) is the one on page 2 of the documentation provided by Parallax (see attached) . I am also using the test code on page 4 of the same documentation sheet. The only change I make to the code is to lengthen the pause statement at the end to slow things down and remove HOME from DEBUG and add CR so I can have a·string of numbers to look at.·Sometimes·the output I get has two more digits then the expected output in the sample on page 2.

    Example = 2724% then 16%· then 15% then back to a 4 digit output. Not concerned about getting the right % yet just some consistancy. I don't know how to capture the debug box to includ it in my posting.·sad.gif·

    I am using my BOE with a BS2 instead of my PDB with BS2e so as to only deal with the Humidity sensor. I don’t think I have anything wired· wrong , but anything is possible. After 20 years working for an Electronics Engineer , ( Old school Engineer - did not deal with microprocessors or computers, although our equipment did interface to customer’s computers ) building high voltage power supplies I learned sometimes we make mistakes that we cannot see. jumpin.gif

    Post Edited (Highlandtinker) : 5/5/2009 10:13:28 PM GMT
  • Jessica UelmenJessica Uelmen Posts: 490
    edited 2009-05-06 19:01
    Hi Highlandtinker,

    I tested the sample code with your modifications again using the BASIC Stamp 2 and 2e, and both ran fine. However, I noticed that when I either unplugged the sensor or connected it to a different pin, I got the same response as you. As elementary as it sounds, make sure you're connected to the correct pin and have the polarity of the sensor correct. If you'd like to attach a picture of your wiring setup, I would be happy to lend a second set of eyes. I know very well the value of a second look when checking wiring. [noparse]:)[/noparse]

    - Jessica

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jessica Uelmen
    Education Department
    Parallax, Inc.
  • HighlandtinkerHighlandtinker Posts: 50
    edited 2009-05-07 01:36
    ···· Jessica,

    ············ Thanks again for the help. I will send a picture as soon as I can get one that is good enough to see something. I have rewired and double checked my work but just can't see anything wrong. I even changed the sensor and changed jumpers, but still no-go. I am going to set this project to the side, but only temporaraly. This by no means discourages me, just makes me more determined. Parallax is a super company and the support is very good. Thanks again and I will send photo soon.roll.gif·········
  • HighlandtinkerHighlandtinker Posts: 50
    edited 2009-05-12 00:17
    freaked.gif
    ·· Well, I tried to get this to work as shown in the documentation but have been unable to get consistant out put. Keep getting 4 digit readings that will change to one digit every 8 to 10 cycles, instead of the expected sample out put in fig 3, pg. 2. I have checked and double checked my circuit which is the simple test circuit on pg. 2 of 4. If I hook posistive of ensor to a pin other then what the code expects then I still get 4 digit out put but it is always thw same. If any one out there might have any idea of what I am doing wrong or have any other circuits that use this sensor please help. I may try the more expensive Humidity/Temp sensor Parallax sells.· Thanks again. smurf.gif
  • JSansoterraJSansoterra Posts: 1
    edited 2009-12-03 05:50
    I was experiencing the same problem as you.

    I believe your RHconstant value is too high. Start with a value of 11398 and dial it in from there.

    That being said, the RC network is sensitive to temperature drift and noise and the HS1101 has a 5% tolerance. Each time the RCTIME command is executed I see the humidity·value fluctuate +/- 5% from my reference instrument on the same table. Therefore, 20%RH reads as low as 15%RH and as high as 25%RH.

    Here are some·values as I'm watching it run:

    · Reference instrument: 20%RH.
    · Calcluated·values·using your hardware setup and code, executed·once per second: 20, 17, 23, 15, 25, 18, 25, 17....

    A 5% tolerance over a 0-100%RH range·might be acceptable if·you needed to·know·when things were at 65%RH versus·20%RH. But·when operating over a smaller range, say 20-30%RH, the tolerance is more problematic.

    A better design or more accurate component might be a better alternative.·I have also been looking at the Sensirion Temperature/Humidity sensor... it's just too expensive.

    ·
  • HighlandtinkerHighlandtinker Posts: 50
    edited 2009-12-08 02:21
    JSansoterra

    Thank you for the good infolol.gif· I just saw your post tonite. I haven't played with this project for awhile, but using your info I will try again. What you say makes lots of sence and explains a few things. I have been able to get it to work ok a few times but then I have trouble duplicating it again. May be because of where in the house I am working.jumpin.gif I also would like to try the Sensirion Temperature/Humidity sensor but have many other projects to play with and only so much $$$. Again,·roll.gif THANK YOU!!
  • RogueRogue Posts: 1
    edited 2010-05-12 03:23
    I had the same problem. It is the sensor, if you have a capacitor checker (Fluke) or something and you check the capacitance to the data sheet you will see that the sensor is off of the factory setting.

    The constant that they show is I believe is @1290 which is the decay for 0% humidity. If you re adjust it to 495 it should fix the problem. Or use your debug to look at the time decay at you humidity level and then recalibrate

    I made a spread sheet I can send you by E mail if you like or here is the formula


    Time decay Span ratio Humidity Constant
    1166.00 = 2.4 x 30 Plus 456
Sign In or Register to comment.