Arduino Testing - Temperature of Office at Home

Summer 2011
Starting with the Breadboard Arduino Compatible Kit from Sparkfun, I added an LM34 temperature sensor
to pin A0 to measure the room temperature, and also a 2N2222 to the BBAC circuit for
an automatic reset from the RTS signal for uploading sketches to the Arduino.

May 2012
Wanting to add a seven-segment display, I changed over to an Arduino Uno with a prototyping shield. I started with some base example code from Nathan Seidle (yes, I owe you a beer).
I added temperature sensing and reporting via serial port, leading zero blanking, a decimal point for tenths display.


Current temperature status is: (red if temperature has been more than 90 degrees)
(Requires manual reset)


The graph should be updated every five minutes or so.


New Code for the Arduino Uno

The ino file

The new PERL script that connects to the Arduino
(was stamp.pl, now arduino.pl)


Runs on an Ubuntu 10.10 machine The perl script file


plot.sh

Runs from a crontab every 5 minutes, and calls the remaining files.
#!/bin/bash
cd /home/gswann/temperature

# get the last 48 hours (one sample per minute)
tail -2880 temp.log > temp2.log
# put most recent first, rather than last
./rev.pl
# get the column containing the temperature
./extract_values.pl
# plot the data into a .pbm file
gnuplot plot.cmd
#convert to .gif
/usr/bin/ppmtogif temp.pbm > temp.gif 2>junk.out
# send plot image to godaddy
./copyto


plot.cmd

set title "Arduino 48 Hour Room Temperature Monitor Plot"
set terminal pbm color
set yrange [70:100]
set time
set style lines 1
set size 1.0,1.0
set xlabel "hours ago"
set ylabel "Degrees F"
set xtics ("now" 0,"2" 120,"4" 240,"6" 360,"8" 480,"10" 600,"12" 720,"14"
840,"16" 960,"18" 1080,"20" 1200,"22" 1320,"24" 1440,"30" 1800, "36" 2160,
"42" 2520, "48" 2880)
set output "temp.pbm"
plot "t1.log" with lines

extract_values.pl

#!/usr/bin/perl

open (LOG, "temp-rev.log");

open (T1,"> t1.log");

while (<LOG>){
  ($junk,$temps)=split(/=/,$_);
    $temps =~ tr/\ /\ /s;
    ($junk1,$T1,$T2,$T3,$T4) = split(/\ /,$temps);
     print T1 "$T1\n";
     }
close T1;
close LOG;
          

rev.pl

#!/usr/bin/perl

open IN,"temp2.log";
open OUT,">temp-rev.log";
@a=<IN>;
@b=reverse(@a);

print OUT @b;

close IN;
close OUT;

gswann - June 2011