SHT11 and LCD Appmod
GrantmcF
Posts: 30
I'm new to parallax microcontrollers and having some trouble with my first project. I am trying to get the temp and humidity from the SHT11 to read out on the LCD Appmod #29121. I can get the SHT11 to read out on the debug screen and the sample program to run on the LCD but I am having trouble integrating the two programs. I found programs on the forum doing this but with serial LCDs. I am using a Bs2 with the LCD on output pins 1-7 and the SHT11 clock on pin 0 and data on pin 8. I realize this should be a simple program but I would rather not have to reinvent this if it is already out there. Can anybody point me in the right direction?
Comments
The BS2only program is the Parallax demo code without all of the stuff that makes it work with any Stamp module. I think it's a little easier to understand without that stuff. Of course it'll only work with the BS2 (not the 2px, 2sx, etc.). That original demo program does both the Appmod demo and the conditional compilation to work with other modules, and I think that makes it a bit more complicated than it needs to be.
The attached zip contains my full progression of code with comments for the different versions. The final version (LCD_appmod_SHT11_004.bs2) reads two SHT11s and displays the readings on the LCD Appmod. I started with the LCD Appmod demo code, removed the unneeded demo parts,etc, and merged in the SHT11 tester code from my multiple SHT11 code. The code is for a BS2PX, so there may be some adjustments needed depending on what Stamp you are using.
Lines 193 to 233 contain the loop that cycles through the two sensors to send readings to the LCD. You can leave the code as is to try it out with a single sensor because it will just display bogus values for one sensor. Line 73 contains the pinoffset variable that is used with line 195 to set the data line for the SHT11s. My code uses a pinoffset of 14 which means the data line for the first SHT11 is on P14 and the second sensor data line is on P15. They are both tied to the same clock source, P13.
The code I'm working from is the SHT11_Demo.BS2 and the LCD_AppMod_Demo.BS2. Both are posted in the component description pdf so I won't repost them here. First I imported both programs into one program and made sure there are no conflicts. Both run their own functions fine. I have been trying to figure out where to pick up the final corrected temp and humidity readings, but I can't tell where they are stored. In the main part of the sensor program, I have tried picking off temp at the linearized equation and the same for humidity. I have tried inserting these into the lcd part of the program as data messages where "addr = Msg1", where Msg1 = DEC (tf / 10), ".", Dec1 tf, DegSym. I have also tried assigning the variables tf and rhTrue to the address, where "addr = rhTrue". The next command GOSUB LCD_Put_String seems to be looking for a zero terminated data string. I tried that variation also with no luck.
The big questions I have are where do I pick off the data I want, and how do I get it into the lcd command string to get it displayed? Do I need different commands? Where on the chip are the math functions for temp and humidity being performed and how is the data being stored? Understanding that better would probably help.
So, I doublechecked my code and the only problem seems to be with the use of the LCDOUT command. So, attached is a new program that should work just fine except that the actual readings do not get sent to the LCD because I am uncertain as to the correct way to send the reading. If you look at lines 245-250, you will see my notes. Basically, the [DEC (tF / 10), " ", DEC (rhTrue / 10)] should give you the two values (temp and humidity), so I am thinking that this just needs to be shoved into the "char" variable then out to the LCD_Command routine.
Since I don't have any of my BASIC Stamp stuff accessible at the moment, I can't finish debugging to figure out what is needed to get the readings to the LCD. Plus, since I deal primarily with the Propeller now, my pBASIC has gotten rusty. However, I think if you uncomment lines 248, 249, and 250, it will work. If not, hopefully a Stamp expert can chime in.