PDA

Bekijk de volledige versie : Very cheap thermometer connected to WL-500g ?



jimmy_cr
19-12-2006, 09:12
Is it possible to make some changes so this thermometer will work on WL-500g?

http://i.iinfo.cz/r/photos/zapoj.png
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"


#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 naportu, unsigned char odkud, int 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 t0, t1, t2;
int mask = (1 << odkud);
t1=0;
t2=0;

for (t0 = 0; t0 < DelkaCyklu; t0++)
// measurement
if ((inb (naportu) & mask) == 0) t1++ ;

// 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 (STATUS, 3, 1))
{
printf ("Program must be run under root privileges\n");
exit (1);
}
if (ioperm (CONTROL, 3, 1))
{
printf ("No access to port\n");
exit (1);
}


// set control port to 1 so there is +5V for supply
outb (52, CONTROL);

// temp measurement
//for LPT port and thermometer connected to LPT PIN 15
printf ("Temperature is %4.1f \n", ZmerTo (STATUS, 3, 0));

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

return (0);
}



translated form article:

http://www.root.cz/clanky/nejjednodussi-online-teplomer/

sgtwilko
23-12-2006, 10:13
I've got a usb to serial adapter (pl2303) with a DS one-wire thermometer.

I have a DS1820 but the DS18S20 or DS1920 should work fine.

There is even a package in the feed (digitemp) that can read them for you. You can have multiple sensors attached to the one serial adapter.

dyonisos
17-06-2007, 21:29
I've got a usb to serial adapter (pl2303) with a DS one-wire thermometer.

I have a DS1820 but the DS18S20 or DS1920 should work fine.

There is even a package in the feed (digitemp) that can read them for you. You can have multiple sensors attached to the one serial adapter.

Is there a step-by-step guide available?

I have a usb-serial converter and DS1820 with RS232 adapter. The digitemp ipkg I found is only for DS2490, DS9097 and DS9097U.

I get the error:
USB ERROR: owAcquire called with invalid port string

Please help! What can I do?

sgtwilko
18-06-2007, 18:53
Is there a step-by-step guide available?

I have a usb-serial converter and DS1820 with RS232 adapter. The digitemp ipkg I found is only for DS2490, DS9097 and DS9097U.

I get the error:
USB ERROR: owAcquire called with invalid port string

Please help! What can I do?

First of all remember the wl500g uses different places for the serial port location than most Linux desktops. It uses the full /dev/usb/tts/???

The serial port adapter is seen as a DS9097.

As my serial adapter that I'm using is at the following address /dev/usb/tts/0 I use the following to show all devices on the tree

digitemp_DS9097 -s /dev/usb/tts/0 -w
See the log when you plug it in to determine what address your device is using, should be 0 unless you have multiple serial adapters.

Once you have that working and you have all your devices plugged in and can see them on the tree walk, initialise the config file by running:

digitemp_DS9097 -i
I think this creates a file in /opt/ called .digitemprc (I can't remember if I renamed mine)

Mine looks like this...

TTY /dev/usb/tts/0
READ_TIME 1500
LOG_TYPE 1
LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F"
CNT_FORMAT "%b %d %H:%M:%S Sensor %s #%n %C"
HUM_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F H: %h%%"
SENSORS 1
ROM 0 0x11 0x0A 0x98 0x11 0x10 0x18 0x44 0x5B

The initialise will walk the tree and find the sensors and add them to the file.
Every time you change what sensors are attached you will need to add the addresses to the file or re-initialise.
This isn't as stupid as it might sound. Just because the order of the sensors is one way round today, doesn't mean than the devices will start-up and report in the same order tomorrow. Ironically, temperature can have a big effect on the start-up of these little parasitic devices.

In the above file, I think I added the read_time to stabilise the usb serial adpaters I'm using, as they don't quite provide enough voltage for 100% reliability.

I then call

digitemp_DS9097 -c /opt/.digitemprc -a

This returns

DigiTemp v3.4.0 Copyright 1996-2005 by Brian C. Lane
GNU Public License v2.0 - http://www.digitemp.com
Jun 18 18:24:16 Sensor 0 C: 22.75 F: 72.95


But the format is changeable (I've changed mine in the config file) and if you use the -l logfile option the copyright text isn't logged.

For more information see the help files (Readme, etc) that are in the following.
http://www.digitemp.com/software/linux/digitemp-3.4.0.tar.gz

To answer a question I got via PM by a different user (strange in the same week getting two questions on something I posted last year), that may or may not help others, I'm using the wl500g Delux with the usb2 ports. I have found that plugging usb1 devices into it sometimes doesn't work unless they are plugged into a usb1 hub that is plugged into the wl500 directly. So I effectivly have one usb2 port on the asus that I have a usb2 hub on (for my Toppy and external hardisk) and the other for the serial adapters and the usb memory I use to boot with.

I never got the pl2303 adapters to work plugged into a usb2 hub, after some searching I found that there is a Linux kernel bug that stops this from working.

SgtWilko

dyonisos
19-06-2007, 00:06
First of all remember the wl500g uses different places for the serial port location than most Linux desktops. It uses the full /dev/usb/tts/???

The serial port adapter is seen as a DS9097.

As my serial adapter that I'm using is at the following address /dev/usb/tts/0 I use the following to show all devices on the tree

digitemp_DS9097 -s /dev/usb/tts/0 -w
See the log when you plug it in to determine what address your device is using, should be 0 unless you have multiple serial adapters.

Once you have that working and you have all your devices plugged in and can see them on the tree walk, initialise the config file by running:

digitemp_DS9097 -i
I think this creates a file in /opt/ called .digitemprc (I can't remember if I renamed mine)

Mine looks like this...

TTY /dev/usb/tts/0
READ_TIME 1500
LOG_TYPE 1
LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F"
CNT_FORMAT "%b %d %H:%M:%S Sensor %s #%n %C"
HUM_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F H: %h%%"
SENSORS 1
ROM 0 0x11 0x0A 0x98 0x11 0x10 0x18 0x44 0x5B

The initialise will walk the tree and find the sensors and add them to the file.
Every time you change what sensors are attached you will need to add the addresses to the file or re-initialise.
This isn't as stupid as it might sound. Just because the order of the sensors is one way round today, doesn't mean than the devices will start-up and report in the same order tomorrow. Ironically, temperature can have a big effect on the start-up of these little parasitic devices.

In the above file, I think I added the read_time to stabilise the usb serial adpaters I'm using, as they don't quite provide enough voltage for 100% reliability.

I then call

digitemp_DS9097 -c /opt/.digitemprc -a

This returns

DigiTemp v3.4.0 Copyright 1996-2005 by Brian C. Lane
GNU Public License v2.0 - http://www.digitemp.com
Jun 18 18:24:16 Sensor 0 C: 22.75 F: 72.95


But the format is changeable (I've changed mine in the config file) and if you use the -l logfile option the copyright text isn't logged.

For more information see the help files (Readme, etc) that are in the following.
http://www.digitemp.com/software/linux/digitemp-3.4.0.tar.gz

To answer a question I got via PM by a different user (strange in the same week getting two questions on something I posted last year), that may or may not help others, I'm using the wl500g Delux with the usb2 ports. I have found that plugging usb1 devices into it sometimes doesn't work unless they are plugged into a usb1 hub that is plugged into the wl500 directly. So I effectivly have one usb2 port on the asus that I have a usb2 hub on (for my Toppy and external hardisk) and the other for the serial adapters and the usb memory I use to boot with.

I never got the pl2303 adapters to work plugged into a usb2 hub, after some searching I found that there is a Linux kernel bug that stops this from working.

SgtWilko


Many Thanks SgtWilko!

It is working perfectly. The silly error was the wrong device /dev/tts/x instead of /dev/usb/tts/x
I suspected a DS9097 issue because of various statements that this simple serial adapter is flaky.

On the wl-500g Premium only hub1 do work. If you want USB2 performance you have to connect directly to Asus. That' s strange also.

Regards
Dyonisos

dyonisos
20-06-2007, 14:12
How could I connect two temp sensors (DS1820(S)) on the bus? Just hook it up parallel on a 20m CAT5 cable? Please let me know.

oleo
21-06-2007, 07:11
How could I connect two temp sensors (DS1820(S)) on the bus? Just hook it up parallel on a 20m CAT5 cable? Please let me know.

Yes. Its simple like that.

dyonisos
21-06-2007, 13:00
Yes. Its simple like that.

Thanks oleo.
Do you know the bus distance that could be covered with the passive serial to 1-wire adapter and e.g. 2 sensors? I would like to cover approx. 20m.

oleo
21-06-2007, 16:07
You could try my http://www.lecad.si/~leon/other/wlan/wrt54ow
but never tried more than few meters. I suspect that for 20 meters you need edge control.

britnet
22-06-2007, 10:12
Hi there,

i want to run at least 2 temp sensors on my wl500gP,

Should I bought 2 of these: LINK (http://www.conrad.de/goto.php?artikel=176168) ?

Can somebody write a short how-to?

Thanks in advance.

sgtwilko
22-06-2007, 18:34
I can't find the exact article but www.digitemp.com (http://www.digitemp.com) has a lot of info..

A quick google provides the following:
http://www.idtsoft.com/projects/yuki/dthowto.txt - which is as close to the original as I can remember.
http://www.ban-solms.de/t/IPCop-digitemp.html - Which does provide pictures for those who need there hand held, but I haven't verified that's exactly what Brian described and Brians note does reference a Doc with the diagram in it...

SgtWilko