This is an old revision of the document!


Barometer

<HTML> <IMG SRC=“/gnuplot/index.php?file=last72.gnuplot”> </HTML>

Dual pressure sensor board

PIC18F1320 Datasheet

RX on pin 3 TX on pin 2

Power ON
98.97 kPa,      742.3 Torr      ; 0814,0521
98.97 kPa,      742.3 Torr      ; 0814,0521
98.97 kPa,      742.3 Torr      ; 0814,0521

I need to order the 296-19829-1-ND MAX3227E Datasheet

MAX3221 is the wrong chip, it only does +-5V 232 signals, I will need to remove and add the MAX3227

max3221-max3243.pdf

WireFunction
Red5V
YellowRX (Data from computer)
BlueTX (Data to computer)
BlackGnd
gnuplot

Perl logging script


#!/usr/bin/perl -w
 
use DateTime::Format::Excel;
use DateTime;
 
$pidfile="/root/baro/barolog.pid";
$csvfile="/root/baro/log/barometer.csv";
$gnpfile="/root/baro/log/barolog.gnp";
$logfileshort="/root/baro/log/barolog-";
$device="/dev/ttyUSB0";
 
open(FILE, ">".$pidfile);
print FILE $$;
close(FILE);
 
open(CSV,  ">>".$csvfile);
print CSV "\n";
close(CSV);
 
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$syear=substr($year,1,2);
$year+=1900;
$mon++;
$logfile=$logfileshort.$syear.$mon.$mday;
#print "Logfile: $logfile\n";
 
 
$dt = DateTime->new( year => $year, month => $mon, day => $mday);
 
open(USB, "<".$device);
 
while (1) {
	$curhour=$hour;
	$qtr=1+int($min/15);
	$curqtr=$qtr;
	$dt = DateTime->new( year => $year, month => $mon, day => $mday);
	$count=0;
	$avgtally=0;
 
	print "Opening $device\n";
	while (<USB>) {
		($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
		$mon++;
		$year+=1900;
		$qtr=1+int($min/15);
		$dt = DateTime->new( year => $year, month => $mon, day => $mday);
 
		if($curqtr==$qtr) {
		} else {
			$average=$avgtally/$count;
			$pressure=(($average/1023)+0.095)/0.009;
			$pressure = sprintf("%g", $pressure);
			print "$baro, ";
			$oldcount=$count;
			$count=0;
			$avgtally=0;
			# Print Average here
			$logfile=$logfileshort.$syear.$mon.$mday;
 
			open(LOG, ">>".$logfile);
			print "Pressure for $hour.$qtr: $pressure kPa\n";
			$quarter=15*int($min/15);
			print LOG "$hour.$quarter $average $pressure\n";
			close(LOG);
 
			$now=time();
			$foravg=sprintf("%g", $average);
			open(GNP, ">>".$gnpfile);
			print GNP "$now $pressure $foravg $oldcount\n";
			close(GNP);
 
			$excel = DateTime::Format::Excel->format_datetime( $dt );
#			print "Hour: $hour\tQuarter: $quarter\n";
			$exceltime=($hour/24)+($quarter/1440);
#			print "Excel: ".($excel+$exceltime)."\n";
			open(CSV,  ">>".$csvfile);
			print CSV $excel+$exceltime;
			print CSV ",$pressure";
			print CSV ",".sprintf("%g", $average);
			print CSV ",$oldcount";
			print CSV "\n";
			close(CSV);
 
			$dt = DateTime->new( year => $year, month => $mon, day => $mday);
			$curhour=$hour;
			$curqtr=1+int($min/15);
 
		}
#		if($count==6) {
#			$curqtr++;
#		}
 
			$count++;
			@baro=split(/ /,$_);
			$baro=$baro[1];
			$avgtally+=$baro;
		}
	sleep(1);
}

Gnuplot


set terminal png size 800
set title "PIC18F based Barometer\nhttp://photonicsguy.ca/projects/electronics/dualpressuresensor"
set nokey
#set xlabel "Date\nTime" 0,-1
set grid
set xrange [1226454300:]
set bmargin 3
set ylabel 'Pressure (kPa)'
set xdata time
set timefmt "%s"
set format x "%b-%d\n%H:%M"
set xlabel "Date"
 
plot\
'/root/baro/log/barolog.gnp' using ($1-(5*3600)):2 ti "Values" with impulses lt 2,\
'/root/baro/log/barolog.gnp' using ($1-(5*3600)):2 ti "Barometer" with lines lt 3 lw 3

<HTML> <IMG SRC=“http://photonicsguy.ca/sqlfile.php?id=1”> </HTML>


  • Use an LM358 Op-Amp
  • 80 to 110 kilopascals » 3.125 to 4.475 Volts. 3 to 4.5 volt rate will give 77.3 to 110 KPa range.

  • projects/electronics/dualpressuresensor.1231532381.txt.gz
  • Last modified: 2014/11/13 10:50
  • (external edit)