Introduction: Easy, Mobile IR Thermometer

This thermometer is an easy-to-build thermometer that relies on IR blackbody radiation to determine your temperature

Step 1: Determine Specifications, Requirements and Overall Goals

Goal:

The goal of this circuit design is to create a device capable of measuring a person's body temperature based off of infrared readings of their blackbody radiation. This device will be sufficient to act as mobile device, making it wearable by the user. This requires that all circuit components and any software components be on-board.

Requirements:

  • lightweight, small, and mobile
  • capable of measuring IR at tympanic (body) temperatures
  • capable of filtering extraneous noice
  • able to amplify signal to produce sufficient signal to noise ratio

Specifications:

  • measure in the range 95 to 103 degress F effectively and accurately
  • Low pass filter with a cutoff frequency around 25Hz (this will help eliminate non-body signals)
  • 17 bit ADC (measurement reolution of 0.02 degrees C over the -40 to 125 degrees C range)
  • Optical filter (5.5 to 14 micrometer bandpass)

These goals show us exactly what we want to get out of our final product. The requirements hone in on exactly how we will accomplish that. The specifications provide the details necessary to build the device.

Step 2: Acquire Necessary Parts

To make this IR thermometer, there are a couple parts you will need:

  • Arduino Uno, Arduino IDE (available online for free) and respective cords
  • SparkFun MicroSD Shield for Arduino Uno
  • LinkSprite LCD Shield for Arduino Uno
  • Small 2in x 2in printed circuit board
  • Melexis MLX90614 Infrared Thermometer
  • 100 microFarad Capacitor
  • 2 x 4700 microFarad Resistors
  • Solder & soldering iron
  • Plenty of wire that can be stripped, soldered, and cut (relative flexibility of the wire is useful)
  • Cheap over-ear headphones that have earpieces that can easily be hollowed out
  • 9V battery & connector to Arduino Uno
  • microSD card (and SD card adapter if your computer cannot directly interface with the microSD)

Parts are pictured.

Step 3: Design Circuit Capable of Acquiring Data

Before anything can be done with the Arduino, you need to design a circuit that will acquire the data for you. Of course, the MLX90614 will do most of the heavy lifting for the hardware of this project, but there are other parts necessary.

Our system of data acquisition relies on using I2C communication, so we have designed our circuit as such. I2C is a method of communication that allows us to dictate how exactly we acquire our data. I2C uses a master/slave companionship which we determined to be incredibly efficient with communication.I2C is a digital form of communication. Luckily, the MLX90614 has an on-board ADC that we can use to digitize our data.

The circuit necessary for data acquisition uses a printed circuit board, two 4700 ohm resistors, a 100 microFarad capacitor, the MLX90614, and some wire.

The MLX90614 serves as the signal transducer. It measures the IR radiation. the MLX90614 also has many on-board filters as well as an ADC. This allows the signal coming out of the MLX90614 to be appropriate for I2C communication. The resistors in this circuit help to scale the information given to the Arduino appropriately. In other words, they allow some flexibility for calibration. The capacitor serves as the final filter in this circuit. It eliminates unwanted IR noise from the signal.

With this understanding, you can see why the circuit pictured was used. Solder this circuit to a printed circuit board. Whatever arrangement you find best should work so long as it is clean and has wires soldered to it that can interact with the Arduino later.

Step 4: Code the Arduino for Calibration and Temp Readout

The Arduino is the bread and butter of this whole device in that it does the bulk of the work associated with this project. Programming the Arduino can be done easily by borrowing some of Adafruit's code found on GitHub (https://github.com/adafruit/Adafruit-MLX90614-Library).

This code does several things. First, it establishes the slave/master relationship necessary for I2C communication. Second, it creates an "mlx" class that makes accessing the slave object, in this case the MLX90614, incredibly easy. Third, it provides convenient definitions that come in handy while doing programming necessary for your project.

This code is a library created by Adafruit. To use it, download a .zip file containing .cpp, .h, and .ino files. Transfer this .zip folder into your Arduino library by doing the following:

  1. Open windows explorer (or finder if you are using a Mac).
  2. Locate your Program Files folder in your C: drive
  3. In the Program Files folder, locate the Arduino folder
  4. In the Arduino folder, locate the Libraries folder.
  5. Paste the .zip file into the Libraries folder.

Now, you can open up your Arduino IDE and access the example code associated with this library by going File -> Examples -> Libraries -> Adafruit MLX90614.

