Thanks. Tried that however somehow the counter went bold and is counting 'something' but no kWh. Meter is still on the same kWh total while according to my mounter, it already used 2kWh since the start:
2016-07-30;14:43:34;1469882614;26994;13
2016-07-30;14:44:34;1469882674;29993;431
2016-07-30;14:45:34;1469882734;32992;990
2016-07-30;14:46:34;1469882794;35991;1529
2016-07-30;14:47:34;1469882854;38990;2158
Thing is that the manual that came with the meter doesn't show any information about input voltage etc for this meter like the one you've send. The PDF of this meter you can find here: sdm120c
The lua script I'm using is like:
pin = 2
min_pw_ms = 20
upload_rate_ms = 60000
pulse_detected = 0
timestamp = 0
counter = 0
conn = nil
gpio.mode(pin, gpio.INT)
function pin1up(level)
pulse_detected = 1
end
function maintask()
print("Counter is:"..counter)
if not wifi.sta.getip() then
print("Connecting to AP, Waiting...")
else
-- gpio.write(0, gpio.HIGH)
print("Uploading to server...")
upload()
end
end
function pulsetask()
timestamp = timestamp + 1
if pulse_detected == 1 then
counter = counter + 1
pulse_detected = 0
end
end
gpio.trig(pin, "up", pin1up)
tmr.alarm(0, upload_rate_ms, 1, maintask);
tmr.alarm(1, min_pw_ms, 1, pulsetask);
maintask();
Update: Just found some other schematics.. maybe I'm missing some pull-up/down ... going to do some more testing ;o)