Working: Gasmetersensor based on Kaku doorsensor (15 euros)

Moderator: leecollings

pwhooftman
Posts: 75
Joined: Monday 11 November 2013 18:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Working: Gasmetersensor based on Kaku doorsensor (15 euros)

Post by pwhooftman »

Hi, i'd like to introduce my 15 euro gasmeter pulse solution.

I bought a Kaku AMST-606 magnetic door contact for 15 euro's.
Inside the switch, there is a small reed switch, a magnetich switch (the little glass tube with green ends).

Image

I desolderd the reed switch and attached 15cm thin but stiff copper wires to it (telephone cable), running through little drill holes in the casing (do not loose the metal part of the rotating time-out switch on the back of the AMST-606 during disassembly!)

Image

Next i positioned the reed valve in the special cavity in the gasmeter. Becvause the last reel of digits contains a magnet which passes by with every revolution, every 0,01m3 of gas used produces an on-off cycle of the swith.

Image
Image

Then i proceeded as follows:
- in the device list, note the Idx of the Kaku AMST-606 switch
- add it to the used devices and give the switch a name like 'gaspuls'
- add dummy hardware
- add a virtual sensor to the hardware of the type "counter", give it any name like 'gascounter'. Once created, edit the device and set it to the type 'counter'
- create a luascript script_device_gaspuls.lua in /scripts/lua, make sure it matches the name given to the switch.
- fill the script with the following code. Adjust the Idx, filepath and switchname to your specific situation

Code: Select all

--|55744.690


commandArray = {}

local thisfilename = "/volume1/@appstore/domoticz/domoticz/scripts/lua/script_device_gaspuls.lua"
local virtualcounter_idx = "44"
local switchName = "gascounter"

if devicechanged[switchName] == 'On' then

-- Open this file and read in the first line
   file = io.open(thisfilename, "rb")
   sContents = file:read("*l")
   file:close()

-- Parse and update the countvalue
   foo, snumber = sContents:match("([^,]+)|([^,]+)")
   local countvalue = snumber + 0.010
   local newline = foo .. "|" .. string.format("%.3f", tostring(countvalue))

-- Update virtual counter device
   ts = virtualcounter_idx .. "|0|" .. string.format("%.3f", tostring(countvalue))
   commandArray['UpdateDevice'] = ts

-- Write back new counter value
   local file = io.open(thisfilename, "r+")
   file:write(newline)
   file:close()

end

return commandArray
Notes:
- put the current reading of the gasmeter at the top of the lua script in the notation shown
- this value is read & written back to the lua script on every executiuon because of the bug mentioned in this thread http://www.domoticz.com/forum/viewtopic.php?f=15&t=1309

Every time the kaku switch is activated, the script is called and the value of the counter is increased by 0.010.

The result:

Image

The 'today' value is high because i entered this starting value in the script, making it seem all gas was consumed today
I'm curious how long the built in 3V lithium battery of the AMST-606 will last, it switches like 1000-2000 a day....

Update: fixed a small bug in the Lua script which crippled the value when going from .990 m3 to the next .000 counter

Tip: set the device type to 'gas' and the gasmeter setting to 1 to display daily usage correctly
Image
Last edited by pwhooftman on Friday 07 February 2014 12:56, edited 3 times in total.
Domoticz v 1.16xx
1X RFXtrx433 USB 433.92MHz Transceiver Firmware version: 71
1X Synology Nas DS918+ DSM 7 (12Gb RAM mod)
safi78
Posts: 204
Joined: Thursday 05 September 2013 15:39
Target OS: Linux
Domoticz version: LastBeta
Contact:

Re: Working: Gasmeterpuls for 15 euros, based on Kaku doorse

Post by safi78 »

Very cool!
homebridge, rfxcom, zwave, nest, applamp, hue, debian, apple, mysensors, netatmo, fibaro, synology, foscam, otherz
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by Derik »

Really great !!!!

I have a other meter, only i like yor mod very much...
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
BigDog
Posts: 82
Joined: Tuesday 17 September 2013 13:59
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.9269
Location: The Netherlands
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by BigDog »

damn sometimes things can be so easy :D

the only thing i was thinking about if you have more kaku sensors are switches if the door-sensor reports its thing other sensors and switches cant communicate with domoticz becose the door sensor is already sending and the doorsensor is sending very often i see....
1X Raspberry4B : Domoticz Version 2023.1 [Linux 5.10.63-v7l+ armv7l]
1X Conbee II : 2.25.3 - 26720700
1X RFXtrx433 USB Firmware:183
1X Mysensors Gateway 1.5 -3
6X ESP8266: Tosmota firmware
Zigbee : 6 Operators, 13 Sensors
pwhooftman
Posts: 75
Joined: Monday 11 November 2013 18:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by pwhooftman »

