Using GPIO to measure energy

Moderator: leecollings

Lieuwke
Posts: 15
Joined: Saturday 06 December 2014 19:25
Target OS: Linux
Domoticz version:
Contact:

Re: Using GPIO to measure energy

Post by Lieuwke »

Hi Sincze,

Followed you instruction to the letter but can't seem to get it to work.

Checks:
GPIO pin 12(physical pin on the Board) is working.
Checked it with GPIO Readall when the sensor is activated and not. Readout is ok.
Checked with GPIO Exports to show me the pin states also:

18: in 1 falling and 18: in 0 falling is returned. Depending on the state of the sensor.
I'm Guessing GPIO hardware is in working order.

I placed the mentioned files in the correct folder using WinSCP and i edited the ISRCOUNTER in /etc/init.d to match my setup to DEVIDX="39"
I also set the file permissions for the files to 0775

Somewhere i read i had to add the file to startupscript using sudo update-rc.d isrcounter defaults
Did that, but i don't know if things are working.

my difficulty is: How do i check the separate steps.
I know how to check the pin using GPIO.
But how to check if the ISRCOUNTER1 binary is working en how to check if the ISRCOUNTER script in init.d is right?
Can i force things manually to narrow the search so we can find the missing link?

Again thank you for all your great efforts!!
Sony Raspberry Pi B V2.0
Homemade P1 cable on Landis/Gyr E350
C&K/Honeywell Security system connected to Domoticz
AEON Labs USB Z-Wave
TCRT5000 sensor watermeter -> revived..... and in progress....
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Using GPIO to measure energy

Post by sincze »

Hey you got some spare time to work on this project again.
Nice.
Lieuwke wrote:Hi Sincze,

Followed you instruction to the letter but can't seem to get it to work.

Checks:
GPIO pin 12(physical pin on the Board) is working.
Checked it with GPIO Readall when the sensor is activated and not. Readout is ok.
Checked with GPIO Exports to show me the pin states also:

18: in 1 falling and 18: in 0 falling is returned. Depending on the state of the sensor.
I'm Guessing GPIO hardware is in working order.
Yes wiringpi pin 1, so that seems to be working. Nice :D
Lieuwke wrote: I placed the mentioned files in the correct folder using WinSCP and i edited the ISRCOUNTER in /etc/init.d to match my setup to DEVIDX="39"
I also set the file permissions for the files to 0775
That would mean that if you would execute ./isrcounter it will give you some kind of... I am missing some values sir message ???
Lieuwke wrote: Somewhere i read i had to add the file to startupscript using sudo update-rc.d isrcounter defaults
Did that, but i don't know if things are working.
When you placed all files in the correct folder you should be okay.
Lieuwke wrote: my difficulty is: How do i check the separate steps.
I know how to check the pin using GPIO.
But how to check if the ISRCOUNTER1 binary is working en how to check if the ISRCOUNTER script in init.d is right?
Can i force things manually to narrow the search so we can find the missing link?

Again thank you for all your great efforts!!
To find out where it goes wrong you could cinsider to build the executing string from scratch.
Avoid this ;-) jusr run the executable. You can actually see what happens.

For example what happens if you issue a:

Code: Select all

/etc/init.d/isrcounter status
Does it actually run?? If you did everything okay it should say:

Code: Select all

[ ok ] isrcounter1 is running.
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.
HNBC84
Posts: 63
Joined: Tuesday 01 December 2015 10:53
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Using GPIO to measure energy

Post by HNBC84 »

Before i start to do something that dont work.

Is this for a s0 counter or only a photosensor?

I have a s0 counter setup (since today) and before i buy stuff i dont need, or do some wireing. I want to connect it directly to the GPIO pins. :)

And i think this is the place tobe
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: RE: Re: Using GPIO to measure energy

Post by sincze »

HNBC84 wrote:Before i start to do something that dont work.

Is this for a s0 counter or only a photosensor?

