1. intro

DS18B20

./pic/ds18b20_t09.jpg ./pic/ds18b20_waterproof.jpg

./pic/ds18b20_schema2.png

./pic/ds18b20_gpio.png

2. client

source /bin/cid-functions
cid_add_line /boot/config.txt "dtoverlay=w1-gpio"
wget -N -nv http://d01cid.ddns.net/sharel/bin/cid-ds18b20 -P /bin/
chmod +x /bin/cid-ds18b20
cube /etc/cron.d/cid-cron "#*/1" with "*/1"
cid_add_line /bin/cid-cron01 "/bin/cid-ds18b20 srv002.d01.net"
Tip for your reference, you can get the script here

2.1. testing

After enabling the extra line in /boot/config.txt, reboot the node.

ll /sys/devices/w1_bus_master1/
drwxr-xr-x 3 root root    0 Jan  1  1970 28-000008eaf56c
lrwxrwxrwx 1 root root    0 Jan  1  1970 driver -> ../../bus/w1/drivers/w1_master_driver
drwxr-xr-x 2 root root    0 Sep  5 22:36 power
lrwxrwxrwx 1 root root    0 Jan  1  1970 subsystem -> ../../bus/w1
-rw-r--r-- 1 root root 4096 Jan  1  1970 uevent
-rw-rw-r-- 1 root root 4096 Sep  5 22:36 w1_master_add
-r--r--r-- 1 root root 4096 Sep  5 22:36 w1_master_attempts
-rw-rw-r-- 1 root root 4096 Sep  5 22:36 w1_master_max_slave_count
-r--r--r-- 1 root root 4096 Sep  5 22:36 w1_master_name
-r--r--r-- 1 root root 4096 Sep  5 22:36 w1_master_pointer
-rw-rw-r-- 1 root root 4096 Sep  5 22:36 w1_master_pullup
-rw-rw-r-- 1 root root 4096 Sep  5 22:36 w1_master_remove
-rw-rw-r-- 1 root root 4096 Sep  5 22:36 w1_master_search
-r--r--r-- 1 root root 4096 Sep  5 22:36 w1_master_slave_count
-r--r--r-- 1 root root 4096 Sep  5 22:36 w1_master_slaves
-r--r--r-- 1 root root 4096 Sep  5 22:36 w1_master_timeout
-r--r--r-- 1 root root 4096 Sep  5 22:36 w1_master_timeout_us
cat /sys/devices/w1_bus_master1/w1_master_slaves
28-000008eaf56c
cat /sys/bus/w1/devices/28-000008eaf56c/w1_slave
91 01 4b 46 7f ff 0f 10 25 : crc=25 YES
91 01 4b 46 7f ff 0f 10 25 t=25062

3. server

 mysql -u"root" -p"Passw0rd" -e "drop database temperature;"
 mysql -u"root" -p"Passw0rd" -e "create database temperature;"
 mysql -u"root" -p"Passw0rd" temperature -e "create table temps (t1 FLOAT, t2 FLOAT, t3 FLOAT, t4 FLOAT, receivedat TIMESTAMP DEFAULT CURRENT_TIMESTAMP);"
# mysql -u"root" -p"Passw0rd" temperature -e "insert into temps (t1, t2, t3, t4) values (10, 12, 14, 16);"

3.1. rtemp

yum -y install rrdtool
curl -# http://d01cid.ddns.net/sharel/tar/rtemp-20180212.tgz | tar xzP -C /opt/
/opt/rtemp/bin/rtemp-init
wget -N -nv http://d01cid.ddns.net/sharel/etc/httpd/conf.d/rtemp.conf -P /etc/httpd/conf.d/
cube /etc/httpd/conf.d/rtemp.conf "%dnsdomainname%" with "$(dnsdomainname)"
systemctl reload httpd.service
source /bin/cid-functions
cube /etc/cron.d/cid-cron "#*/1" with "*/1"
cid_add_line /bin/cid-cron01 "/opt/rtemp/bin/rtemp"

3.2. tempmon (deprecated)

wget -N -nv http://iada.nl/system/files/tempmon_2_0.zip -P /tmp/
mkdir -p /var/www/html/tempmon
unzip /tmp/tempmon_2_0.zip -d /var/www/html/tempmon/
rm -f /tmp/tempmon_2_0.zip
yum -y install dos2unix
dos2unix /var/www/html/tempmon/index.php
cube /var/www/html/tempmon/index.php "HOST" with "localhost"
cube /var/www/html/tempmon/index.php "USER" with "root"
cube /var/www/html/tempmon/index.php "PASSWORD" with "Passw0rd"
cube /var/www/html/tempmon/index.php "DATABASE" with "temperature"
cube /var/www/html/tempmon/index.php "temp1" with "t1"
cube /var/www/html/tempmon/index.php "temp2" with "t2"
cube /var/www/html/tempmon/index.php "created_at" with "receivedat"
cube /var/www/html/tempmon/index.php "Sensor Binnen" with "Sensor T1"
cube /var/www/html/tempmon/index.php "Sensor Buiten" with "Sensor T2"
cube /var/www/html/tempmon/index.php "Gem laatste 24u" with "Average"
cube /var/www/html/tempmon/index.php "Refresh: 150" with "Refresh: 60"
cube /var/www/html/tempmon/index.php "height:400px" with "height:250px"

4. debugging

mysql -u"root" -p"Passw0rd" temperature -e "select * from temps;"

5. references