Overview
This project is about observing the temperature and density of light in the surroundings using sensors.
In this light density and temperature measurer we use a photoresistor sensor to measure light density and a temperature sensor for measuring temperature of the surrounding.
Hardware required
- Arduino Uno R3
- Resistor
- Jumper Wires
- Temperature Sensor
- Photoresistor Sensor
- Breadboard
Schematic Diagram
Fig 1. Circuit Diagram
Arduino Code :
int lightSensor = A0;
int tempSensor = A1;
void setup() //Runs once at the start
{
pinMode(tempSensor, INPUT);
pinMode(lightSensor, INPUT);
Serial.begin(9600);
}
void loop() //Runs in a constant loop
{
//Just print a line for the light reading
int lightReading = analogRead(lightSensor);
Serial.print("Light reading: ");
Serial.println(lightReading);
int tempReading = analogRead(tempSensor);
//If using 5v input
float voltage = tempReading * 5.0;
// Divided by 1024
voltage /= 1024.0;
//Converting from 10mv per degree
float tempC = (voltage - 0.5) * 100;
Serial.print(tempC);
Serial.println(" degrees C"); //Print as degrees
delay(1000); //Use a delay to slow readings
}
Precautions
- Connections should be done properly.
- Arduino is case Sensitive so code accordingly.
- Give different and appropriate colors to the wires.
- Use resistors for sensors and LCDs.