I have a s0 counter setup (since today) and before i buy stuff i dont need, or do some wireing. I want to connect it directly to the GPIO pins. :)

And i think this is the place tobe
It counts pulses (on, /off). If that is what you are asking Image

Sent from my SM-G925F using Tapatalk
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.
HNBC84
Posts: 63
Joined: Tuesday 01 December 2015 10:53
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: RE: Re: Using GPIO to measure energy

Post by HNBC84 »

sincze wrote:
HNBC84 wrote:Before i start to do something that dont work.

Is this for a s0 counter or only a photosensor?

I have a s0 counter setup (since today) and before i buy stuff i dont need, or do some wireing. I want to connect it directly to the GPIO pins. :)

And i think this is the place tobe
It counts pulses (on, /off). If that is what you are asking Image

Sent from my SM-G925F using Tapatalk
easy answer

I think i will give it a shot :)
someone allready get it to work with a s0 kwh counter?
HNBC84
Posts: 63
Joined: Tuesday 01 December 2015 10:53
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Using GPIO to measure energy

Post by HNBC84 »

I think i have the software correct.

Code: Select all

pi@domoticz ~ $ sudo isrcounter1 status
Waiting ... Waiting ... ^Z
[1]+  Stopped                 sudo isrcounter1 status
pi@domoticz ~ $ /etc/init.d/isrcounter status
[ ok ] isrcounter1 is running.
pi@domoticz ~ $ sudo isrcounter1 status
Waiting ... Waiting ...
The theaspoon connection counts whitout the wierd numbers

Tomorrow i wil get a cable connection from the s0 counter en wil have a shot its about 10m away

Why does it need a gpio out and a in?
Why not just 1 in and a ground?
HNBC84
Posts: 63
Joined: Tuesday 01 December 2015 10:53
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Using GPIO to measure energy

Post by HNBC84 »

Code: Select all

2017-02-28 22:03:12.651 GPIO: 1 interrupts in queue.
2017-02-28 22:03:12.651 GPIO: Too many interrupts for GPIO 18. Ignoring..
2017-02-28 22:03:12.651 GPIO: Acknowledging interrupt for GPIO 18.
2017-02-28 22:03:12.651 GPIO: Processing interrupt for GPIO 18...
2017-02-28 22:03:12.701 GPIO: Done processing interrupt for GPIO 18 (LOW).
Could someone explain? Or how to get it of?
I use it with a s0 kWh counter and like the watercooker it goes to fast.

Still not shore if it counts all the pulses

Code: Select all

Waiting ...  Done. counter: 3410: 1
Waiting ...  Done. counter: 3418: 2
Waiting ...  Done. counter: 3419: 8
Waiting ...  Done. counter: 3420: 1
Waiting ...  Done. counter: 3421: 1
Waiting ...  Done. counter: 3422: 1
Waiting ...  Done. counter: 3424: 1
Waiting ...  Done. counter: 3425: 2
Waiti
Icarus
Posts: 3
Joined: Friday 06 January 2017 21:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Using GPIO to measure energy

Post by Icarus »

Big thanks to those that did all the work on this. I have it reading my Gas meter. Wire connecting TCRT5000 to GPIO is hanging out of an upstairs window. Not ideal but I can not get wire to rasberry pi any other way.
I have a Fibaro universal binary sensor. Would it be possible to connect TCRT5000 to one input & get domotics to count pulses from it ?? If so how do I go about doing it ?
Thanks
stinuz
Posts: 1
Joined: Thursday 07 December 2017 9:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Using GPIO to measure energy

Post by stinuz »

Hello,

I'm planning to compile 2 isrcounter instances because I want to use 1 for gas and 1 for water. In your tutorial you are mentioning something of false / positive detection. Will I also have this covered when I compile the isrcounter myself or did you add additional code to the compiled file in your tutorial.

Thanks in advance,
Stijn
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests