-
Notifications
You must be signed in to change notification settings - Fork 1
Home
The protocol seems to be the same as described here:
see also:
https://sigrok.org/wiki/Voltcraft_DL-160S
written with libusb 0.1 API, therefore some libraries and header files must be installed. This can be achieved by:
sudo apt-get install libusb-dev
git clone https://github.com/FrankBau/dl161s.git
cd dl161s
cd dl161s/dl161s/src
gcc -o dl161s dl161s.c -lusb
sudo apt-get install autoconf
cd dl161s
./autogen.sh
./configure
make
sudo make install
Install dl161s in an existing recipe layer (or create a new layer for it)
bitbake dl161s
Insert the datalogger and make sure, that the cp210x
kernel module does not get loaded (see also FAQ):
sudo modprobe -r cp210x
echo "blacklist cp210x" | sudo tee /etc/modprobe.d/blacklist_cp210x.conf
dl161s
will write the measurement data to a file in /var/www/html/logs/
. Create that folder if it does not exist:
sudo mkdir -p /var/www/html/logs/
start the program manually from the build folder for testing:
sudo ./dl161s
dl161s
will write log messages to the syslog. Check /var/log/messages (or /var/log/syslog etc.) for log messages.
The program will (hopefully) run forever. If it returns, an error occured. Check syslog:
tail /var/log/messages
For a longer test, you may start dl161s as a background task:
sudo ./dl161s &
Now, check the measurement data:
ls -l /www/pages/logs/
lighttpd
with PHP support is used, please see
- https://redmine.lighttpd.net/projects/lighttpd/wiki
- https://raspberry.tips/raspberrypi-tutorials/raspberry-pi-als-webserver-teil-1/
- https://www.howtoforge.com/tutorial/install-lighttpd-with-php-fpm-and-mysql-on-debian/
sudo apt install lighttpd
sudo apt install php7.3-fpm php7.3-mbstring php7.3-mysql php7.3-curl php7.3-gd php7.3-curl php7.3-zip php7.3-xml php7.3-cgi
sudo lighttpd-enable-mod fastcgi
sudo lighttpd-enable-mod fastcgi-php
root@raspberrypi3:~# php-cgi --version
PHP 7.3.29-1~deb10u1 (cgi-fcgi) (built: Jul 2 2021 04:04:33)
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.29, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.29-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies
sudo vi /etc/lighttpd/lighttpd.conf
Note: on yocto rocko (Nov. 2018) the config file is to be found here:
sudo vi /etc/lighttpd.conf
and check/add/change the following lines.
dir-listing.activate = "enable"
dir-listing.hide-dotfiles = "enable"
dir-listing.encoding = "utf-8"
The last three lines are used for showing file&folder listings in the web browser.
Check that the module "mod_fastcgi" is in the list of enabled modules and
check/add lines for .php handling in file /etc/lighttpd/conf-enabled/15-fastcgi-php.conf
fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.sock"
)))
After all changes, restart lighttpd:
sudo service lighttpd force-reload
lighttpd should run automatically on boot. Check with ps aux | grep lighttpd
From the host PC, when entering the target IP address like http://raspberrypi.local/ in a web browser, the browser should render the content of file /www/pages/index.html
which reads:
**It works!**
If you add a file /www/pages/phpinfo.php
with the content
<?php phpinfo(); ?>
The web browser should display detailed infos about the php installation when rendering http://raspberrypi3.local/phpinfo.php.
You might need to replace the IP address with the IP address of your raspi.
sudo cp ../wwwpages/index.php /var/www/html/
it needs also a current 1.x version of dygraph-combined.js
which is found at https://dygraphs.com/download.html
curl https://dygraphs.com/1.1.1/dygraph-combined.js > dygraph-combined.js
sudo mv dygraph-combined.js /var/www/html/
Two techniques are combined:
Copy (install) the binary program to its final destination:
sudo cp dl161s /usr/local/bin/
Create a new file:
sudo vi /etc/systemd/system/dl161s.service
with the following content:
[Unit]
Description=dl161s sound level recorder
[Service]
Type=simple
User=www-data
Group=wwww-data
ExecStart=/usr/local/bin/dl161s
Restart=always
RestartSec=5
StartLimitBurst=5
StartLimitInterval=1m
StartLimitAction=reboot
Short explanation: when that service is started, systemd will launch the dl161s program and watch it. If it dies, it will be automatically relaunched. If it dies more than 5 times within 1 minute, the system will be rebooted. For testing: kill it (killall dl161s) several times until reboot happens.
You can start/stop the service manually from a terminal for testing. The daemon-reload line is only needed after changing the systemd files:
sudo systemctl daemon-reload
sudo systemctl start dl161s.service
...
sudo systemctl stop dl161s.service
Check the service status with:
systemctl status dl161s.service
You should see output like
pi@FrankBerry3:~ $ sudo systemctl status dl161s.service
● dl161s.service - dl161s sound level recorder
Loaded: loaded (/etc/systemd/system/dl161s.service; disabled)
Active: active (running) since Tue 2016-12-20 14:26:24 CET; 37s ago
Main PID: 589 (dl161s)
CGroup: /system.slice/dl161s.service
└─589 /usr/local/bin/dl161s
Dec 20 14:26:24 FrankBerry3 systemd[1]: Started dl161s sound level recorder.
Dec 20 14:26:24 FrankBerry3 dl161s[589]: started
Dec 20 14:26:29 FrankBerry3 dl161s[589]: send_calibration(0)
Dec 20 14:26:29 FrankBerry3 dl161s[589]: send_calibration returns: 0
Dec 20 14:26:29 FrankBerry3 dl161s[589]: found stored calibration value: 0*0.1 dB
or use
journalctl -u dl161s.service
to get more information.
In principle, that service could be started automagically on system startup (systemctl enable dl161s.service
).
But this won't work here because the data logger needs 5+ seconds to boot itself.
Instead of using timers etc.., we simply add a udev
rule that fires when the data logger becomes visible on USB bus:
A udev rule file determines what will happen, when a particular device is added/removed to/from the system.
Create the following rule file.
sudo vi /etc/udev/rules.d/90-local.rules
with content (adjust the id's according to lsusb
output)
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="10c4", ATTR{idProduct}=="ea61", RUN+="/bin/systemctl start dl161s.service"
ACTION=="remove", SUBSYSTEM=="usb", ATTR{idVendor}=="10c4", ATTR{idProduct}=="ea61", RUN+="/bin/systemctl stop dl161s.service"
and activate the new rule with:
sudo udevadm control --reload-rules
Reboot and check that dl161s is started automatically.
Use
sudo udevadm control --log-priority=info
to log what/when rules have fired.
You may also disconnect and reconnect the data logger and watch the service running.
note: For an USB cam on a similar system; i had to write the rule like this:
ACTION=="add", SUBSYSTEM=="usb", ENV{ID_MODEL}=="mvBlueFOX3-1013C", RUN+="/usr/bin/touch /home/nvidia/added"
ACTION=="remove", SUBSYSTEM=="usb", ENV{ID_MODEL}=="mvBlueFOX3-1013C", RUN+="/usr/bin/touch /home/nvidia/removed"
- Q: How can I change the diagram appearance on the web site? A: Edit /var/www/html/index.php (sudo required). See https://dygraphs.com/options.html
- Q: How can I configure the mike settings like alarm level, dbA, slow/fast etc..? A: Edit the C source code
dl161s.c
, re-build (compile&link) and re-install the executable to/usr/local/bin/
.
- protect website access by .htaccess htpasswd etc..
- add Linux Dash for remote monitoring
- monitor (using
iotop
) or minimize disk activities using a read-only filesystem - use the watchdog
- optimize low-power settings