Anton TETERIN 6890679940 * read DS18x20 temperature sensors /A | 9 months ago | |
---|---|---|
.. | ||
README.md | 1 year ago | |
read_ds18x20.py | 9 months ago | |
read_ds18x20.sh | 9 months ago |
#
#
sudo su
ls -la /sys/bus/w1/devices/*
lrwxrwxrwx 1 root root 0 Jun 12 12:18 /sys/bus/w1/devices/00-200000000000 -> ../../../devices/w1_bus_master1/00-200000000000
lrwxrwxrwx 1 root root 0 Jun 12 12:18 /sys/bus/w1/devices/00-a00000000000 -> ../../../devices/w1_bus_master1/00-a00000000000
lrwxrwxrwx 1 root root 0 Jun 12 12:13 /sys/bus/w1/devices/w1_bus_master1 -> ../../../devices/w1_bus_master1#
ls -la /sys/bus/w1/devices/*
lrwxrwxrwx 1 root root 0 Jun 12 12:20 /sys/bus/w1/devices/00-600000000000 -> ../../../devices/w1_bus_master1/00-600000000000
lrwxrwxrwx 1 root root 0 Jun 12 12:20 /sys/bus/w1/devices/00-e00000000000 -> ../../../devices/w1_bus_master1/00-e00000000000
lrwxrwxrwx 1 root root 0 Jun 12 12:20 /sys/bus/w1/devices/10-000800e489b3 -> ../../../devices/w1_bus_master1/10-000800e489b3 <-- this is first sensor
lrwxrwxrwx 1 root root 0 Jun 12 12:20 /sys/bus/w1/devices/10-00080280a759 -> ../../../devices/w1_bus_master1/10-00080280a759 <-- this is second sensor
lrwxrwxrwx 1 root root 0 Jun 12 12:18 /sys/bus/w1/devices/w1_bus_master1 -> ../../../devices/w1_bus_master1#
chmod +x /home/pi/meter/* ls -la /home/pi/meter/*
which python
/usr/bin/python
root@(host):/home/pi/meter# ./read_ds18x20.py
/sys/bus/w1/devices/10-000800e489b3;27000
/sys/bus/w1/devices/10-00080280a759;29500#
#
sudo su apt install postgresql
pg_ctlcluster 11 main start
su - postgres psql
CREATE USER (user) WITH PASSWORD '(pass)'; \du
CREATE DATABASE telemetry; \l
GRANT ALL ON DATABASE telemetry TO (user) ; \l telemetry
\c telemetry CREATE TABLE telemetry_host(); \d \d telemetry_host
ALTER TABLE telemetry_host ADD COLUMN timestamp TIMESTAMPTZ PRIMARY KEY; ALTER TABLE telemetry_host ADD COLUMN sensor CHAR(64) NOT NULL; ALTER TABLE telemetry_host ADD COLUMN value INTEGER NOT NULL; \d telemetry_host
???
nano ./read_ds18x20.sh pi@(host):~/meter $ ./read_ds18x20.py | ./read_ds18x20.sh
INSERT 0 1
INSERT 0 1
sudo crontab -e
*/1 * * * * /home/pi/meter/read_ds18x20.py | /home/pi/meter/read_ds18x20.sh
tail -f /var/log/syslog | grep CRON
Jun 12 12:47:01 lab5rp41 CRON[1507]: (root) CMD (/home/pi/meter/read_ds18x20.py | /home/pi/meter/read_ds18x20.sh)
Jun 12 12:47:04 lab5rp41 CRON[1503]: (CRON) info (No MTA installed, discarding output)#
psql -h (host_ip) -U (user2) -d (db) -c "SELECT * FROM telemetry_host;"
Password for user (host):
timestamp | value | sensor
-------------------------------+-------+------------------------------------------------------------------
2020-06-12 08:58:36.732033+01 | 12345 | test_sensor
2020-06-12 10:38:12.519066+01 | 27500 | /sys/bus/w1/devices/10-000800e489b3
2020-06-12 10:38:12.68798+01 | 29000 | /sys/bus/w1/devices/10-00080280a759
2020-06-12 10:38:47.060764+01 | 27000 | /sys/bus/w1/devices/10-000800e489b3
2020-06-12 10:38:47.222548+01 | 28937 | /sys/bus/w1/devices/10-00080280a759
2020-06-12 10:46:38.363432+01 | 27062 | /sys/bus/w1/devices/10-000800e489b3
2020-06-12 10:46:38.552815+01 | 28812 | /sys/bus/w1/devices/10-00080280a759
2020-06-12 10:47:03.880082+01 | 27687 | /sys/bus/w1/devices/10-000800e489b3
2020-06-12 10:47:04.031554+01 | 28750 | /sys/bus/w1/devices/10-00080280a759
(9 rows)
Books: