MSP430 Launchpad using a SHT15 and a 16×2 LCD Display
As an addition to my previous post Product Road Test: MSP430 Launchpad Value Line Development Kit I decided to try and interface a SHT15 Temperature and humidity sensor to the MSP430 Launchpad. This code change took about 30 minutes and the HW change took about another 30 minutes, see the code at the bottom of this post. The nice thing is I still have six IOs left, I think I might just try to add an SD card next to datalog the temperature and humidity
To see a larger image, click image then click image on the next page (some wordpress thing I have yet to figure out)

I used the SHT15 library for the Arduino library from the website http://www.practicalarduino.com , the library can be downloaded here https://github.com/practicalarduino/SHT1x
Just copy the library to where you have Energia installed, for example my install is on my desktop so here is the path to where I copied the SHT1x library: C:\Documents and Settings\me\Desktop\energia-0101E0008\hardware\msp430\libraries\SHT1x
To see a larger image, click image then click image on the next page (some wordpress thing I have yet to figure out)
The code (consumes 7478 Bytes) is here:
Download the code by clicking here, then click on link on the next page (once again wordpress issue): Demo_code_4
The below code will not paste into the IDE you get carriage returns and other stuff that keeps it from compiling, it is here for you to examine. Thanks to the wonderful posts at www.hobbielektronika.hu website which I had to translate to find the errors.
/*
The circuit:
=================================
LCD pin Connect to
———————————
01 – GND GND, pot
02 – VCC +5V, pot
03 – Contrast Pot wiper
04 – RS Pin8 (P1.4)
05 – R/W GND
06 – EN Pin9 (P1.3)
07 – DB0 GND
08 – DB1 GND
09 – DB2 GND
10 – DB3 GND
11 – DB4 Pin10 (P1.1)
12 – DB5 Pin11 (P1.2)
13 – DB6 Pin12 (P1.6)
14 – DB7 Pin13 (P1.7)
15 – BL+ +5V
16 – BL- GND
=================================
SHT15 SENSOR Connect to
———————————
GND GND
DATA P2_5 then 4.7K to VCC
SCLK P2_4
VCC VCC (should have 0.1uF ceramic to gnd, I did not do this)
=================================
*/
// include the library code:
#include <LiquidCrystal.h>
#include <SHT1x.h>
// Specify data and clock connections and instantiate SHT1x object
#define dataPin P2_5
#define clockPin P2_4
SHT1x sht1x(dataPin, clockPin);
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(P1_4, P1_3, P1_1, P1_2, P1_6, P1_7);
//used in temperature and humidity
float temp_f;
float humidity;
// used in elapsed_time
unsigned long lastSecond = 0;
int secs = 0;
int mins = 0;
int hours = 0;
//end elapsed_time vars
/// end vars
void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
//lcd.print(“F:”);
lcd.print(“F: H:”);
lcd.setCursor(0, 1); // set cursor location on LCD
lcd.print(“Elapsed:”);
}
void loop() {
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// measure SHT15 temperature and humidity then display
temp_f = sht1x.readTemperatureF();
humidity = sht1x.readHumidity();
lcd.setCursor(2, 0);
lcd.print(temp_f);
lcd.setCursor(11, 0);
lcd.print(humidity);
lcd.setCursor(15, 0);
lcd.print(“%”);
/////// end temperature display
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// elapsed time to display
if(millis() – lastSecond >= 2000) ///just in-case something took more than two seconds, should not happen??
{
lastSecond += 2000;
secs++;
secs++;
}
if(millis() – lastSecond >= 1000)
{
lastSecond += 1000;
secs++;
}
if(secs > 59)
{
secs = 0;
mins++;
}
if(mins > 59)
{
mins = 0;
hours++;
}
//place hours in correct position
if( hours <= 9 )
{
lcd.setCursor( 12, 1 );
lcd.print( hours, DEC );
}
else if( hours <= 99 )
{
lcd.setCursor( 11, 1 );
lcd.print( hours, DEC );
}
else if( hours <= 999 )
{
lcd.setCursor( 10, 1 );
lcd.print( hours, DEC );
}
else if( hours <= 9999 )
{
lcd.setCursor( 9, 1 );
lcd.print( hours, DEC );
}
else if( hours <= 99999 )
{
lcd.setCursor( 8, 1 );
lcd.print( hours, DEC );
}
// do minutes
lcd.setCursor( 13, 1 );
lcd.print( “:” );
if( mins <= 9 )
{
lcd.print( “0” );
}
lcd.print( mins, DEC );
///// end of elapsed time
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
}