Introduction: LCD Thermo-Meter Project Using TI MSP-EXP430FR5739 FraunchPad

This was created using Energia.

Mainly for my use as a practical device for learning to program microcontrollers. This is how far I've made it after reviewing the tips from this thread - thanks 43oh.com guys.

I would like to add some form of wireless communication to another microcontroller, one device transmitting the data to another device hosting the LCD. I have not decided if it will be infrared or radio frequency (I do have a CC110L set).

This is a working unit at this time. I am not sure I have optimized this very well. I am also not sure if I should have used 'float' as the variable type.

Any and all comments, suggestions, or advice are very much welcome. Thank you.

Step 1: THE CODE

/*

March 02 2013
Based on an Arduino project by DJ Mentzik.
Enhanced and modified by WWC.
Further enhanced by Vic Velcro.
Converted from Arduino to MSPEXP430FR5739 (FraunchPad) by Vic Velcro.
http://www.vicstricks.com/forum/viewforum.php?f=16

Use and modify as needed.

Displays current temperature from 8 sample average in C and F, Max in C, and Min in C.

To wire your HP44780 based LCD screen to your FraunchPad, connect the following pins:
LCD Pin 4 to digital pin 3 or P2_5
LCD Pin 6 to digital pin 4 or P2_6
LCD Pin 11 to digital pin 20 or P1_3
LCD Pin 12 to digital pin 15 or P1_2
LCD Pin 13 to digital pin 14 or P1_1
LCD Pin 14 to digital pin 13 or P1_0
Additionally, wire a 10K pot to +5V and GND, with it's wiper (output) to LCD screen's VO pin (pin3) to adjust contrast of characters.
To drive the backlighting, wire a 270 ohm resistor from FraunchPad VCC to LCD pin 15.

The temperature sensor is an LM335Z. The (adj) leg is not used for this project. Locate a datasheet if you are not familiar with device.
While pins are in breadboard and flat side is away from you, the left leg is grounded and the right leg is un-used.
The center leg is connected to pin A0 which is also marked P1_5. Additionally, the center pin connects to a resistor of 2.2k ohms and then
the opposite leg of the resistor goes to VCC of the FraunchPad.

*/

#if defined(__MSP430FR5739__)                                   // FraunchPad !ONLY!
#include "Energia.h"
#else                                                           // no good
#error Unsupported Platform. Only FraunchPad.
#endif

#include <LiquidCrystal.h>                                      // include the LCD driver library

int tempPin = A0;                                               // Declaring the Analog input to be 0 (A0) of FraunchPad board.
int i;                                                          //variable to delineate sample iteration sequence

float VCC=3.63;                                                 //declare board voltage
float tempRAW;                                                  //declare variables
float tempK;                                                    //variable for holding Kelvin temp (floating for decimal precision
float tempC = 0;                                                // variable for holding Celcius temp (floating for decimal precision)
float tempF = 0;                                                // variable for holding Fahrenheit temp
float samples[8];                                               // Array to hold 8 samples for Average temp calculation
float maxi = 0,mini = 100;                                      // Max/Min temperature variables with initial values. LM335 in simple setup only measures Temp above 0.
                                             
LiquidCrystal lcd(P2_5, P2_6, P1_3, P1_2, P1_1, P1_0);          // initialize the library with the numbers of the interface pins

void setup()
{
Serial.begin(9600);                                             // Opens serial port, sets data rate to 9600 bps
lcd.begin(16, 2);                                               // Set up the LCD's number of columns and rows:

Serial.println("");                                             // Blank line for spacing in the serial monitor
Serial.println("Thermo-Meter project by Vic Velcro.");           // Print text to Serial monitor
Serial.print("Free to modify and use as needed.");
Serial.println("");                                             // Blank line for spacing in the serial monitor

lcd.clear();
lcd.setCursor(2, 0);                                            // Set LCD cursor position (column, row)
lcd.print("Vic's Tricks");                                      // Print text to LCD
lcd.setCursor(2, 1);                                            // Set LCD cursor position (column,row) 
lcd.print("Thermo-Meter");                                      // Print text to LCD
delay(10000);                                                   // Delay to read text

lcd.clear();
lcd.setCursor(1, 0);                                            // Set LCD cursor position (column, row)
lcd.print("* On The Web *");                                    // Print text to LCD
lcd.setCursor(1, 1);                                            // Set LCD cursor position (column,row) 
lcd.print("vicstricks.com");                                    // Print text to LCD
delay(10000);                                                   // Delay to read text

lcd.clear(); // clear LCD display                               // Clear the display
lcd.setCursor(1, 0);                                            // Set LCD cursor position (column, row)
lcd.print(" Average Temp ");                                    // Print text to LCD
lcd.setCursor(1, 1);                                            // Set LCD cursor position (column, row) 
lcd.print("  Displayed  ");                                     // Print text to LCD
delay(5000);                                                    // Delay to read text
lcd.clear();                                                    // Clear LCD

}

