COI - Temperature Monitor

Introduction: COI - Temperature Monitor

About: ABOUT FCFI FCFI is a community oriented public workshop where people can meet and work on their projects. We provide a facility that is open 10 AM to 10 PM, 6 days a week (with plans to eventually be open 24/7…

Mechanical Setup:


You will need an Intel Edison for Arduino, a Grove Starter Kit Plus and a computer with the Edison-Arduino IDE installed.

Begin by plugging the Edison board with Grove Starter Kit Plus Base Shield attached into the computer via two micro usb cables. Then attach the Grove RGB LCD screen to any of the I2C ports on the Grove base shield with one of the Grove Universal 4-pin Cables. Attach the Grove Temperature Sensor to port A0 on the Base Shield using a Grove Universal 4-pin Cable.

We also recommend using a static mat while connecting the electronic components.

Step 1: Code ...

Programming:
Type or copy the following code into your Edison-Arduino IDE, and click to upload the program to your Edison board.

#include 
#include
#include 
rgb_lcd lcd;
int tempSense = 0;
int B=3975; //This is a constant used
to convert between the thermistor resistance in the temperature
sensor and the actual temperature in Celcius.
double minTemp = 10;
double ideal = 20;
double maxTemp = 25;
void setup() {
  lcd.begin(16, 2);
  lcd.setRGB(255, 255, 255);
  pinMode(tempSense, INPUT);
}
void loop() {
  lcd.setCursor(0,0);
  lcd.print("                     
          ");//32 spaces clears screen of all text - deals with
text offset glitches
  lcd.setCursor(0,0);
  double read = analogRead(tempSense);
  double
resistance=(float)(1023-read)*10000/read; 
  double
temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;
  lcd.print(temperature);
  //Set the color gradient
  temperature = min(temperature,
maxTemp);
  temperature = max(temperature,
minTemp);
  double fraction;
  if(temperature < ideal){
    fraction = (ideal - temperature) /
(ideal - minTemp) * .5 + .5;
  } else {
    fraction = (maxTemp -
temperature)/(maxTemp-ideal) * .5;
  }
  int r = 0;
  int g = 0;
  int b = 0;
  double quarter = 1.0/4.0;
  if(fraction < quarter){
    r = 255;
    g = (int)((fraction)/quarter *
255);
  } else if(fraction < 2 * quarter){
    r = (int)((2 * quarter -
fraction)/quarter * 255);
    g = 255;
  } else if(fraction < 3 * quarter){
    g = 255;
    b =
(int)((fraction-2*quarter)/quarter * 255);
  } else{
    g = (int)((4 * quarter -
fraction)/quarter * 255);
    b = 255;
  }
  //Set LCD Colors
  lcd.setRGB(r,g,b);
  delay(500);//Wait half a second.
}

Step 2: Results

Results:


The finished product is a temperature monitor which displays the current temperature in Celsius, and provides an at-a-glance color display of the temperature. The minTemp, maxTemp, and ideal can be changed in the code, and affect the color display. As the temperature approaches or passes the maxTemp, the display turns red, as the temperature nears the ideal, the display turns green, and as the temperature approaches the minTemp, the display turns blue. In the picture, you can see that our room is rather warm.

This device can be used to monitor the
temperature around plants, livestock, and valuable or delicate objects.

Lessons:

Using a static mat is always advisable when connecting electronics. Also, if the screen-clearing command (printing 32 spaces) is not included, the lcd screen will occasionally acquire an artifact of an additional temperature reading offset from the original.

Step 3:

Be the First to Share

    Recommendations

    • The 1000th Contest

      The 1000th Contest
    • Battery Powered Contest

      Battery Powered Contest
    • Hand Tools Only Challenge

      Hand Tools Only Challenge

    Discussions

    0
    tobywinks
    tobywinks

    5 years ago

    Pretty neat! Check out my diy for a wiring time saver. I bet it would help you, and feel free to vote?