Re: Using GPIO to measure energy
Posted: Friday 20 March 2015 17:07
Nobody an idea on what can be the problem of the isrcounter not stating?
"NAME=isrcounter" and exists in "/usr/local/bin/isrcounter" and "/usr/local/bin" does exists in PATH.hansrune wrote:You can debug into more detail by using 'sudo bash -x /etc/init.d/isrcounter status'
Does the daemon executable exist ? Check that what is in NAME=isr.... in the init script exists in your PATH. Mine is NAME=isrcounter1 and exists in /usr/local/bin/isrcounter1
Code: Select all
+ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
+ DESC='ISR pulse counter and uploader'
+ NAME=isrcounter
+ NAME_SAVEFILE=watermeterstand
+ USERNAME=pi
+ DEVIDX=6
+ LOGFILE=/var/run/shm/isrcounter
+ SAVEFILE=/home/pi/domoticz/scripts/watermeterstand
+ DAEMON=/usr/local/bin/isrcounter
+ DAEMON_ARGS=/var/run/shm/isrcounter
+ SCRIPTNAME=/etc/init.d/isrcounter
+ '[' -x /usr/local/bin/isrcounter ']'
+ . /lib/init/vars.sh
++ TMPTIME=0
++ SULOGIN=no
++ DELAYLOGIN=no
++ UTC=yes
++ VERBOSE=no
++ FSCKFIX=no
++ '[' -f /etc/default/rcS ']'
++ . /etc/default/rcS
+++ FSCKFIX=yes
++ unset EDITMOTD
++ unset RAMRUN
++ unset RAMLOCK
++ '[' -r /proc/cmdline ']'
+++ cat /proc/cmdline
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ for ARG in '$(cat /proc/cmdline)'
++ case $ARG in
++ '[' '' ']'
+ . /lib/lsb/init-functions
+++ run-parts --lsbsysinit --list /lib/lsb/init-functions.d
++ for hook in '$(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null)'
++ '[' -r /lib/lsb/init-functions.d/20-left-info-blocks ']'
++ . /lib/lsb/init-functions.d/20-left-info-blocks
++ FANCYTTY=
++ '[' -e /etc/lsb-base-logging.sh ']'
++ true
+ case "$1" in
+ status_of_proc /usr/local/bin/isrcounter isrcounter
+ local pidfile daemon name status OPTIND
+ pidfile=
+ OPTIND=1
+ getopts p: opt
+ shift 0
+ '[' -n '' ']'
+ daemon=/usr/local/bin/isrcounter
+ name=isrcounter
+ status=0
+ pidofproc /usr/local/bin/isrcounter
+ local pidfile base status specified pid OPTIND
+ pidfile=
+ specified=
+ OPTIND=1
+ getopts p: opt
+ shift 0
+ base=isrcounter
+ '[' '!' '' ']'
+ pidfile=/var/run/isrcounter.pid
+ '[' -n /var/run/isrcounter.pid ']'
+ '[' -e /var/run/isrcounter.pid ']'
+ '[' -x /bin/pidof ']'
+ '[' '!' '' ']'
+ status=0
+ /bin/pidof -o %PPID -x /usr/local/bin/isrcounter
+ status=1
+ '[' 1 = 1 ']'
+ return 3
+ status=3
+ '[' 3 = 0 ']'
+ '[' 3 = 4 ']'
+ log_failure_msg 'isrcounter is not running'
+ '[' -n 'isrcounter is not running' ']'
+ log_begin_msg isrcounter is not running ...
+ log_begin_msg_pre isrcounter is not running ...
+ log_daemon_msg_pre isrcounter is not running ...
+ log_use_fancy_output
+ TPUT=/usr/bin/tput
+ EXPR=/usr/bin/expr
+ '[' -t 1 ']'
+ '[' xxterm '!=' x ']'
+ '[' xxterm '!=' xdumb ']'
+ '[' -x /usr/bin/tput ']'
+ '[' -x /usr/bin/expr ']'
+ /usr/bin/tput hpa 60
+ /usr/bin/tput setaf 1
+ '[' -z ']'
+ FANCYTTY=1
+ case "$FANCYTTY" in
+ true
+ /bin/echo -n '[....] '
[....] + '[' -z isrcounter ']'
+ /bin/echo -n isrcounter is not running ...
isrcounter is not running ...+ log_begin_msg_post isrcounter is not running ...
+ :
+ log_end_msg 1
+ '[' -z 1 ']'
+ local retval
+ retval=1
+ log_end_msg_pre 1
+ log_use_fancy_output
+ TPUT=/usr/bin/tput
+ EXPR=/usr/bin/expr
+ '[' -t 1 ']'
+ '[' xxterm '!=' x ']'
+ '[' xxterm '!=' xdumb ']'
+ '[' -x /usr/bin/tput ']'
+ '[' -x /usr/bin/expr ']'
+ /usr/bin/tput hpa 60
+ /usr/bin/tput setaf 1
+ '[' -z 1 ']'
+ true
+ case "$FANCYTTY" in
+ true
++ /usr/bin/tput setaf 1
+ RED=''
++ /usr/bin/tput setaf 2
+ GREEN=''
++ /usr/bin/tput setaf 3
+ YELLOW=''
++ /usr/bin/tput op
+ NORMAL=''
+ /usr/bin/tput civis
+ /usr/bin/tput sc
+ /usr/bin/tput hpa 0
+ '[' 1 -eq 0 ']'
+ '[' 1 -eq 255 ']'
+ /bin/echo -ne '[FAIL'
[FAIL+ /usr/bin/tput rc
+ /usr/bin/tput cnorm
+ log_use_fancy_output
+ TPUT=/usr/bin/tput
+ EXPR=/usr/bin/expr
+ '[' -t 1 ']'
+ '[' xxterm '!=' x ']'
+ '[' xxterm '!=' xdumb ']'
+ '[' -x /usr/bin/tput ']'
+ '[' -x /usr/bin/expr ']'
+ /usr/bin/tput hpa 60
+ /usr/bin/tput setaf 1
+ '[' -z 1 ']'
+ true
+ case "$FANCYTTY" in
+ true
++ /usr/bin/tput setaf 1
+ RED=''
++ /usr/bin/tput setaf 3
+ YELLOW=''
++ /usr/bin/tput op
+ NORMAL=''
+ '[' 1 -eq 0 ']'
+ '[' 1 -eq 255 ']'
+ /bin/echo -e ' failed!'
failed!
+ log_end_msg_post 1
+ :
+ return 1
+ true
+ return 3
+ exit 3
Ok will setup demo on separate raspberry to see what is wrong. Currently II don't have access to my hardware. Really interested what is going wrong here.Panda wrote:Sorry to kick this old threat but I got the same error as roblom, can start the compiled script fine, but won't be able to use the start/stop script.
I started from scratch today.sincze wrote:Ok will setup demo on separate raspberry to see what is wrong. Currently II don't have access to my hardware. Really interested what is going wrong here.Panda wrote:Sorry to kick this old threat but I got the same error as roblom, can start the compiled script fine, but won't be able to use the start/stop script.
Code: Select all
USERNAME=pi
Code: Select all
pi@raspberrypi ~/domoticz/watermeter $ sudo /etc/init.d/isrcounter start
pi@raspberrypi ~/domoticz/watermeter $ sudo /etc/init.d/isrcounter status
[FAIL] isrcounter1 is not running ... failed!
Code: Select all
USERNAME=root
Code: Select all
pi@raspberrypi ~/domoticz/watermeter $ sudo /etc/init.d/isrcounter start
pi@raspberrypi ~/domoticz/watermeter $ sudo /etc/init.d/isrcounter status
[ ok ] isrcounter1 is running.
pi@raspberrypi ~/domoticz/watermeter $ sudo /etc/init.d/isrcounter stop
pi@raspberrypi ~/domoticz/watermeter $ sudo /etc/init.d/isrcounter status
[FAIL] isrcounter1 is not running ... failed!
Did you find this link?? Isrcounter?Lieuwke wrote:Hi all,
i have my TCRT5000 hooked up to my Raspberry GPIO and with GPIO readall i can see when the disc from my watermeter passes by (showing 1 or 0)
I have made a contact in Domoticz that show the status also. But now i'm stuck. Where do i go from there.
How do i get the watermeter to count in my utility view? What steps do i have to go over?
Mayby you can tell me the steps that are involved in step 3?Step 3: The interrupt handler is adapted from the wiringPi samples. Under wiringPi/examples, add the C program isrcounter1.c. I also added an output for a feedback LED in series with a current-limiting resistor. The LED output changes every other pulse received. Adjust pin numbers as needed in the C program, then make isrcounter1. Copy the compiled code to /usr/local/bin/isrcounter1. Source code can be downloaded from http://hansrune.net/domo/isrcounter1.c
Step 4: Add a system startup / service script to /etc/init.d/isrcounter. You can download my version from http://hansrune.net/domo/isrcounter
Step 5: Wire your input signal, and optionally the feedback output
Step 6: Under domoticz application settings, adjust the number of pulses and costs per unit of consumption
A yes. the famous how to get back from a disaster or... I want to upgrade my hardware scenarioLieuwke wrote:Hi sincze,
i don't worry at all, your are very kind and patient, so i'm confident we will get it going right
I also want to document the steps i'm making for myself. Now i'm running on a rpi 1b v2 with domoticz 2.2826 that is a bit outdated, but it's working. I've got a Rpi3 lying here i want to use with the new domoticz version and i have to do the steps all over again.
I noticed no increase on my watermeter values since last evening, so i think it's not starting automatically.
Code: Select all
HeaderPin 1: 3,3 volt
HeaderPin 9: Ground
HeaderPin 12: GPIO1
Code: Select all
Install Wiring PI (http://wiringpi.com/download-and-install/)
- sudo apt-get install git-core
- sudo apt-get update
- sudo apt-get upgrade
- git clone git://git.drogon.net/wiringPi
- cd wiringPi
- git pull origin
- ./build
Code: Select all
echo 2142454 > /var/run/shm/isrcounter1
Code: Select all
http://<YOUR_IP_HERE>:8080/json.htm?type=command¶m=udevice&idx=<YOUR_IDX_HERE&nvalue=0&svalue=<YOUR_METER_VALUE_HERE>
Code: Select all
sudo apt-get install monit
sudo monit
Code: Select all
check process Water_Meter matching "/usr/local/bin/isrcounter1"
start program "/etc/init.d/isrcounter start"
stop program "/etc/init.d/isrcounter stop"
Code: Select all
sudo monit status
sudo monit reload