Failed to detect any pins error ?

Moderator: leecollings

Post Reply
jslegers
Posts: 34
Joined: Tuesday 23 February 2016 9:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: NL
Contact:

Failed to detect any pins error ?

Post by jslegers »

Hello,

Yesterday my neighbor and I installed a water meter with a TCRT5000 board. I have connected the sensor on pin 12 GPIO 18.
If i start manually /usr/local/bin/gpio export 18 in and then /home/pi/domoticz/domoticz my water counter works.

But when we place /usr/local/bin/gpio export 18 in in the domoticz.sh script we get an error.

29 22:20:11.910 EventSystem: reset all events...
2016-02-29 22:20:11.936 Error: GPIO: Failed to detect any pins, make sure you exported them!
2016-02-29 22:20:11.972 Active notification subsystems: (0/10)
2016-02-29 22:20:11.982 Webserver started on port: 8080
2016-02-29 22:20:11.995 Started sh

We have also tried to put this command in /etc/init/d/rc.local file but the same error.

Any one else also seen this problem before ?
User avatar
sincze
Posts: 1302
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Failed to detect any pins error ?

Post by sincze »

I'll install latest Domoticz version from the site 2.4834 on my SD and see if I can replicate the situation. :D
Pretty strange.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
User avatar
sincze
Posts: 1302
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Failed to detect any pins error ?

Post by sincze »

Ok Running v2.2563 on Raspberry Pi 2.
I did the following:

1. DOWNLOAD & INSTALL WIRING PI http://wiringpi.com/download-and-install/
2. Create the exports my Watermeter is connected to
Watermeter GPIO
Watermeter GPIO
Aansluiting Sensoren (GPIO).png (305.51 KiB) Viewed 5442 times

Code: Select all

	gpio export 18 in
	gpio edge 18 both
2. Check the export:

Code: Select all

	gpio exports
3. To have the GPIO available in Domoticz I added the following lines to the /etc/init.d/domoticz.sh script as described here: https://www.domoticz.com/wiki/GPIO

At the end of the file after the ":"
:
#Run export GPIO Raspberry

/usr/local/bin/gpio export 18 in
/usr/local/bin/gpio edge 18 both

4. Reboot the system

Code: Select all

sudo shutdown -r now
[code]

5. Created the GPIO sensor as described here: [url]https://www.domoticz.com/wiki/GPIO[/url]"

6. Added LUA to /domoticz/script/lua directory as script_device_watermeter.lua

[code]
	commandArray = {}
	print('> Monitoring water consumption')
	-- Water usage
	-- Retrieve value from water meter device:
	sWaterUsage = otherdevices_svalues['Water']

	-- To have a better readable format, divide number by 1000:
	sWaterUsagePrint = tonumber(sWaterUsage / 1000);

	-- calculation is done with the unmodified water value
	sWaterUsage = tonumber(sWaterUsage);

	print(">> Utilities: Water usage until now is " .. sWaterUsagePrint .. " ");
	if (devicechanged['GPIO_WATER'] == 'Closed')
	then
	   sWaterUsageTot = (sWaterUsage + 1)
   
	print(">> Utilities: Water usage is now " .. sWaterUsageTot .. " ");
	commandArray['OpenURL']='http://IPADDRESS:PORT/json.htm?	type=command&param=udevice&idx=164&svalue='..sWaterUsageTot..''
end

return commandArray
This is working okay, no error messages. :D
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
User avatar
sincze
Posts: 1302
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Failed to detect any pins error ?

Post by sincze »

I just updated to v2.4834

Using the steps described here: https://www.domoticz.com/wiki/Installin ... pberry_PI

Code: Select all

mkdir ~/domoticz
cd ~/domoticz
wget http://www.domoticz.com/releases/release/domoticz_linux_armv7l.tgz
tar xvfz domoticz_linux_armv7l.tgz
rm domoticz_linux_armv7l.tgz
The Watermeter is still working.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
User avatar
sincze
Posts: 1302
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Failed to detect any pins error ?