BigDog wrote:damn sometimes things can be so easy :D

the only thing i was thinking about if you have more kaku sensors are switches if the door-sensor reports its thing other sensors and switches cant communicate with domoticz becose the door sensor is already sending and the doorsensor is sending very often i see....
Thats right, Kaku sensor transmit 5-sec bursts of messages. But i don't use any other Kaku transmitters to be received by the RfxCom, and as long as the last gasmeter dial does not spin faster than 5 seconds i should be ok

I'm currently reading up on connecting a light-diode to a Gpio port of a TP-Link 1043ND router (those are cheap). Someone has created a little program on that router to count pulses delivered to the Gpio port, so maybe thats my next project :)
Domoticz v 1.16xx
1X RFXtrx433 USB 433.92MHz Transceiver Firmware version: 71
1X Synology Nas DS918+ DSM 7 (12Gb RAM mod)
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by Derik »

I'm currently reading up on connecting a light-diode to a Gpio port of a TP-Link 1043ND router (those are cheap). Someone has created a little program on that router to count pulses delivered to the Gpio port, so maybe thats my next project :)


How is this working??
And what are there for more options???
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
pwhooftman
Posts: 75
Joined: Monday 11 November 2013 18:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by pwhooftman »

Derik wrote:I'm currently reading up on connecting a light-diode to a Gpio port of a TP-Link 1043ND router (those are cheap). Someone has created a little program on that router to count pulses delivered to the Gpio port, so maybe thats my next project :)


How is this working??
And what are there for more options???
GPIO are General Purpose Input Output ports on the chip of the router, which can be used to control external devices like sensors & switches. The well known PiFace for Raspberry Pi is based on usages of these ports. See http://wiki.openwrt.org/toh/tp-link/tl-wr1043nd for example.
Domoticz v 1.16xx
1X RFXtrx433 USB 433.92MHz Transceiver Firmware version: 71
1X Synology Nas DS918+ DSM 7 (12Gb RAM mod)
dorustd
Posts: 3
Joined: Friday 08 August 2014 21:20
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by dorustd »

Hi

I am very interested.
At the moment I have Domoticz installed.
Domoticz v 1.1680
1X RFXtrx433 USB 433.92MHz Transceiver Firmware version: 69
I have severeal klikaanklikuit (door) sensors installed

But.... I am I am very interested to create gassensor as yoy described.

So far successful but :
How do I change/add create a luascript script_device_gaspuls.lua in /scripts/lua ?
On the RaspBerry PI ?

Can you help me


Regards,
Theo
The Netherlands
pwhooftman
Posts: 75
Joined: Monday 11 November 2013 18:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by pwhooftman »

Hi Theo,

I put the text of the luascript via notepad into a .lua file.
I copied the file to a public folder on my Synology, i guess you can use WinSCP to put in onto the Raspberry via FTP
Then move it to the right folder under domoticz (i think ./domoticz/scripts/lua)

BTW: the battery of the 'gassensor' lasts less than 2 months..., no wonder becaus eit's designed as a door contact :-)
Domoticz v 1.16xx
1X RFXtrx433 USB 433.92MHz Transceiver Firmware version: 71
1X Synology Nas DS918+ DSM 7 (12Gb RAM mod)
niclasf
Posts: 3
Joined: Sunday 02 February 2014 19:18
Target OS: Linux
Domoticz version:
Location: Stockholm
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by niclasf »

My wireless pulse counter is Very low-power. It is also very versatile.

http://foogadgets.tictail.com/product/w ... se-counter
dorustd
Posts: 3
Joined: Friday 08 August 2014 21:20
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by dorustd »

Thanks !

In meantime its working now with my AMST-606 contact.
I have installed the lua scirpt in the proper directory on my Rasberry PI. I have seen it is working

Only I have to do is to desolder the reed switch and attached 15cm thin but stiff copper wires to it (telephone cable).
I hope it will work after installation the device on my gasmeter.

Other question:
How do I reset Status 55775 to 0 ?
dorustd
Posts: 3
Joined: Friday 08 August 2014 21:20
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by dorustd »

Is does not work.

Maybe my gameter the last reel of digits does not contain a magnet :(
markk
Posts: 267
Joined: Tuesday 14 January 2014 14:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by markk »

Hi

I'm desperate to get this working but am having a bit of trouble. I'm rumming Domoticz on windows and it appears I have the file path wrong and don't know how to fix it. I attach the script I'm using and the error message from the log and would be really grateful for any help please!

image.jpg
image.jpg (24.49 KiB) Viewed 23841 times
Attachments
image.jpg
image.jpg (103.54 KiB) Viewed 23841 times
Running Domoticz on Pi3 with RFXtrx433e. LWRF power sockets and dimmer switches. Integrated my existing wirefree alarm PIRs and door contacts with domoticz. Geofencing with Pilot. Harmony Hub. Tado for Heating. Now playing with mysensors.
Palatinus
Posts: 1
Joined: Saturday 27 September 2014 10:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by Palatinus »

hello,
thanks for this great tutorial! I am not from the computer industry and it has worked for me right away.
I'm from Germany, so it was not possible for me not to get the sensor. I have instead taken a door sensor of intertechno. Inside it looks like and can be converted as well.
It now transmits high without problems from the basement to the living room.
Unfortunately, it does not transmit battery status. Are there any experiences how long the battery works?
Maybe I'm going there to solder a power supply to it.
Thanks again for the Great manual, I did not think that you can get as cheap a sensor for the gas meter.
pwhooftman
Posts: 75
Joined: Monday 11 November 2013 18:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by pwhooftman »

Hi, my battery lasted about 6 weeks, so i advice to connect a power supply to it.
Domoticz v 1.16xx
1X RFXtrx433 USB 433.92MHz Transceiver Firmware version: 71
1X Synology Nas DS918+ DSM 7 (12Gb RAM mod)
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by ThinkPad »

Very clever idea! In technical aspect mabye not the best advisable idea (because of the battery draining quite fast, and the 433Mhz band being blocked every few seconds), but definately easily to create!
I am not active on this forum anymore.
User avatar
Conn-artist
Posts: 21
Joined: Saturday 12 July 2014 12:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8367
Location: 127.0.0.1
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by Conn-artist »

Hi, i'd like to introduce my 15 euro gasmeter pulse solution.
Thanks for the excellent instructions. I tried a similar construction with my gas meter, except I am using a reed switch from Flukso in stead of a KAKU, and the Raspberry Pi GPIO interrupts (and s ingle pull-up resistor). Saves batteries.

I encountered an issue which I would like to share, in case anyone else experiences it.

The script that is explained above records the gas meter reading in three decimals (e.g. 55744.690) but the actual data field in the Domoticz database is an integer. It won't accept a string with a decimal component. Maybe the data format changed between the time that OP wrote his post and the version that I use (2.2042).

So I modified one line in the script as follows, to store an integer value:
ts = virtualcounter_idx .. "|0|" .. string.format("%d", tostring(countvalue * 100))
And then in Domoticz, Setup / Application Settings, I return to the original value by entering 100 in the RFXMeter/Counter Dividers / Gas field.

HTH.

*Edit: formatting
--
Martijn
roblom
Posts: 402
Joined: Wednesday 26 February 2014 15:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: the Netherlands
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by roblom »

Conn-artist wrote: I tried a similar construction with my gas meter, except I am using a reed switch from Flukso in stead of a KAKU, and the Raspberry Pi GPIO interrupts (and s ingle pull-up resistor). Saves batteries.
Can you provide some more information about how you connect the reed switch to the PRi?
User avatar
Conn-artist
Posts: 21
Joined: Saturday 12 July 2014 12:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8367
Location: 127.0.0.1
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by Conn-artist »

decrxgarage wrote:Can you provide some more information about how you connect the reed switch to the PRi?
I don't have my schematics software installed at the moment so I can't draw it, but it's trivial, really. The reed switch has two connections, see http://elinux.org/File:GPIOs.png for the RaspberryPi GPIO pinout.
  • one connection of the reed switch goes to GND
  • the other one goes to GPIO 23
  • a 10k pullup resistor is added and connected between GPIO 23 and 3V3.
Before starting Domoticz, run the following from the command line (requires GPIO librray from http://wiringpi.com):

gpio export 23 in
gpio edge 23 falling


And then the GPIO 23 will become available in Domoticz and it will switch whenever the reed switch closes.
--
Martijn
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Working: Gasmetersensor based on Kaku doorsensor (15 eur

Post by ThinkPad »

The GPIO solution is very nice Conn-artist. I was already looking for something like that.

I am planning to read the pulse LED of my kWh-meter, and also the gasmeter with a reed-contact/IR-sensor which responds to the little mirror in the zero of the counting reel.

I have two modules: The great advantage of both modules is that they already have an analog to digital part (LM398 / LM393 or something). They both have a analog output which spits out raw values. But they also have a digital output. By adjusting the screw potentiometer, you can configure when the digital output has to be HIGH or LOW. There is also a small LED on the module that will turn on or off simultaneously to the digital output. I already managed to let the LED on the module blink at the same rate as the LED of my kWh-meter 8-) So that part is working.

I will try the scripts mentioned here soon, i think this is a great way to reading your meters in a cheap way!
I am not active on this forum anymore.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests