Shop OBEX P1 Docs P2 Docs Learn Events
SHT11 and LCD Appmod — Parallax Forums

SHT11 and LCD Appmod

GrantmcFGrantmcF Posts: 30
edited 2010-11-28 01:51 in BASIC Stamp
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

  • FranklinFranklin Posts: 4,747
    edited 2010-11-24 08:36
    If you could show us what you are trying perhaps we can show you where to make changes to your code.
  • sylvie369sylvie369 Posts: 1,622
    edited 2010-11-24 10:35
    If the results are appearing correctly on the debug terminal then your issue is all about using the LCD Appmod. Here (attached) is a program I've used with that device.

    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.
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2010-11-24 16:05
    I have working code that does exactly what you are looking for. I will dig onto my home laptop and find it.
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2010-11-25 00:30
    It took a bit, but I found the code used on my BOE with the LCD APPMOD and two SHT11s. This is my new setup used to test SHT11 modules against a known good reference module. (here is the thread containing my original setup)

    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.
  • GrantmcFGrantmcF Posts: 30
    edited 2010-11-26 02:26
    Andrew, thanks but I'm using a BS2, which is part of the problem. The BS2p versions have prebuilt lcd commands. It seems that with the BS2 you have to build your lcd commands from scratch and even with the examples I've seen, they are not making sense yet.

    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.
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2010-11-28 01:51
    I understand where the problem lies now as I went back to the LCD Appmod demo to just drop in my SHT11 code and leave the bits of code that allow the LCD to work with the BS2 in bus mode. I quickly discovered that I have hardcoded the LCDOUT command which choked when trying to tokenize the program for a BS2. This is where you are stumped.

    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.
    'LCDOUT E, 0, [DEC (tF / 10), "   ", DEC (rhTrue / 10)]  ' original code for BS2PX
    'char = [DEC (tF / 10), "   ", DEC (rhTrue / 10)]        ' what I would think is needed to utilize the "GOSUB LCD_Command" subroutine for the BS2
    '
    ' tF = [DEC (tF / 10), "   ", DEC (rhTrue / 10)]         ' what might work, by using the word tF variable to
    ' char = tF                                        ' store the Temp/Hum values as a text string then to
    ' GOSUB LCD_Command                                      ' the char variable for the LCD_Command subroutine
    
    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.
Sign In or Register to comment.