Temperature Monitor with Voice Alert using Arduino. DIY

Programming, Tutorial, Coding, New Design, and/or any project for your Arduino and Raspberry Pi can post your topic /suggestion here.
User avatar
Location: Philippines
Posts: 197
Joined: Sat Apr 23, 2016 10:32 pm

Temperature Monitor with Voice Alert using Arduino. DIY

Fri Nov 22, 2019 7:07 am

This project is based on Arduino Uno and Processing software for monitoring temperature and sending voice alerts. Processing is an open source IDE that can be used to visualise data and implement other functionalities.

The circuit is built around Arduino Uno board and LM35 temperature sensor. Connect output pin (V0) of LM35 to A0 pin of Arduino board, Vcc pin to 5V pin of the board, and ground pin to common.

Arduino monitors the output pin of temperature sensor LM35 to calculate ambient temperature. Then, it sends the value on the serial port to which it is connected. Processing software receives incoming data from the port and displays it on the graphical user interface (GUI). It also checks the temperature. If temperature is below 40°C, green LED glows. If it is above 40°C, red LED glows and a pre-recorded voice alert is played on the laptop speaker.

The microcontroller (MCU) on Arduino has an inbuilt 10-bit analogue-to-digital converter (ADC). Using its ADC, Arduino monitors the output of LM35 through its analogue pin A0. Program (efy_temp.ino) in Arduino, as given below, performs multiplication and division using certain factors to give actual temperature.temperature=(val×4.88)/10; //multiplication factor to convert the value into temperature

To understand the above relationship, note that ADC on Arduino gets 5V as a reference by default. So, to calculate step size, use the relationship given below.

where n=number of bits

Here, we have a 10-bit ADC on Arduino. So,
Stepsize=5/1024=0.0048828= 4.88mV

Datasheet of LM35 says that, for every 1°C rise, there is an increase of 10mV in output.

Hence, temperature = (val×4.88mV)/10mV

Understanding the GUI
Processing IDE uses Cartesian coordinates. It assumes the top-left corner of the rectangular GUI window as having (0,0) coordinates, and all other coordinates are taken with respect to it. To achieve the desired functionality, two libraries are used, namely, serial and minim.

Minim library comes pre-installed with Processing IDE; it needs to be downloaded and installed as explained in the testing steps section.

Processing code (dee_efy.pde) is used to generate the GUI window. The code within setup() runs once and sets the size of the GUI window and loads the essential dependencies. The code inside draw loop runs repeatedly. serialEvent() function is called every time data comes on the serial port. Processing reads it as string and stores it in a variable named data.

Led() function takes care of the red and green LEDs based on the value of temperature.

The application can also be exported to run as a standalone app for Windows, Mac or Linux platforms by going to File>Export Application. Chose the platform for which you want to export and click OK.

Testing steps
  • Download and install Arduino IDE from website and Processing software from this website.
  • Connect Arduino board with laptop or computer using a USB cable and open Arduino code (efy_temp.ino) using Arduino IDE software. Under Tools, select the board as Arduino/Genuino Uno and correct COM port. Next, compile the code and upload it to Arduino board.
  • Open Processing source code (dee_efy.pde) using Processing software. Add the audio library (minim) in this software for voice alerts. For this, go to Sketch>Import Library…>Add Library…>minim. In filter box, search for minim and click on Install, and wait for a few seconds.
  • Add fonts for your GUI. For this, go to Tools>Create Font, select Arial-black-48 and click OK. Colour codes can be obtained from Tools>Color Selector option.
  • Replace COM12 port number in Processing code with your own COM port number. Check COM port under Windows Device Manager. Save the code before running it. Note that the pre-recorded audio files to be played, colour font file and Arduino code should be inside the data folder on your PC.
  • Run the code and a GUI will open with temperature value
In the GUI, green LED will glow when temperature is below the predefined limit (40°C), and red LED will glow when temperature is above the pre-defined limit along with the voice alert.

Below is the source Code:

Code: Select all

int val;
int tempPin = A0;
float reading,temperature;
void setup()
void loop()
  val = analogRead(tempPin);
  reading= (val*4.88);
  temperature= reading/10;


Code: Select all

// This software is written by Deepankar Maithani. The code is 
// is tested on PROCESSING 3.0 (REV 0246) - 30 September 2015
import ddf.minim.*;// this library handles the audio file playback
import processing.serial.*; // this library handles the serial talk 

Serial myPort;  // Create object from Serial class
String data="" ; // empty string to gather the temperature  values
float ConvertedData=0;
PFont  myFont;  // object from the font class
boolean stateChange=true;
Minim minim; //object from minim class
AudioSample warning; // a name is assigned to the audio sample
AudioSample safe;
void setup()// this runs just once
  size(500, 500); // size of processing window
  background(0);// setting background color to black
  myPort = new Serial(this, "COM12", 9600);// giving parameters to object of serial class,put the com to which your arduino is connected and the baud rate
  myPort.bufferUntil('\n');// gathers data till new line character
  myFont=loadFont("Arial-Black-48.vlw");// font type see the data folder of your sketch
  textFont(myFont, 70);// font size
  minim = new Minim(this); //we pass this to Minim so that it can load files from the data directory
  ////////////////audio samples////////////////////////
  warning = minim.loadSample("tempWar.mp3");// A .mp3 file is loaded to the audiosample named warning
  safe=minim.loadSample("tempSafe.mp3"); // A .mp3 file is loaded to the audiosample named safe
void draw()
  background(0);//refreshing background everytime the draw runs
  noStroke();// disable drawing the outline of text
  textAlign(CENTER);// align text to the centre of coordinates
  fill(255);// fill white color to text
  text(data, 410, 155);// display the data at 350,155 coordinate
  textSize(40); // size of text
  fill(#4B5DCE);// fillin blue color on the text 
  text("Temp. Reading", 180, 150);// write text "Temp. Reading" at the coordinates 180,150
  noFill();//the upcoming rect will not have anything inside
  stroke(#4B5DCE);// color of border of rectangle
  rect(5, 100, 470, 80); //rectangle
void serialEvent(Serial myPort)// whenever serial event happens it runs

  data=myPort.readStringUntil('\n'); //gathering data from pot in a variable
  ConvertedData=parseFloat(data);// converting string into float
void Led()
  strokeWeight(5);// thickness of outline
  stroke(255);// white color outline around LED
  fill(#67F50A); //
  ellipse(180, 240, 55, 55);// green LED
  ellipse(280, 240, 55, 55); // Red LED

  if (ConvertedData>40)
    fill(#AED691);// green dull
    ellipse(180, 240, 55, 55);
    fill(#FC0004);// red bright
    ellipse(280, 240, 55, 55);
    if (stateChange==true)
      println("Warning is given out");// for debugging
  if (ConvertedData<40)
    fill(#67F50A);// green bright
    ellipse(180, 240, 55, 55);
    fill(#CE6668);// red dull
    ellipse(280, 240, 55, 55);
    if (stateChange==false)
      println("it is safe now");// for debugging
Monitor temperature with voice alerts.zip
(211.59 KiB) Downloaded 216 times



In total there are 29 users online :: 0 registered, 0 hidden and 29 guests
Registered users: No registered users
Most users ever online was 364 on Wed Jan 22, 2020 8:31 pm
Total posts 546
Total topics 424
Total members 73
Our newest member Kelly
No birthdays today