Is it possible to make some changes so this thermometer will work on WL-500g?


beware, there's probably mistake in this wiring - PIN 1 and PIN 14 shouldn't be connected together as there's no need - should be enough to connect only PIN1 or PIN14 (read in forum under article)

"teplomer.c"
PHP Code:
#include <stdio.h>
#include <unistd.h> 
#include <sys/io.h> 

#define DATA 0x378
#define STATUS DATA+1
#define CONTROL DATA+2

float ZmerTo (unsigned short naportuunsigned char odkudint stav

// return temperature in °C
// parametert
// naportu - port where is thermometer connected tomereni
// odkud  - bit where is thermometer connected tomereni
// stav - set if is bit "odkud" negated or not

#define DelkaCyklu  0xffff  //length of cycle

{
int t0t1t2;
int mask = (<< odkud);
t1=0;
t2=0;    
 
for (
t0 0t0 DelkaCyklut0++)
    
// measurement
    
if ((inb (naportu) & mask) == 0t1++ ;
  
// negation of measurement in case the bit/port is also negated
t2=DelkaCyklu-t1;
if (
stav!=0){
   
t1=t2;
   
t2=DelkaCyklu-t1;
    };
// temperature calculation
return ((((double)t2 / ((double)DelkaCyklu)) - 0.32) / 0.0047);
}

int main (void
{
if (
setuid (0) < 0)
    {   
    
printf ("Program must be run under root privileges\n");
    exit (
1);
     }
if (
ioperm (STATUS31))
    {
    
printf ("Program must be run under root privileges\n");
    exit (
1);
    }
if (
ioperm (CONTROL31))
    { 
    
printf ("No access to port\n");
          exit (
1);
     }

  
// set control port to 1 so there is +5V for supply
outb (52CONTROL);
    
// temp measurement
//for LPT port and thermometer connected to LPT PIN 15 
printf ("Temperature is %4.1f \n",  ZmerTo (STATUS30));

// set control port to 0 so there is NOT +5V for supply
outb (55CONTROL);    

return (
0);

translated form article:

http://www.root.cz/clanky/nejjednodu...line-teplomer/