Digital Thermometer with an OLED

Design Challenge

Digital Thermometer with the chipKIT™ Basic I/O Shield™

Introduction

For this deisgn challenge, we will be setting up our own digital thermometer and displaying the temperature on a LCD screen. For more information about the concepts behind an LCD screen or a refresher on thermistors, feel free to refer to the links on the right.

Before you begin, you should:
  • Know how to use a thermistor.
  • Be familiar with using an LCD screen.
After you're done, you should:
  • Be able to show off your thermometer in high resolution.

Inventory:

Qty Description Typical Image Schematic Symbol Breadboard Image
1 NTC Thermistor
1 10 kΩ Resistor
1 Basic I/O Shield

Basic Theory

As you know, we will be calculating the temperature from an analog reading from the thermistor. We will then display our calculated temperature on the LCD screen in a much fancier fashion than the seven-segment display.

Step 1: Wiring

Wiring of the 10kOhm thermistor:

The chipKIT™ Basic I/O Shield™ has the same form factor as the chipKIT Uno32™, so it will fit directly on top of the Uno32. For our project, all of the pins that we used on the Uno32 will be in the same place as they are on the Basic I/O Shield.

However, if you wanted to use any of the digital pins on the Basic I/O Shield, be aware that many of them are inherently tied to various components on the shield. Only the PWM pins, 3, 5, 6, and 9 will be able to connect to a breadboard without interferring with any of the components on the shield. Check out the link on the right for more information about the digital pins on the Basic I/O Shield.

    Figure 1. Breadboard setup of the thermistor.
  • Place the thermistor somewhere on the breadboard. Using a 10 kΩ resistor, connect one of the leads to the power bus strip.
  • Connect the power bus to the 3.3V supply on the chipKIT Uno32 board, which is labeled as “3V3”.
  • Attach the other lead of the thermistor to the negative bus on the breadboard. Connect this bus to either one of the ground pins on the chipKIT Uno32, which are both labeled as “GND”.
  • Now, run a wire from the leg of the thermistor that has the 10 kΩ resistor to pin A0 on the chipKIT Uno32.

Determining the Temperature

Since this is a design challenge, you should be able to derive the equation that will be used in the code to determine the temperature from the equations for the output voltage of the termistor, the equation for the analog-to-digital (ADC) value of the Uno32, and the B parameter equation for the temperature, where the B value is 4100 for our thermistor:

For reference, here is the final equation that you should end up with:

Remember that the temperature is still in the Kelvin scale and that it will need to be corrected to the Fahrenheit or Celsius temperature scale, if you so desire.

Step 2: Write some code

We should be able to write the code that we need in order display each digit of the temperature on the LCD screen one at a time. What we will go over is how to create a new character that we want to show, like a degree symbol. We will create a message that says “I (heart) chipKIT”.

What we need to do, in essence, is to create a so-called font library where we will define what pixels are to be displayed for each new character. Each character will consist of eight bytes representing the eight columns (with eight rows each) to define all 64 pixels available for the character space.

//Including the needed library
#include 

//Some necessary definitions of how big our glyphs and font library are
#define OledChar      8                //number of bytes in a glyph
#define OledUserFont  (32*OledChar)  //number of bytes in user font table

//The Library in Hexidecimal where the first number after the “0x”
//defines the bottom four pixels and the second number defines the
//top four pixels of that particular column
uint8_t UserFont[OledUserFont] = {
	0x00, 0x0C, 0x1E, 0x3C, 0x78, 0x3C, 0x1E, 0x0C	// 0x00
    };
    //note that we only used 1 of these 32 byte sets
        
//global variable
char heart=0x00;

void setup(){
  IOShieldOled.begin();
  IOShieldOled.defineUserChar(heart, &UserFont[heart*OledChar]);
}//end of setup

void loop(){
  
  IOShieldOled.clearBuffer();
  
  IOShieldOled.setCursor(7,1);
  IOShieldOled.putString("I");
  IOShieldOled.setCursor(7,2);
  IOShieldOled.putChar(heart);
  IOShieldOled.setCursor(4,3);
  IOShieldOled.putString("chipKIT");
  IOShieldOled.updateDisplay();

  delay(500);
}//end of loop

  • Other product and company names mentioned herein are trademarks or trade names of their respective companies. © 2014 Digilent Inc. All rights reserved.
  • Circuit and breadboard images were created using Fritzing.