Arduino Digital Thermometer using MAX30205 Temperature Sensor

Source and original idea from Circuit Digest.

Your body temperature is an important indicator of your overall health. If you are looking for an accurate thermometer that costs less, you will find this tutorial helpful. Here, we will build DIY Arduino digital thermometer using MAX30205 temperature sensor.

After this tutorial, you will be able to record temperature on a 7-segment display, measured in Fahrenheit. Once built, the sensor will easily integrate with several devices. You can get creative and choose to interface it with any application you want.

Step 1: Gather all the components

For this project, you’ll need:

Step 2: Connect Arduino with MAX30205

See the complete circuit diagram for connecting the two components below.

The diagram looks a bit complicated as this project uses a 7-segment display. You could use OLED or LCD too but 7-segment displays offer a low-cost way to get the values to look big and bright.

Three 74HC595 connect the Arduino Nano. The three 74HC595 are kept together so there are more output pins (from Arduino) for 7-segment displays. The MAX30205 board communicates with the 12C protocol and hence requires more than one pull-up resistor.

However, keep in mind that some boards come with additional pull-up resistors and hence do not require any more. So, before you start to put the components together, find out whether the board requires external pull-up resistors. The board used for this project already has internal pull-up resistors.

Step 3: Interface Arduino with MAX30205

The sensor used in this project is from Maxim integrated. It measures with 0.1 degrees C accuracy (37 to 39 degree C). Also, the module board comes with a logic level shifter.

On the output side, three 74HC595, 8-shift registers have been used to interface the 7-segment display with the Arduino. See the following pin diagram for better understanding.

Pin description for interfacing the components

⦁ Pin numbers 1,2,3,4,5,6,7,15 are represented by symbols QA and QH. These function as data outputs.

⦁ Pin number 9 is represented by the symbol QH. This pin functions as serial data output.

⦁ Pin number 10 is represented by the symbol SCLR. It functions as the shift register clear input.

⦁ Pin number 11 is represented by SCK. It functions as a shift register clock input.

⦁ Pin number 13 is represented by the symbol G. It functions as an output enable input.

⦁ Pin number 14 is represented by symbol SI and functions as serial data input.

⦁ Pin number 12 is represented by the symbol RCK and functions as storage register clock input.

⦁ Pin number 8 is represented by the symbol GND and functions as Ground.

⦁ Pin number 16 is represented by VCC and functions as a positive supply voltage.

QA and QH (the data output pins) are connected to the 7-segment displays. Pin 14 (the data input pin) of the 1st shift register is connected to the Arduino Nano and the QH (serial data output) pin provides data to the other shift registers. You will continue serial data connections till the 3rd 74HC595.

Step 4: Program MAX30205 with Arduino

To program the temperature sensor with Arduino, follow the following steps:

Add the Standard 12C library Arduino header file as shown below:

#include <Wire.h>

You can find the above library here. It offers some important functions to facilitate communication with the temperature sensor.

Next, define the temperature sensor’s object data. See the code below:

#include "Protocentral_MAX30205.h" 
MAX30205 tempSensor;

Define the parameters. The following code will provide temperature data as Fahrenheit is set as ‘true’. To see the results in Celsius, the code needs to be set as ‘false’.

const bool fahrenheittemp = true; // I'm showing the temperature in Fahrenheit, If you want to show the temperature in Celsius the make this variable false.

Change the following code to ‘false’ if the common anode is being used. The code will remain ‘true’ if you are using the common Cathode 7-segment, which we are using for this project.

See the code below;

const bool commonCathode = true; // I'm using common Cathode 7segment if you use common Anode then change the value into false.
const byte digit_pattern[17] =
{
  // 74HC595 Outpin Connection with 7segment display.
  // Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7
  // a  b  c  d  e  f  g  DP
  0b11111100,  // 0
  0b01100000,  // 1
  0b11011010,  // 2
  0b11110010,  // 3
  0b01100110,  // 4
  0b10110110,  // 5
  0b10111110,  // 6
  0b11100000,  // 7
  0b11111110,  // 8
  0b11110110,  // 9
  0b11101110,  // A
  0b00111110,  // b
  0b00011010,  // C
  0b01111010,  // d
  0b10011110,  // E
  0b10001110,  // F
  0b00000001   // .
};

Next, set up the pin modes of 74HC595 pins. After you are done with it, initialize the temperature sensor reading and 12C protocol in the setup function as shown below.

void setup() {
  // put your setup code here, to run once:
  // set the serial port at 9600
  Serial.begin(9600);
  delay(1000);
  // set the 74HC595 Control pin as output
  pinMode(latchPin, OUTPUT);    //ST_CP of 74HC595
  pinMode(clkPin, OUTPUT);      //SH_CP of 74HC595
  pinMode(dtPin, OUTPUT);       //DS of 74HC595
  // initialize I2C Libs
  Wire.begin();
  // start MAX30205 temperature read in continuos mode, active mode
  tempSensor.begin();  
}

The temp sensor.temperature() function reads the temperature in the loop. It is stored in the variable labeled ‘temp’.

If you select Fahrenheit mode, then the temperature data will be converted from Celsius to Fahrenheit. Next, you will convert the three digits from the temperature data into further individual digits. See the code below:

// saperate 3 digits from the current temperature (like if temp = 31.23c, )
  int dispDigit1=(int)temp/10;      // digit1 3
  int dispDigit2=(int)temp%10;      // digit2 1
  int dispDigit3=(temp*10)-((int)temp*10);  //digit3 2

Next, the individual digits are transmitted to the 7-segment display through 74HC595 shift registers. We’ll transmit the first digit first as the LSB first appeared into the third-segment through the third 74HC595.

To set the third digit for transmission, pull the latched pin low and submit data to the 74HC595 THROUGH SHIFToUT() FUNCTION.

