0% found this document useful (0 votes)
10 views6 pages

Arduino Sensors: Temp & Gas Monitoring

The document outlines an Arduino session focused on hands-on experience with a temperature sensor and a smoke/gas MQ-2 sensor. It includes code snippets for reading temperature and smoke levels, as well as exercises to enhance the programs by adding a buzzer for alarms. The session is led by Dr. Swarna Priya RM, an Associate Professor at SCORE.

Uploaded by

safalyareddy60
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

Arduino Sensors: Temp & Gas Monitoring

The document outlines an Arduino session focused on hands-on experience with a temperature sensor and a smoke/gas MQ-2 sensor. It includes code snippets for reading temperature and smoke levels, as well as exercises to enhance the programs by adding a buzzer for alarms. The session is led by Dr. Swarna Priya RM, an Associate Professor at SCORE.

Uploaded by

safalyareddy60
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ARDUINO SESSION 4

Topics:
Hands-on with
a. Temperature Sensor
b. Smoke / Gas MQ-2 Sensor

Dr. Swarna Priya RM,


Associate Professor, SCORE

7/29/2024 Dr. Swarna Priya RM


Temperature Sensor

float val;
int tempPin = A1;

void setup()
{
[Link](9600);
pinMode(tempPin, INPUT);
}

7/29/2024 Dr. Swarna Priya RM


void loop()
{
val = analogRead(tempPin);
float mv = (val/1024.0)*5000;
float cel = mv/10;
float farh = (cel*9)/5 + 32;

[Link]("TEMPRATURE = ");
[Link](cel);
[Link]("*C");
[Link]();
delay(1000);

[Link]("TEMPRATURE = ");
[Link](farh);
[Link]("*F");
[Link]();

7/29/2024 Dr. Swarna Priya RM


Smoke Sensor

#include <SoftwareSerial.h>
int sensorPin = A0;
int sensorValue = 0;
int led = 13;

void setup()
{ // declare the ledPin as an OUTPUT:
pinMode(led, OUTPUT);
[Link](9600);
}

7/29/2024 Dr. Swarna Priya RM


void loop()
{
[Link]("Welcome to IoT Class ");
sensorValue = analogRead(sensorPin);
[Link](sensorValue);
delay(5000);

if (sensorValue>400)
{
digitalWrite(led,HIGH);

}
else
{
digitalWrite(led,LOW);
}
}

7/29/2024 Dr. Swarna Priya RM


Exercise

■ Include a buzzer in the smoke sensor program along with the


LED which is already available.

■ Include a buzzer in the temperature sensor program to give


an alarm if the temperature is greater than 20 degree
Celcius.

7/29/2024 Dr. Swarna Priya RM

You might also like