Photo: And a battery powered wireless Raspberry Pi.
Photo: And finally a nice see-through case for the Pi.
Photo: The Pi with Eye
Photo: The first attempt measuring the magnetic pulses generated by our gas meter. Between the red and green plugs is a reed switch. In this position the reed switch get two on signals for complete turn of the rightmost dial. The cables lead to a nearby Raspberry Pi, see next picture.
Photo: The Raspberry Pi with a Piface reading the pulses from the gas meter or rather the reed switch. This is done with very simple Python code


#!/usr/bin/python
from time import sleep
from time import mktime
from time import gmtime
import datetime
import piface.pfio as pfio
pfio.init()
lastread = 0
total = 0
while(True):
     myread = pfio.digital_read(0)
     if myread != lastread:
           date = mktime(gmtime())
           total = total + myread
           print datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),",",date, ",",myread,",",total
           lastread = myread
     sleep(0.01)


The script gets fired off with 
nohup stdbuf -o0 ./read.py > test.out&
to make sure it happily runs in the bachground. When you turn on the hot water you can then see the logfile showing each turn of the smallest wheel. The counts are pretty accurate, at least if you believe my daily readings.
Loading...
Uli Harder
Public
The Pi with Eye