Similarly, the other digits are set up for transmission. After all the data has been transmitted, set the latch pin to release (HIGH) to end the transmission See the code below:

// display digits into 3, 7segment display.
  digitalWrite(latchPin, LOW);
  if(commonCathode == true){
    shiftOut(dtPin, clkPin, LSBFIRST, digit_pattern[dispDigit3]);
    shiftOut(dtPin, clkPin, LSBFIRST, digit_pattern[dispDigit2]|digit_pattern[16]);   // 1. (Digit+DP)
    shiftOut(dtPin, clkPin, LSBFIRST, digit_pattern[dispDigit1]);
  }else{
    shiftOut(dtPin, clkPin, LSBFIRST, ~(digit_pattern[dispDigit3]));
    shiftOut(dtPin, clkPin, LSBFIRST, ~(digit_pattern[dispDigit2]|digit_pattern[16]));   // 1. (Digit+DP)
    shiftOut(dtPin, clkPin, LSBFIRST, ~(digit_pattern[dispDigit1]));
  }
  digitalWrite(latchPin, HIGH);

Step 5: Test the DIY Arduino digital thermometer

Your final apparatus should look something like this:

There are two sets of breadboards as shown in the image. When you’ll place one finger on the sensor, the temperature will be shown on the 7-segment display.

Here’s the complete code for the project:

/*
 * This program Print temperature on 3, 7segment display
 * Hardware Connections (Breakoutboard to Arduino Nano):
 * Vin  - 5V (3.3V is allowed)
 * GND - GND
 * MAX30205 SDA - A4
 * MAX30205 SCL - A5
 * 74HC595 ST_CP - D5
 * 74HC595 SH_CP - D6
 * 74HC595 DS - D7
 * 
 */
#include <Wire.h>
#include "Protocentral_MAX30205.h" // Arduino Contributed Libs (https://github.com/protocentral/ProtoCentral_MAX30205)
// define MAX30205 objectData
MAX30205 tempSensor;
// Show the temperature in Fahrenheit 
const bool fahrenheittemp = true; // I'm showing the temperature in Fahrenheit, If you want to show the temperature in Celsius then make this variable false.
// set the 7segment type (common Cathode or Anode)
const bool commonCathode = true; // I'm using common Cathode 7segment if you use common Anode then change the value into false.
// alpha-digit pattern for a 7-segment display
const byte digit_pattern[17] =
{
  // 74HC595 Output Connection with 7segment display.
  // Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7
  // a  b  c  d  e  f  g  DP
  0b11111100,  // 0
  0b01100000,  // 1
  0b11011010,  // 2
  0b11110010,  // 3
  0b01100110,  // 4
  0b10110110,  // 5
  0b10111110,  // 6
  0b11100000,  // 7
  0b11111110,  // 8
  0b11110110,  // 9
  0b11101110,  // A
  0b00111110,  // b
  0b00011010,  // C
  0b01111010,  // d
  0b10011110,  // E
  0b10001110,  // F
  0b00000001   // .
};
//Pin connected to ST_CP of 74HC595
int latchPin = 5;
//Pin connected to SH_CP of 74HC595
int clkPin = 6;
//Pin connected to DS of 74HC595
int dtPin = 7;
void setup() {
  // put your setup code here, to run once:
  // set the serial port at 9600
  Serial.begin(9600);
  delay(1000); 
  // set the 74HC595 Control pin as output
  pinMode(latchPin, OUTPUT);    //ST_CP of 74HC595
  pinMode(clkPin, OUTPUT);      //SH_CP of 74HC595
  pinMode(dtPin, OUTPUT);       //DS of 74HC595
  // initialize I2C Libs 
  Wire.begin();
  // start MAX30205 temperature read in continuous mode, active mode
  tempSensor.begin();   
}
void loop() {
  float temp = tempSensor.getTemperature(); // read temperature for every 5ms
  if( fahrenheittemp == true){
    temp = (temp * 1.8) + 32 ; // convert the temperature from Celcius to Farenhite using formula of [ T(°C) × 1.8 + 32 ]
    Serial.print(temp ,2);
    Serial.println("°f" );
  }else{
    Serial.print(temp ,2);
    Serial.println("°c" );
  }
  // saperate 3 digits from the current temperature (like if temp = 31.23c, )
  int dispDigit1=(int)temp/10;      // digit1 3
  int dispDigit2=(int)temp%10;      // digit2 1
  int dispDigit3=(temp*10)-((int)temp*10);  //digit3 2
/*
  Serial.print(temp);
  Serial.print(" ");
  Serial.print(dispDigit1);
  Serial.print(" ");
  Serial.print(dispDigit2);
  Serial.print(" ");
  Serial.println(dispDigit3);
*/
  // display digits into 3, 7segment display.
  digitalWrite(latchPin, LOW);
  if(commonCathode == true){
    shiftOut(dtPin, clkPin, LSBFIRST, digit_pattern[dispDigit3]);
    shiftOut(dtPin, clkPin, LSBFIRST, digit_pattern[dispDigit2]|digit_pattern[16]);   // 1. (Digit+DP)
    shiftOut(dtPin, clkPin, LSBFIRST, digit_pattern[dispDigit1]);
  }else{
    shiftOut(dtPin, clkPin, LSBFIRST, ~(digit_pattern[dispDigit3]));
    shiftOut(dtPin, clkPin, LSBFIRST, ~(digit_pattern[dispDigit2]|digit_pattern[16]));   // 1. (Digit+DP)
    shiftOut(dtPin, clkPin, LSBFIRST, ~(digit_pattern[dispDigit1]));
  }
  digitalWrite(latchPin, HIGH);
  delay(500);
}

Get started with your Arduino Nano here.

We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: