Školský projekt Bardejov

Meranie teploty termometrom DS18B20 pomocou pasívneho prevodníka 1-WIRE.


Definícia teploty

Merať teplotu

Teplota je stavová veličina opisujúca strednú kinetickú energiu častíc. Nultý zákon termodynamiky opisuje teplotu ako veličinu, ktorá má v každom mieste izolovanej sústavy v rovnováhe rovnakú hodnotu.

Teplota sa označuje T a jej jednotkou podľa SI je Kelvin. V bežnom živote sa však z praktických dôvodov častejšie používa stupeň Celzia alebo stupeň Fahrenheita.

Jednotky SI

m (meter), kg (kilogram), s (sekunda), A (ampér), K (kelvin), mól, cd (kandela)

Teplotu môžeme merať dvoma spôsobmi - priamo, nepriamo.

Školský projekt

Meteo stanica, meranie teploty

Cieľom projektu je zkonštruovať malú meteorologickú stanicu v Bardejove, priestor školy SŠJH, zaznamenávať a graficky vyhodnocovať priebeh teploty v pravidelných intervaloch.

Kristián Vojčík.
Kristián Vojčík, II.A
Maroš Jusko, III.E.
Maroš Jusko, III.E
František Haluška, Ing.
František Haluška, Ing.

Linux server

1. Sériový port

Sériový port Standard RS-232
COM1
COM1 je ttyS0

1. [root@ssjh /]# dmesg | grep tty

2. [root@ssjh /]# setserial -g /dev/ttyS[0123]

digitemp

Na ttySO je paralelný port.

Server nemá sériový port. Použili sme prevodník USB to Serial.

2. Prevodník pl2303, USB to Serial

3. [root@ssjh /]# lsmod

Module                  Size  Used by
pl2303                 26693  0
usbserial              40241  1 pl2303
iptable_mangle         10945  0
i915                   32833  2
drm                    92136  3 i915
ipt_MASQUERADE         11329  0
iptable_nat            14661  0
nf_nat                 25837  2 ipt_MASQUERADE,iptable_nat
nf_conntrack_ipv4      17225  2 iptable_nat
xt_state               10689  0
nf_conntrack           65217  5 ipt_MASQUERADE,iptable_nat,nf_nat,nf_conntrack_ipv4,xt_state
nfnetlink              13321  3 nf_nat,nf_conntrack_ipv4,nf_conntrack
ipt_REJECT             12353  0
xt_tcpudp              11713  0
bridge                 59625  0
xt_multiport           11457  0
nfsd                  254697  17
exportfs               12865  1 nfsd
lockd                  70385  2 nfsd
nfs_acl                11329  1 nfsd
auth_rpcgss            49377  1 nfsd
autofs4                28361  2
hidp                   32321  2
l2cap                  36161  5 hidp
bluetooth              64325  2 hidp,l2cap
fuse                   47601  1
sunrpc                168009  8 nfsd,lockd,nfs_acl,auth_rpcgss
iptable_filter         11073  1
ip_tables              26153  3 iptable_mangle,iptable_nat,iptable_filter
x_tables               23113  7 ipt_MASQUERADE,iptable_nat,xt_state,ipt_REJECT,xt_tcpudp,xt_multiport,ip_tables
cpufreq_ondemand       15569  2
acpi_cpufreq           16977  0
dm_multipath           24273  0
video                  27349  0
output                 11713  1 video
sbs                    26065  0
battery                19793  0
ac                     13129  0
ipv6                  307273  95
snd_hda_intel         338021  1
snd_seq_dummy          11461  0
snd_seq_oss            37185  0
snd_seq_midi_event     14913  1 snd_seq_oss
8139too                31553  0
snd_seq                56673  5 snd_seq_dummy,snd_seq_oss,snd_seq_midi_event
snd_pcm_oss            47553  0
snd_usb_audio          93761  1
snd_usb_lib            23489  1 snd_usb_audio
snd_rawmidi            28737  1 snd_usb_lib
snd_seq_device         15061  4 snd_seq_dummy,snd_seq_oss,snd_seq,snd_rawmidi
snd_hwdep              16073  1 snd_usb_audio
gspca                 655952  1
firewire_ohci          25153  0
parport_pc             35049  0
firewire_core          46465  1 firewire_ohci
8139cp                 28097  0
snd_mixer_oss          22721  3 snd_pcm_oss
snd_pcm                80585  3 snd_hda_intel,snd_pcm_oss,snd_usb_audio
mii                    12993  2 8139too,8139cp
button                 15969  0
compat_ioctl32         16193  1 gspca
parport                42189  1 parport_pc
videodev               33729  2 gspca
pcspkr                 11201  0
e1000                 125953  0
crc_itu_t              10433  1 firewire_core
v4l2_common            25793  2 compat_ioctl32,videodev
i2c_i801               16733  0
snd_timer              27721  2 snd_seq,snd_pcm
v4l1_compat            19525  1 videodev
snd                    59753  12 snd_hda_intel,snd_seq_oss,snd_seq,snd_pcm_oss,snd_usb_audio,snd_rawmidi,
d_seq_device,snd_hwdep,snd_mixer_oss,snd_pcm,snd_timer
soundcore              14945  3 snd
i2c_core               28737  1 i2c_i801
iTCO_wdt               19857  0
snd_page_alloc         16337  2 snd_hda_intel,snd_pcm
iTCO_vendor_support    11717  1 iTCO_wdt
sg                     40169  0
sr_mod                 23269  0
cdrom                  40425  1 sr_mod
dm_snapshot            22793  0
dm_zero                10305  0
dm_mirror              26945  0
dm_mod                 57521  9 dm_multipath,dm_snapshot,dm_zero,dm_mirror
pata_marvell           13761  0
ata_piix               24133  4
ata_generic            14405  0
libata                114417  3 pata_marvell,ata_piix,ata_generic
sd_mod                 33217  7
scsi_mod              145657  4 sg,sr_mod,libata,sd_mod
ext3                  126929  2
jbd                    64689  1 ext3
mbcache                15809  1 ext3
ehci_hcd               39117  0
ohci_hcd               27845  0
uhci_hcd               30561  0

4. [root@ssjh /]# dmesg | grep tty

console [tty0] enabled
serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
00:0a: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

usb 4-2: pl2303 converter now attached to ttyUSB0
pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0

Linux digitemp

digitemp

Softvér pre linux digitemp.com

Digitemp je jednoduchý na použitie pre konzolové aplikácie pre čítanie hodnôt z Dallas Semiconductor 1-Wire zariadenia. Jeho hlavné použitie je pre čítanie teploty senzorov. Digitemp podporuje po 1-Wire teplotné čidlá: DS18S20 (a DS1820), DS18B20, DS1822, DS2438 Smart Battery Monitor, DS2422 a DS2423 čítače, DS2409 MicroLAN zariadenia a AAG TAI-8540 čidlo vlhkosti.

5. [root@ssjh /]# rpm -ql digitemp

/usr/bin/digitemp_DS2490
/usr/bin/digitemp_DS9097
/usr/bin/digitemp_DS9097U
/usr/share/doc/digitemp-3.6.0
/usr/share/doc/digitemp-3.6.0/COPYING
/usr/share/doc/digitemp-3.6.0/COPYRIGHT
/usr/share/doc/digitemp-3.6.0/CREDITS
/usr/share/doc/digitemp-3.6.0/ChangeLog
/usr/share/doc/digitemp-3.6.0/DS9097_Schematic.gif
/usr/share/doc/digitemp-3.6.0/FAQ
/usr/share/doc/digitemp-3.6.0/README
/usr/share/doc/digitemp-3.6.0/TODO
/usr/share/doc/digitemp-3.6.0/dthowto.txt
/usr/share/man/man1/digitemp.1.gz

6. [root@ssjh /]# man digitemp


DIGITEMP(1)                                                        DIGITEMP(1)



NAME
       digitemp - program to read from temperature sensors.

SYNOPSIS
       digitemp [options]

DESCRIPTION
       DigiTemp  uses  the Dallas 1-wire bus to read temperatures from digital
       sensors attached to a serial port adapter. It handles initializing  the
       bus,  searching  for  attached  devices, reading devices and custom log
       strings. It suports the following temperature devices: DS1820, DS18S20,
       DS18B20, DS1822

       It  also  handles the DS2406 1-wire hub switches, and DS2422 and DS2423
       counters.

       DigiTemp uses either the DS9097 passive serial  port  adapter,  or  the
       DS2480B based DS9097U adapter (recommended).

OPTIONS
       At  least  1  action must be given, along with some optional arguments.
       Actions are one (and only on) of the -w -t -a -w options

       -h, -? Show summary of options.

       -v     Show verbose output.

       -i     Initialize .digitemprc file, search the bus  for  all  supported
              devices.

       -w     Walk the full device tree and display the serial number and type
              of all devices detected on the bus.

       -s /dev/ttyS0
              Set serial port to use. Make sure you have permission to  access
              this port.

       -l /var/log/temperature
              Send  output  to logfile, the output format is defined by the .B
              -o command

       -c digitemp.conf
              Set digitemp configuration file. The default is  .digitemprc  in
              the current directory.

       -r 1000
              Read  delay  in ms. This sets the amount of time to wait between
              sending the  temperature  conversion  command  and  reading  the
              result. The DS18S20 takes about 750mS to do the temperature con-
              version. Default is 1000mS (1 sec).

       -t #   Read sensor number #, the # depends on the order of the  sensors
              in the

       -q     Quiet output, no copyright banner.

       -a     Read all sensors.

       -A     Treat DS2438 as A/D converter, output raw voltages

       -d 5   Delay between samples (in seconds).

       -n 50  Number of times to repeat the command.

       -O"counter format string"
              See Counter Format below.

       -o [1..3] ["output format string"]
              See Temperature Format below.

       -H"Humidity format string"
              See Humidity Format below.


Temperature Format
       The  temperature format can be either a numeric value, or a string. The
       numeric values select pre-configured output formats:

           1 = One line per sensor, time, C, F (default)
           2 = One line per sample, elapsed time, temperature in C
           3 = Same as #2, except temperature is in F

       #2 and #3 have the data seperated by tabs, suitable for import  into  a
       spreadsheet or other graphing software.

       The  format  string  uses  strftime tokens plus 5 special ones for Dig-
       iTemp:

       %s     for sensor #

       %C     for centigrade

       %F     for fahrenheit

       %R     to output the hex serial number

       %N     for seconds since Epoch.

       The case of the token is important! The default format string  is:  "%b
       %d  %H:%M:%S  Sensor  %s C: %.2C F: %.2F" which gives you an output of:
       May 24 21:25:43 Sensor 0 C: 23.66 F: 74.59

       The DS2438 sensor can be used for a variety of things.  It  includes  a
       temperature  sensor and A/D converter. DigiTemp defaults to using it as
       a humidity sensor. The raw voltages can be displayed by passing the  -A
       argument

       When the -o2 or -o3 log options are used the attached DS2438’s tempera-
       tures will be output without the humidity.


Counter Format String
       The counter format string is similar, adding these tokens:

       %n     is the counter #, which depends on its position in the .digitem-
              prc file

       %C     is the count in decimal.


Humidity Format String
       The Humidity format string is the same as the temperature format string
       with the addition of this format specifier:

       %h     is the humidity in 0-100%


AUTHOR
       This manual page was written by Jesús Roncero ,  for
       the  Debian project (but may be used by others). Modifications by Brian
       C. Lane 

UPDATES
       DigiTemp updates can be found on the http://www.digitemp.com website.




                                   June 2005                       DIGITEMP(1)

Pasívny adaptér DS9097 - výroba

1. Schéma zapojenia

digitemp

2. Súčiastky

digitemp

R1 - 1k5
D1 - BZX83 3,9V
D2 - BZX83 6,2V
D3, D4 - 1N5818
IC1 - DS18B20
konektor CAN9-Z
krytka na CAN9

3. Výroba plošného spoja

digitemp digitemp digitemp digitemp digitemp digitemp digitemp digitemp digitemp digitemp digitemp

4. Umiestnenie adaptéra do krabičky

digitemp digitemp digitemp digitemp digitemp digitemp digitemp digitemp digitemp digitemp digitemp

Pasívny adaptér DS9097 - teória

Pasívny adaptér sa pripája na sériový port. Na adaptér sa pripájajú teplotné čidla DS18S20, ich počet je prakticky neomedzený. Do USB na serveri sme zapojili prevodník USB to Serial a do sériového portu adaptér DS9097.

Prvé pokusy

7. [root@ssjh /]# digitemp -t0 -c /etc/digitemp.conf -s /dev/ttyUSB0

DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane
GNU Public License v2.0 - http://www.digitemp.com
Error 5: DS2480B Adapter Not Detected
Error 10: Read COM Failed
Error 10: Read COM Failed
Error 10: Read COM Failed
Error 10: Read COM Failed
Error 10: Read COM Failed
Error 10: Read COM Failed
Error 10: Read COM Failed
Error 10: Read COM Failed
Error 10: Read COM Failed

ee, adaptér sa nenašiel. Dôvod: dlhý cca 7m kábel k snímaču teploty.

Snímač naletovaný na plošný spoj

8. [root@ssjh /]# digitemp_DS907 -s/dev/ttyUSB0 -i

DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane
GNU Public License v2.0 - http://www.digitemp.com
Turning off all DS2409 Couplers
.
Searching the 1-Wire LAN
28BFEA9B030000CB : DS18B20 Temperature Sensor
ROM #0 : 28BFEA9B030000CB
Wrote .digitemprc

ee, adaptér sa našiel, snímač ROM #0 : 28BFEA9B030000CB detekovaný.

9. [root@ssjh /]# cat /etc/.digitemprc

TTY /dev/ttyUSB0
READ_TIME 1000
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 0x28 0xBF 0xEA 0x9B 0x03 0x00 0x00 0xCB

10. [root@ssjh /]# digitemp_DS9097 -c /etc/.digitemprc -s /dev/ttyUSB0 -t 0

DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane
GNU Public License v2.0 - http://www.digitemp.com
Dec 06 17:07:50 Sensor 0 C: 85.00 F: 185.00

Teplomer - Digitemp - Server

Meranie teploty

digitemp

Teplotný senzor

Použili sme Martybugs.net script na generovanie grafov.

[root@ssjh bin]# /usr/local/bin/tempsenzor.pl
senzor 0: 24.875000 degrees C (Inform3)
senzor 1: -2.875000 degrees C (Átrium I)
`

Meteo SŠJH

Meranie teploty - Meteo SŠJH, vonkajšia teplota.

digitemp

Server Arcon

Meranie teploty harddiskov - teplota SDA, teplota SDB, teplota SDC.

300 GB DISK1 (/dev/sda) temp: 43 °C
300 GB DISK2 (/dev/sdb) temp: 41 °C
300 GB DISK3 (/dev/sdc) temp: 46 °C

digitemp

Merať teplotu