procyon78
Published © GPL3+

Outside temperature monitor using Arduino Nano

3-LED indicator box that measures the outside air temperature and warns for dangerous driving conditions.

BeginnerShowcase (no instructions)659
Outside temperature monitor using Arduino Nano

Things used in this project

Hardware components

Arduino Nano Every
Arduino Nano Every
×1
Resistor 220 ohm
Resistor 220 ohm
×3
5 mm LED: Green
5 mm LED: Green
×1
5 mm LED: Yellow
5 mm LED: Yellow
×1
LED, Blue
LED, Blue
×1
Temperature Sensor
Temperature Sensor
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Fritzing schematic

Code

3-LED temperature monitor

Arduino
/* Temperature indication using 3 LEDs
 *  alerts for dangerous road conditions
 *  Arduino NANO code
 *  15-09-2021 by Procyon78
 */

const int sensorPin = A0;
// reference temperature, degrees Celcius
const float baselineTemp =4.0;

void setup() {
  // open a serial connection to display values
  Serial.begin(9600);
  // set the LED pins as outputs
  // pin D2 = green LED
  pinMode(2,OUTPUT);
  // pin D3 = yellow LED
  pinMode(3,OUTPUT);
  //pin D4 = blueLED
  pinMode(4,OUTPUT);
   }

void loop() {
  // read the value on AnalogIn pin 0 and store it in a variable
  int sensorVal = analogRead(sensorPin);

  // send the 10-bit sensor value out the serial port
  Serial.print("sensor Value: ");
  Serial.print(sensorVal);

  // convert the ADC reading to voltage
  float voltage = (sensorVal / 1024.0) * 5.0;

  // Send the voltage level out the Serial port
  Serial.print(", Volts: ");
  Serial.print(voltage);

  // convert the voltage to temperature in degrees C
  // the sensor changes 10 mV per degree
  // the datasheet says there's a 500 mV offset
  // ((voltage - 500 mV) times 100)
  Serial.print(", degrees C: ");
  float temperature = (voltage - 0.5) * 100;
  Serial.println(temperature);

 // measured temperature is 4 degrees or above = green LED on
 if (temperature >= baselineTemp){
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);

 // measured temperature is between 0 and 4 degrees = yellow LED on
} else if (temperature >= baselineTemp-4 && temperature < baselineTemp){
    digitalWrite(2, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);

 // measured temperature is lower than 0 degrees = blue LED on
} else if (temperature < baselineTemp-4){
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
  }
    
  delay(1000);
}

Credits

procyon78
0 projects • 0 followers

Comments