Post by sincze »

Just added 4,7k resistor between 3,3v and GND pin.

Modified the LUA script from:

Code: Select all

if (devicechanged['Water'] == 'Closed')
then
   sWaterUsageTot = (sWaterUsage + 1)
to:

Code: Select all

if (devicechanged['Water'] == 'Closed')
then
   sWaterUsageTot = (sWaterUsage + 0.5)
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
User avatar
sincze
Posts: 1302
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Failed to detect any pins error ?

Post by sincze »

And while busy whu not remove the http update if the device update can be done from within LUA now :D

Code: Select all

------------------------------------------------------------------------------
-- Script parameters
------------------------------------------------------------------------------
debug = true                    -- Turn debugging on ("true") or off ("false")

------------------------------------------------------------------------------

commandArray = {}

metername="Watermeter"
meteridx=7

if (debug)
then
   print('> Monitoring water consumption')
end

-- Water usage
-- Retrieve value from water meter device:
sWaterUsage = otherdevices_svalues[metername]


-- To have a better readable format, divide number by 1000:
sWaterUsagePrint = tonumber(sWaterUsage / 1000);


-- calculation is done with the unmodified water value
sWaterUsage = tonumber(sWaterUsage);

if (debug)
then
  print(">> Utilities: Water usage until now is " .. sWaterUsagePrint .. " ");
end


if (devicechanged['Water'] == 'Closed')
then
   sWaterUsageTot = (sWaterUsage + 0.5)
   print(">> Utilities: Water usage is now " .. sWaterUsageTot .. " ");
   commandArray['UpdateDevice']=meteridx .. "|0|" .. sWaterUsageTot
end

return commandArray
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
jslegers
Posts: 34
Joined: Tuesday 23 February 2016 9:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: NL
Contact:

Re: Failed to detect any pins error ?

Post by jslegers »

Thanks for the effort. I will test it this weekend.
Good job.
joostnl
Posts: 68
Joined: Wednesday 03 February 2016 19:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Failed to detect any pins error ?

Post by joostnl »

Thank you for all your work. Only i can't get it to work...
I did everything you descriped but when i add the lua to Domoticz.

I get in my log:
2017-02-12 15:26:26.917 LUA: > Monitoring water consumption
2017-02-12 15:26:26.918 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_watermeter.lua: /home/pi/domoticz/scripts/lua/script_device_watermeter.lua:24: attempt to perform arithmetic on global 'sWaterUsage' (a string value)

In your script i only changed the device idx to: 117 (because i see that in devices)
Do i have to change more in the script?
Or do i also need to ad a watermeter to display the input values? (i added only the switch you described)

Thanks in advance!
User avatar
sincze
Posts: 1302
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Failed to detect any pins error ?

Post by sincze »

joostnl wrote:Thank you for all your work. Only i can't get it to work...
I did everything you descriped but when i add the lua to Domoticz.

I get in my log:
2017-02-12 15:26:26.917 LUA: > Monitoring water consumption
2017-02-12 15:26:26.918 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_watermeter.lua: /home/pi/domoticz/scripts/lua/script_device_watermeter.lua:24: attempt to perform arithmetic on global 'sWaterUsage' (a string value)

In your script i only changed the device idx to: 117 (because i see that in devices)
Do i have to change more in the script?
Or do i also need to ad a watermeter to display the input values? (i added only the switch you described)

Thanks in advance!
Show me your script
you need to change IDX and create a water meter as well. in my example below the meter is called water

Code: Select all

sWaterUsage = otherdevices_svalues['Water']
So the GPIO switch is for counting open/closed.... and that should add 1 liter to the watermeter. :D
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
joostnl
Posts: 68
Joined: Wednesday 03 February 2016 19:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Failed to detect any pins error ?

Post by joostnl »

The idx value of '117' is my GPIO Switch so I used this in the script
I added a flowmeter called: 'Water' with a dummy hardware, then add virtual sensor is this correct?

Another question: How did you mount the sensor and why you used a resistor inbetween?

Thanks for your responds, im pretty new to scripting :geek:

Code: Select all

------------------------------------------------------------------------------
-- Script parameters
------------------------------------------------------------------------------
debug = true                    -- Turn debugging on ("true") or off ("false")

------------------------------------------------------------------------------

commandArray = {}

metername="Watermeter"
meteridx=117

if (debug)
then
   print('> Monitoring water consumption')
end

-- Water usage
-- Retrieve value from water meter device:
sWaterUsage = otherdevices_svalues[metername]


-- To have a better readable format, divide number by 1000:
sWaterUsagePrint = tonumber(sWaterUsage / 1000);


-- calculation is done with the unmodified water value
sWaterUsage = tonumber(sWaterUsage);

if (debug)
then
  print(">> Utilities: Water usage until now is " .. sWaterUsagePrint .. " ");
end


if (devicechanged['Water'] == 'Closed')
then
   sWaterUsageTot = (sWaterUsage + 0.5)
   print(">> Utilities: Water usage is now " .. sWaterUsageTot .. " ");
   commandArray['UpdateDevice']=meteridx .. "|0|" .. sWaterUsageTot
end

return commandArray
User avatar
sincze
Posts: 1302
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Failed to detect any pins error ?

Post by sincze »

joostnl wrote:The idx value of '117' is my GPIO Switch so I used this in the script
I added a flowmeter called: 'Water' with a dummy hardware, then add virtual sensor is this correct?

Another question: How did you mount the sensor and why you used a resistor inbetween?

Thanks for your responds, im pretty new to scripting :geek:

Code: Select all

------------------------------------------------------------------------------
-- Script parameters
------------------------------------------------------------------------------
debug = true                    -- Turn debugging on ("true") or off ("false")

------------------------------------------------------------------------------

commandArray = {}

metername="Watermeter"
meteridx=117

if (debug)
then
   print('> Monitoring water consumption')
end

-- Water usage
-- Retrieve value from water meter device:
sWaterUsage = otherdevices_svalues[metername]


-- To have a better readable format, divide number by 1000:
sWaterUsagePrint = tonumber(sWaterUsage / 1000);


-- calculation is done with the unmodified water value
sWaterUsage = tonumber(sWaterUsage);

if (debug)
then
  print(">> Utilities: Water usage until now is " .. sWaterUsagePrint .. " ");
end


if (devicechanged['Water'] == 'Closed')
then
   sWaterUsageTot = (sWaterUsage + 0.5)
   print(">> Utilities: Water usage is now " .. sWaterUsageTot .. " ");
   commandArray['UpdateDevice']=meteridx .. "|0|" .. sWaterUsageTot
end

return commandArray
Have a look here for my mounting bracket. ;-)
viewtopic.php?t=2157&start=20
viewtopic.php?t=5021#p64026

The resistor was used as a pull down to avoid false positives.
In the end I removed it and solved the whole watermeter in a different way.

as described here: viewtopic.php?t=5021#p41946. It has been working for over 2 years now flawless with isrcounter.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
joostnl
Posts: 68
Joined: Wednesday 03 February 2016 19:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Failed to detect any pins error ?

Post by joostnl »

Thanks for your photo's I made a simular bracket from DIN RAIL.

I tuned the sensor that the green light go's on when the reflective part of the water meter passes by. I found it to hard to point it at the end of the red arrow.
Must i change my sensor now to NO or NC?

Without your script i get some times an error.

"2017-02-18 17:19:30.120 Error: Watermeter hardware (13) thread seems to have ended unexpectedly"

This is not normal right?

I got the script working, i was confused with were 'water' and 'watermeter' had to be haha

Why are you counting with 0.5? I thougth 1 revolution was 1 L not 0.5

Code: Select all

2017-02-18 17:19:26.172 GPIO: Queuing interrupt for GPIO 18.
2017-02-18 17:19:26.172 GPIO: 1 interrupts in queue.
2017-02-18 17:19:26.172 GPIO: Too many interrupts for GPIO 18. Ignoring..
2017-02-18 17:19:26.172 GPIO: Acknowledging interrupt for GPIO 18.
2017-02-18 17:19:26.172 GPIO: Processing interrupt for GPIO 18...
2017-02-18 17:19:26.222 GPIO: Done processing interrupt for GPIO 18 (LOW).
2017-02-18 17:19:26.223 (Watermeter) Lighting 1 (Watermeter)
2017-02-18 17:19:27.882 GPIO: Queuing interrupt for GPIO 18.
2017-02-18 17:19:27.882 GPIO: 1 interrupts in queue.
2017-02-18 17:19:27.883 GPIO: Too many interrupts for GPIO 18. Ignoring..
2017-02-18 17:19:27.883 GPIO: Acknowledging interrupt for GPIO 18.
2017-02-18 17:19:27.883 GPIO: Processing interrupt for GPIO 18...
2017-02-18 17:19:27.933 GPIO: Done processing interrupt for GPIO 18 (HIGH).
2017-02-18 17:19:27.933 (Watermeter) Lighting 1 (Watermeter)
2017-02-18 17:19:30.120 Error: Watermeter hardware (13) thread seems to have ended unexpectedly
2017-02-18 17:19:33.073 GPIO: Queuing interrupt for GPIO 18.
2017-02-18 17:19:33.073 GPIO: 1 interrupts in queue.
2017-02-18 17:19:33.073 GPIO: Too many interrupts for GPIO 18. Ignoring..
2017-02-18 17:19:33.074 GPIO: Acknowledging interrupt for GPIO 18.
2017-02-18 17:19:33.074 GPIO: Processing interrupt for GPIO 18...
2017-02-18 17:19:33.124 GPIO: Done processing interrupt for GPIO 18 (LOW).
User avatar
sincze
Posts: 1302
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Failed to detect any pins error ?

Post by sincze »

joostnl wrote:
Why are you counting with 0.5? I thougth 1 revolution was 1 L not 0.5
Ha well mine was counting double so when I used 1 liter... :D

- On detection of the disk it would say 1 liter used
- When leaving the detection of the disk area.. again 1 liter used.

But instead ofcourse it was still just 1 liter not 2.
Also I had some problems when the disk would stop.... (because i did not use water) right in the middle of the detection area.
No problem as it was ignoring the multiple interrupts just as your log shows.

However when I continued using water again.. Again one 1 additional liter. So my mater usage was double according to domoticz.

Hope this helps :D
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
joostnl
Posts: 68
Joined: Wednesday 03 February 2016 19:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Failed to detect any pins error ?

Post by joostnl »

Clear, mine is counting correctly if I use 10L water it counts 10, so I changed to script to +1.

Can you maybe tell me how to install the Isrcounter?

I followed https://www.domoticz.com/wiki/GPIO

Do i only have to set the correct:

We use gpio: 18 so i have to change 4 into 18?

// What GPIO input are we using?
// This is a wiringPi pin number

#define IN_PIN 4
#define INTERRUPT_DEBOUNCE_DELAY 500
User avatar
sincze
Posts: 1302
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Failed to detect any pins error ?

Post by sincze »

joostnl wrote:Clear, mine is counting correctly if I use 10L water it counts 10, so I changed to script to +1.

Can you maybe tell me how to install the Isrcounter?

I followed https://www.domoticz.com/wiki/GPIO

Do i only have to set the correct:

We use gpio: 18 so i have to change 4 into 18?

// What GPIO input are we using?
// This is a wiringPi pin number

#define IN_PIN 4
#define INTERRUPT_DEBOUNCE_DELAY 500
how to install isrcounter is slightly different.
viewtopic.php?f=32&t=3151&start=60#p112272
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest