Project tutorial
Visualising sensor data using Arduino and Processing

Visualising sensor data using Arduino and Processing © GPL3+

The project is a beginner guide to interface sensors to Arduino and visualise sensor data through Processing

  • 44,430 views
  • 3 comments
  • 41 respects

Components and supplies

About this project

In this Project, we first see how to interface a temperature sensor to an arduino. Later we would send this sensor data to PC via serial and visualise the data in a software called Processing.

Now make your own temperature sensor by Arduino and LM35 Sensor
You require the  following parts:

  • 1-ARDUINO BOARD ANY VERSION
  • 2-LM35 TEMPERATURE SENSOR
  • 3-USB CABLE
  • 4-COMPUTER WITH ARDUINO SOFTWARE

Few points on LM35

  • Calibrated Directly in Celsius (Centigrade)
  • Linear + 10-mV/°C Scale Factor
  • 0.5°C Ensured Accuracy (at 25°C)
  • Rated for Full −55°C to 150°C Range
  • Suitable for Remote Application

Connecting LM 35 to Arduino (UNO) :

Sending serial data to Processing :

//import Serial communication library
import processing.serial.*;

//init variables
Serial commPort;
float tempC;
float tempF;
int yDist;
float[] tempHistory = new float[100];

void setup()
{
//setup fonts for use throughout the application
//set the size of the window
size(360,320);
//init serial communication port
commPort = new Serial(this, "COM10", 9600);
//fill tempHistory with default temps
for(int index = 0; index<100; index++)
tempHistory[index] = 0;
}

void draw()
{
//get the temp from the serial port
while (commPort.available() > 0)
{
tempC = commPort.read();
//refresh the background to clear old data
background(123);

//draw the temp rectangle
colorMode(RGB, 160); //use color mode sized for fading
stroke (0);
rect (49,19,22,162);
//fade red and blue within the rectangle
for (int colorIndex = 0; colorIndex <= 160; colorIndex++)
{
stroke(160 - colorIndex, 0, colorIndex);
line(50, colorIndex + 20, 70, colorIndex + 20);
}
//draw graph
stroke(0);
fill(255,255,255);
rect(90,80,100,100);
for (int index = 0; index<100; index++)
{
if(index == 99)
tempHistory[index] = tempC;
else
tempHistory[index] = tempHistory[index + 1];
point(90 + index, 180 - tempHistory[index]);
}
//write reference values
fill(0,0,0);
textAlign(RIGHT);
text("212 F", 45, 25);
text("32 F", 45, 187);
//draw triangle pointer
yDist = int(160 - (160 * (tempC * 0.01)));
stroke(0);
triangle(75, yDist + 20, 85, yDist + 15, 85, yDist + 25);
//write the temp in C and F
fill(0,0,0);
textAlign(LEFT);
text(str(int(tempC)) + " C", 115, 37);
tempF = ((tempC*9)/5) + 32;
text(str(int(tempF)) + " F", 115, 65);
}
}

Code

Arduino CodeC/C++
Code for calculating temperature value
float temp;
int tempPin = 0;
void setup()
{
  Serial.begin(9600);
}void loop()
{
  temp = analogRead(tempPin);
  temp = temp * 0.48828125;
  Serial.println(temp);
  delay(1000);
}

Schematics

Arduino - LM35
Schematic

Comments

Similar projects you might like

Arduino Temperature - Humidity - Rain Sensor

Project showcase by Rick_Findus

  • 13,398 views
  • 6 comments
  • 18 respects

How To Use DS18B20 Water Proof Temperature Sensor

Project showcase by IoTBoys

  • 77,839 views
  • 13 comments
  • 23 respects

Temperature and Humidity Data Logger

Project tutorial by Wimpie van den Berg

  • 30,080 views
  • 2 comments
  • 27 respects

Parking Sensor with Arduino

Project showcase by Team VINICIUS LOPES

  • 21,154 views
  • 4 comments
  • 29 respects

Car Counter using Arduino + Processing + PHP

Project tutorial by Team UNO

  • 11,079 views
  • 4 comments
  • 8 respects
Add projectSign up / Login