Products: Writing Your Own Software
A great feature of TempTrax is its ease in user programmability. This is especially important to those who don’t wish to use our proprietary software…they simply want to hook up TempTrax to the computer’s serial port and access the data via their own software calls to the unit. This can be accomplished in any number of ways (including Excel, Visual Basic, Visual C++, Perl, etc…). As long as TempTrax is plugged into a PC compatible serial port and you have access to the port, you can get the temperature.
To retrieve the temperature from the TempTrax Model F, setup the RS232 communications port as follows:
- 9600 Baud
- No Parity
- 8 Data Bits
- 1 Stop Bit
- No Flow Control
- DTR On (Logic "1" or high)
After opening up the comport and setting DTR high, send any character out the computer’s serial port. This will "wake up" the TempTrax and it’ll
take a measurement and respond with a carriage return/linefeed delimited ASCII string of data that will look something like the following:
76.8
34.5
Bat Ok
The 1st line returned is the temperature in °F of probe #1, the 2nd of probe #2, and the 3rd line gives the battery conditions. You will need to wait about a second before looking for the returned string. And that’s it!
Only 4 serial port lines are used with the TempTrax Model F family… Transmit, Receive, DTR, and Ground.
If anyone has further questions on communicating with TempTrax please drop an email to support@openxtra.co.uk.
Visual Basic (Version 6.0) Sample Code
Here’s the VB routine to retrieve the temperature data from the TempTrax.
’NAME: GetData()
’PURPOSE: Send a character out the computer’s comport. This causes the TempTrax to take a reading and send the results back to the computer.
’CommCtrlG is the standard MSComm control shipped with Visual Basic
Private Function GetData() As String
Dim str As String
CommCtrlG.DTREnable = True ’DTR signal powers the TempTrax circuit
Rest (0.5) ’User defined function to provide 1/2 second wait time
CommCtrlG.Output = " " ’Send a character out comport to get data
Rest (1) ’Wait a second before looking at return string
str = CommCtrlG.Input ’str should now contain the temperature data
If (Not Len(str) > 10) Then
GetData = ""
Else
GetData = str
End If
CommCtrlG.DTREnable = False
End Function
Perl Sample Code:
Here’s a Perl script that can be used to retrieve the temperature data from the TempTrax (a zipped file is also available).
#!/usr/bin/perl -w
# Requires Device-Serial per module.
use Device::SerialPort 0.05;
use strict;
my $Temptrax = "/dev/ttyS1";
my $pass;
my $return;
# Constructor & Basic Values
my $ob = Device::SerialPort->new ($Temptrax) || die "Can’t open $Temptrax:$!";
$ob->baudrate (9600) || die "fail setting baudrate";
$ob->parity ("none") || die "fail setting parity";
$ob->databits (8) || die "fail setting databits";
$ob->stopbits (1) || die "fail setting stopbits";
$ob->handshake ("none") || die "fail setting handshake";
$ob->dtr_active (1) || die "fail setting dtr_active";
$ob->write_settings || die "no settings";
sleep 1;
#send a dummy character to the TempTrax device to "wake it up"
#The temperature will be returned
$pass = $ob->write("a") or die ("Could not write to Temptrax: $!");
sleep 1;
if (($return = $ob->input) ne "")
{
$ob->write ($return);
print "$return";
}
else
{
print "ERROR!! Did not receive a temperature reading from TempTrax.\n";
}
undef $ob

UK
France
España
Italia
Deutschland
Nederland
Česká Republika
Hellas
Ireland
Polska
Россия
Danmark
Österreich
