Shop OBEX P1 Docs P2 Docs Learn Events
Sensirion sht11 — Parallax Forums

Sensirion sht11

RsadeikaRsadeika Posts: 3,837
edited 2013-12-04 11:14 in Propeller 1
There was some work done quite a few months ago on the Sensirion sht11 library, I thought that I would try to bring this up to date. In the program below I made this adjustment to sht11.c too suit my real temp readings:
float sht11_degF(void)
{
  float soT = (float) sht11_tempRaw();
  //float sTf = (((float) soT) * 0.018)-39.322;
  float sTf = (((float) soT) * 0.018) - 44.922; // Adjusted to match real temp.
  return sTf;
}
The program below is a very basic program, it just prints out all the values to the terminal screen. The next thing that I would like to do is create a CMM/XMMC library of sht11.c and sht11.h, but I have no idea as to where to start or how it is done. The important part is that I have a sht11 library that can be used in either CMM mode or XMMC mode, and maybe some of the other XMM modes, in case I ever want to add the Parallax memory module to my Activity Board or the PropBOE board.

I am also thinking that at some point it may be interesting to also do a C++ version, just to see if in some cases it is more beneficial to use C or C++.

Ray

Comments

  • KMyersKMyers Posts: 433
    edited 2013-11-30 09:21
    Ray,
    Thanks for posting this. Have been working with this sensor but in spin. Want get it working with Xbee also to set up a small wireless sensor network that could be expanded with other sensors.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-11-30 10:03
    As soon as I figure out how to do the libraries I will have an XBee module working, plus a Li-ion power pack attached to make it a mobile temperature monitoring device. Now that I have a working time/date server with an XBee attached, I will hopefully be able to do some data logging plus remote access to the temp unit.

    Ray
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-11-30 10:43
    In the SimpleIDE User Guide, jazzed has a decent description of how to make the libraries. The only problem, well not really a problem, is that each memory model will need its own library which means that I will probably have four of them. I guess a very good naming procedure has to be implemented, now I need some ideas as to what that should look like, since this will be available to everybody.

    Ray
  • KMyersKMyers Posts: 433
    edited 2013-11-30 12:25
    Your code compilied great and works good. I know enough about C to be dangerous but got the DI and clk pins set to match mine. I guess I need to forch my self to sit down and work through the tutorials on C. Not exactly sure what the .h files do and mean and how to use the libraries.

    I would love to see how to do the Xbee in C. Any advice?
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-01 03:04
    Your code compilied great and works good.
    It is not my code, the author is Andy Lindsay(Parallax). All that I am doing is bringing the subject back up for discussion. This particular thread, what I would like to do is keep it topic/subject specific, meaning detailed discussion of XBee, and other things will be brought up in other threads. Having said that, you could go to the Learn forum, and look through the "My ActivityBot" thread, there is lots of code examples as to how the XBee can be used.

    The reason that I am bringing the subject up is, I found that I was getting a different temp reading from two different sources. To be specific, the sht11 readings were about six degrees higher than the readings from a digital thermometer that I was using. Now, I am not saying that the Parallax product is bad, all I am saying is that I am getting different data readings. In the program that is in the OP, I had made a software adjustment for the F degree reading, which when I ran for about an hour the temp readings from both sources were comparable. So, it is not the equipment, but an adjustment that was necessary. The only problem that I can see is, is this just an occurrence for the module that I have, or does this occur with all the other modules also. I do have another sht11 module which I used with a Spin centric project, and if I remember correctly(IIRC), that module also had to be adjusted. But once adjusted the data readings are very consistent.

    @KMyers, if you used the program as downloaded, with the data adjustment in tact, what sort of temp readings were you getting? How close are they to the real temp at the reading site? Maybe you should reset the adjustment back to the original state and do some readings to see if in fact that you are getting a different reading from the real temp.

    Ray
  • KMyersKMyers Posts: 433
    edited 2013-12-01 09:16
    Well in my experience with two different SH11 on two boards I had the same results about 5 degrees higher then my thermostat read. That was in Spin, I put in a fudge factor to compensate for this. Andy's program as downloaded reads about 2 degrees lower then the stat says. Both are in the same room but the prop is beside a sliding glass door so I can see the difference.

    Dont have an activity bot so I ignored the section on that. Will have to investigate that and do all the tortorials instead of shooting in the dark so to speak. Not much of a programer but pretty good at electronics esp RF testing and measurements.

    Please keep the info coming!
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-01 10:03
    Chris Savage(Parallax) has started a blog that covers networking of XBee modules, but I think that he is doing his thing in Spin.

    I did some testing today on my second sht11 module, which I set up on a PropBOE board. Using the same program settings, the second module had a different reading than the other module, so I am trying to see if I can get a fix on something that will work for both modules and only be maybe a degree apart. Actually the changes or fudge factor should be made to C degree code, because that affects the other readings like F degree. Now I hope Andy sees this thread and joins in just for an explanation as to how he came up with this:
    float sht11_degC(void)
    {
      float soT = (float) sht11_tempRaw();
      float sTC = (((float) soT) * 0.01) - 39.636; 
      return sTC;
    }
    
    float sht11_degF(void)
    {
      float soT = (float) sht11_tempRaw();
      //float sTf = (((float) soT) * 0.018)-39.322;
      float sTf = (((float) soT) * 0.018)-42.922; //44.922 Adjusted to another temp.
      return sTf;
    }
    
    I guess specifically the number data like 0.01 and 39.636, seems to be very precise values.

    I remember seeing, in the Spin code, something about activating or turning on a heater, or something like that, which I do not see in this code. I wonder if that has something to do with improving accuracy and precision of the readings?

    Ray
  • KMyersKMyers Posts: 433
    edited 2013-12-01 12:10
    You can turn on the heater in the Spin side but the docs says not to turn it on for more the 10% of the time. I dont know for sure if this is an accuracy thing or not or for sensor outside.

    I have my spin version running alongside each other running to 2 putty terminals. The C version is more accurate now then my spin version by over 10 degrees. Just dont know what to think it wasnt that far off before. Must be something I did wrong.

    I agree the fudge factor should be in the cent reading.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-02 05:41
    When in doubt read the data sheet!

    On page page 8 - 9, in the Sensirion sht11 data sheet they have all the conversion data needed to come up with the temperature readings. The other important thing that was noted, the Sensirion module does not have a membrane that covers the sensing element. How important that is, not sure yet. Now I have to spend some more quality time with the data sheet.

    The way Andy has the program set up, is that you have to manipulate each data output, Centigrade reading have there own data, as does Fahrenheit, and the others. This is getting somewhat more complicated than I thought, maybe a calibration program will be necessary? More to come...

    Ray
  • KMyersKMyers Posts: 433
    edited 2013-12-02 08:13
    Not sure about the membrane, would think that will change the humidity reading. I also thought all reading were based on the centigrade reading except for the dewpoint and humidity.

    Like wise I will re read the data sheet and take a good nap afterwards. One of the benefits of being old and retired.:lol:
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-02 13:08
    After looking at the Sensirion data sheet, and the sht11.c code, I have come to the conclusion, that for me, the best way to go is to deal with sht11.c and sht11.h as stand alone files, not a library. Because I am getting different readings from the modules that I have, I will have to calibrate each one of the modules, which is easier when sht11.c is not in a library. Since I am familiar as to how to work with Project View, it is not difficult too add those files.

    I think that Andy, at some point, will be releasing an official Parallax sht11 CMM library, which will work for most of the people that decide to use it. Just an early warning, each memory mode has to have a specific library for the mode that they will be using. As I mentioned earlier, jazzed has some very good instructions as to how that is done.

    Ray
  • KMyersKMyers Posts: 433
    edited 2013-12-02 15:01
    Reread it also. Several questions due to my C ignorance. At startup is there a delay before taking first reading? Do we do the checksum?

    Also I use a 4.7k res not the 10k they recomend. Nor do I use the bypass cap.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-02 16:02
    Also I use a 4.7k res not the 10k they recomend. Nor do I use the bypass cap.
    I also use the same as you mentioned which is what is in the document for the Sensirion module download section at the Parallax store. I also remember that the docs for the Spin program that I used also used a 4.7k res.

    Not sure what you are referring to in terms of delay, in the data sheet it mentions that there is a computational delay which has to be handled in your program, if that is what you are talking about.

    Now that I have decided how I am going to use sht11.c/sht11.h, I am now working out a program structure for the next Sensirion project. Definitely going to have an XBee component, use of the SD card, use of the volts program, and probably will be using the XMMC mode for this. This will probably change somewhat after I get the outline on paper.

    Ray
  • KMyersKMyers Posts: 433
    edited 2013-12-03 08:22
    I am glad we have same setup except for pins. I will try a bypass but I doubt it will change things.

    Perhaps noise? Time to pull out the scope and look at signals on both systems. Will look forward to seeing what you come up with. Going to start the tutorials this week so I can follow along and understand better.

    The delay I was talking about was on the start of the sensor before any reading was attempted.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-03 12:03
    I put together a quick and dirty program to test out the sht11 files. I added an XBee IO component so you can use the unit as a remote access device. I also decided for this iteration I was going to use CMM mode, and have the sht11 work out of its own cog. Since I plan to add a CO module, I figure the two modules will have to run in there own cogs, but that could change. Anyway this is a test program.

    Ray
  • KMyersKMyers Posts: 433
    edited 2013-12-03 15:06
    Thanks Ray. will check it out tomorrow if I can get some free time.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-04 05:59
    @jazzed, not sure if you are reading this thread, but I did the auto zip thing, and I noticed that CMM folder is not being added to the zipped file. Not sure if this is an issue or not, but with yesterdays upload I had to add it manually to the zip. The zip thing was done in Simple View.

    I am in the process of expanding the sht11 program, making it a mobile device that will be able to use a time stamp for the logged data. I am not ready to start a thread in the Projects forum with this yet. I will be getting the CO module at some point, has anybody written any C drivers for that module?

    Ray
  • KMyersKMyers Posts: 433
    edited 2013-12-04 11:14
    Ray, compilies fine looks good! Just dont have time to wire in the XB's. Had not got that far in my spin version. So far I like yours better then my spin.

    I retired and still going to meeting and Dr appointments. Dont know how I had time to work 35 years...
Sign In or Register to comment.