void loop()
{
Serial.println("");                                             // Blank line for spacing in the serial monitor
Serial.print("LM335Z Raw data: ");                              // Print text to Serial monitor 
Serial.println(analogRead(tempPin));                            // Displays on serial monitor the sampled value before conversion to real Temperature reading
Serial.println("");                                             // Blank line for spacing in the serial monitor

                                                                // Start of calculations FOR loop.
for(i = 0;i<=7;i++){                                            // gets 8 samples of temperature
samples[i] = analogRead(tempPin);                               // conversion math of LM335 sample to readable temperature Kelvin and stores result to samples array. 

                                                                // 5v is normal supply volts of LM335. Change appropriatelly to have correct measurement. My case is 3.63 Volts.
                                                                // If powered from USB then use value 3.6v.
                                                                // The voltage is critical for accurate readings
Serial.println(samples[i]);                                     // Print samples [i] to serial monitor                                            
                                                                                                                        
                                                                // LCD note: line 1 is the second row, since counting begins with
lcd.clear(); // clear LCD display                               // Clear the display
lcd.setCursor(0, 0);                                            // Set LCD cursor position (column 0, row 0)
lcd.print("Current Reading: ");                                 // Print text to LCD
lcd.setCursor(0, 1);                                            // Set LCD cursor position (column 1, row 1)
lcd.print("RAW SAMPLES");                                         // Print text to LCD
lcd.setCursor(12, 1);                                           // Set LCD cursor position (column 12, row 1)
lcd.print(samples[i]);                                          // print current RAW sample iteration to LCD
tempRAW = tempRAW + samples[i];                                 // calculate for RAW samples average
delay(800);                                                     // wait a bit

}                                                               // END of FOR loop

Serial.println("");                                             // Blank line for spacing in the serial monitor
Serial.println("");                                             // Blank line for spacing in the serial monitor
tempK = ((((tempRAW/8.0)/1023)*VCC)*100);                       // Conversion formula for combined samples to Averaged Kelvin

tempC = (tempK-273.15);                                         // Convert Kelvin to Celcius
tempF = (((tempK-273.15) * 1.8) + 32);                          // Convert Kelvin to Fahrenheit

if(tempC > maxi) {maxi = tempC;}                                // update max temperature observed
if(tempC < mini) {mini = tempC;}                                // update min temperature observed

Serial.println("New measurement:");
Serial.print(" Average Temperature in Celcius is " );           // Print text to Serial monitor
Serial.println(tempC);//send the data to the computer           // Send the data to the computer
Serial.print(" Average Temperature in Fahrenheit is " );        // Print text to Serial monitor
Serial.println(tempF);//send the data to the computer           // Send the data to the computer
Serial.print(" MAX Temperature in Celcius is " );               // Print text to Serial monitor
Serial.println(maxi);//send the data to the computer            // Send the data to the computer
Serial.print(" MIN Temperature in Celcius is " );               // Print text to Serial monitor
Serial.println(mini);//send the data to the computer            // Send the data to the computer

lcd.clear();                                                    // Clear the display
lcd.setCursor(0, 0);                                            // Set LCD cursor position (column 0, row 0)
lcd.print("Celcius    ");                                       // Print text to LCD
lcd.setCursor(12, 0);                                           // Set LCD cursor position (column 12, line 0)
lcd.print(tempC);
lcd.setCursor(0, 1);                                            // Set LCD cursor position (column 0, line 1)
lcd.print("Fahrenheit ");                                       // Print text to LCD
lcd.setCursor(12, 1);                                           // Set LCD cursor position (column 12, line 1)
lcd.print(tempF);                                               // Send the data to the LCD
delay(5000);                                                    // Wait after temp display to LCD screen befor starting the loop again.

tempRAW = 0;                                                    // Set tempRAW to 0 before repeating the loop.
}

Comments

About This Instructable

1,886views

3favorites

License:

Bio: Semi-Retired Professional Adventurer. I am a nosey person. I Don't infringe on personal privacy, but I like more answers and less questions. If I ... More »
More by vicvelcro:Raspberry Pi and ZenMINER Heatsink and FanAcoustic-Electric Wooden StompBox with Piezo PickUpLCD Thermo-Meter Project using TI MSP-EXP430FR5739 FraunchPad
Add instructable to: