#!/usr/bin/env ruby # # Author: Norbert Wigbels - foobla.wigbels.de/uber-foobla # # HotHotPiper continously reads the status of a # reed contact attached to the Raspberry Pi GPIO # # The reed measures gas usage. # # A magig URL is formed and called; the url # stores the sensor-data to wigbels.net # # todo: status-led # #------------------------------------------ # Tainted mode 0-4 $SAFE=0 #------------------------------------------ require 'net/http' require 'pi_piper' include PiPiper $mypath = File.expand_path(File.dirname(__FILE__)) watch :pin => 4, :trigger => :falling do puts('added 10 liter of gas to sensor-database') Net::HTTP.get(URI.parse('http://www.wigbels.net/cgi-bin/hhw.rb?sensorid=1&data=10')) system("rrdtool update #{$mypath}/gas.rrd N:10") end PiPiper.wait