Upon opening this example code, there are many things that should be noted. First, the examples code includes two libraries: Wire.h and AdafruitMLX90614.h. The first library allows for I2C communication while the second helps establish the MLX90614 as an object.

With your Arduino connected to your circuit, you can run a quick test and see exactly what the code produces. You should notice a relatively accurate temperature reading if you open the Serial monitor. If you feel like your circuit is producing an inaccurate temperature reading, go into the .cpp file associated with this library. In this document you will see the readTemp method. The code in this method allows us to calibrate the output associated with the temperature reading. Based on the output you are seeing, modify this code as needed to ensure appropriate output.

We recommend adding a delay to the output of the Arduino of about 1s. This just allows data to be output at a rate that is usable (otherwise, there is an overwhelming amount of data generated).

You now have a working thermometer! Because there is no recording mechanism or even display, we need to add more functionality.

Step 5: Add the MicroSD Shield

To record data long-term, the microSD shield should be added to the Arduino. Take your SparkFun microSD shield and attach it to the Arduino. To make the shield functional, a few lines of code must be added to your .ino file (add to the example code mentioned earlier):

  1. Include the SPI.h and SD.h libraries. These allow us to access all the methods associated with SD card use.
  2. Select a pin that will interact with the SD shield and give it global variable declaration, chipSelect. Our code uses pin 8 as the pin of interest, so this would look like: const int chipSelect = 8; Put this variable outside both the setup and loop functions.
  3. In the Setup function, call the SD.begin function, using chipSelect as your input into the function. This will get your SD card running and ready for use in the loop function. We recommend calling this function in an if-statement in case the initialization of the SD card fails. That way, the user can be notified if this occurs.
  4. To write to the SD card, add the code "File dataFile = SD.open("datalog.txt", FILE_WRITE);" to your loop function.
  5. Immediately after add an if-statement to determine if datalog was successfully opened (ex: "if(datafile)"). Should this statement be confirmed (i.e. datalog was successfully opened), you can write into the datafile using the print methods.
  6. When you are done writing, make sure to close the datafile using the close method.

Using this code, you should be able to write to the microSD. Using the SD card adapter, you can connect the microSD card to you computer and read the "datalog.txt" file to see exactly what your temperature is long-term.

Step 6: Add the LCD Shield

The LCD shield is incredibly useful for real-time output. This ensures that you can check your temperature while not needing to be hooked up to the Serial monitor or have to take out the microSD every time you wish to view temperatures.

Attach the LCD shield to the microSD shield. In this manner, you should create a sandwich of three connected board. On bottom, the Arduino. In the middle, the microSD shield. On top, the LCD shield.

The remainder of LCD installation is all coding:

  1. Include the LiquidCrystal.h library
  2. Specify the pins you will use to interact with the shield. Ex: "LiquidCrystal lcd(8, 9, 4, 5, 6, 7);"
  3. In the setup method, establish the LCD's number of columns and rows using the lcd.begin function. We used 16 columns and 2 rows.
  4. In the loop method, print the temperature using the associated mlx methods. With this output, you can eliminate the Serial.print commands associated. It is essential that the loop function uses a delay function so that the loop does not run so fast that it doesn't overwhelm the LCD shield with its incredibly rapid.

From here, the LCD shield should be functional. You can customize your output as you see fit to make the LCD shield most useful for you.

Step 7: Customize Your Code!

We added a little extra to our code by using the LCD's buttons. With this, we were able to switch between C and F readouts, provide a 10s average, and provide a small motivational message.

You can use these buttons however you see fit, but to access them and use them do the following:

  1. read in the values of the button presses by using analogRead function. Be sure to specify the pin you will be reading from. We used A0.
  2. Use the Serial.print methods to find out the integer produced from the analogRead function associated with each button. Each button produces a different integer, so you should be able to determine what button is being pushed depending on the integer value produced.
  3. Once you have established these values, you can create global variables that record each value based what you found earlier.
  4. In your loop function, establish if-statements that determine the if a button is being pushed, and if so, which one. In these if-statements, you can perform different operations to do fun stuff with the device.

We were able to do some fun stuff with the buttons, so make sure to use them as you see fit!

Step 8: Make the Device Mobile

Making the device mobile is relatively easy and is the least sophisticated part of the device. Obviously, you will need to disconnect the Arduino from your computer, so you can go ahead and attach it to the 9V battery. To make the device wearbale, take some over-ear headphones (make sure they are cheap because you are about to destroy them). Hollow out one ear piece. Place your completed circuit on the printed circuit board in this ear piece. You can then reconnect the circuit to the Arduino.

You now have a working, wearable IR thermometer!