I have a circuit in which a thermistor is measuring the ambient temperature of the area around it. But the readings I am getting are not sensible, as they make no sense to a person. How would I get my Arduino to send out a reading in either celsius or fahrenheit temperature? Here is the code I am using. Thank you in advance for the help! ![]()
/*
// Potted Plant Protector
// By Luke Iseman
// With thanks to http://arduino.cc/en/Tutorial/LiquidCrystalDisplay
*/
//potted plant protector with rgb indicator LED and LCD
//with thanks to http://arduino.cc/en/Tutorial/LiquidCrystalDisplay
// Include the LCD Library
#include <LiquidCrystal.h>
//initialize variables for sensor pins
int moistPin = 0;
int tempPin = 1;
int lightPin = 2;
//initialize variables to store readings from sensors
int moistVal = 0;
int tempVal = 0;
int lightVal = 0;
//initialize variables for LED pins
int redPin = 11;
int greenPin = 10;
int bluePin = 9;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
void setup()
{
//initialize the serial port
Serial.begin(9600);
//set LED pins to output mode
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
//set LED pins to off
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, HIGH);
digitalWrite(bluePin, HIGH);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop()
{
moistVal = analogRead(moistPin);
//display moisture reading on lcd
lcd.clear();
lcd.print("moisture ");
lcd.print(moistVal);
//turn on LED to blue, others off if moisture pins are touching together
if (moistVal > 1000)
{
blue();
}
else
{
off();
}
//wait 4 seconds
delay(4000);
//display moisture reading on lcd
//Signal pump to turn on
if (moistVal < 5)
{
digitalWrite(13, LOW);
}
else
{
digitalWrite(13, HIGH);
}
tempVal = analogRead(tempPin);
lcd.clear();
lcd.print("temperature ");
lcd.print(tempVal);
if (tempVal > 148)
{
red();
}
else
{
off();
}
delay(4000);
lightVal = analogRead(lightPin);
//display moisture reading on lcd
lcd.clear();
lcd.print("light ");
lcd.print(lightVal);
//turn on green if light sensor reads 600 or brighter
if (lightVal > 600)
{
green();
}
else
{
off();
}
delay(4000);
}
void blue()
{
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, HIGH);
digitalWrite(bluePin, LOW);
}
void red()
{
digitalWrite(redPin, LOW);
digitalWrite(greenPin, HIGH);
digitalWrite(bluePin, HIGH);
}
void green()
{
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, LOW);
digitalWrite(bluePin, HIGH);
}
void off()
{
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, HIGH);
digitalWrite(bluePin, HIGH);
}
void on()
{
digitalWrite(redPin, LOW);
digitalWrite(greenPin, LOW);
digitalWrite(bluePin, LOW);
}