source: de.wigbels.ruby/hothotread/hothotpiper.rb @ 60b92db

Last change on this file since 60b92db was 53aed1c, checked in by Norbert Wigbels <njw@…>, 10 years ago

Gaszaehler mit RRDTool-Auswertung

  • Property mode set to 100644
File size: 797 bytes
RevLine 
[0955336]1#!/usr/bin/env ruby
2#
3# Author: Norbert Wigbels - foobla.wigbels.de/uber-foobla
4#
5# HotHotPiper continously reads the status of a
6# reed contact attached to the Raspberry Pi GPIO
7#
8# The reed measures gas usage.
9#
10# A magig URL is formed and called; the url
11# stores the sensor-data to wigbels.net
12#
13# todo: status-led
14#
15
16#------------------------------------------
17# Tainted mode 0-4
18$SAFE=0
19
20#------------------------------------------
21require 'net/http'
22require 'pi_piper'
23
24include PiPiper
25
[53aed1c]26$mypath = File.expand_path(File.dirname(__FILE__))
[daaef3e]27
[0955336]28
29watch :pin => 4, :trigger => :falling do 
[4fd0ab9]30  puts('added 10 liter of gas to sensor-database')
[0955336]31  Net::HTTP.get(URI.parse('http://www.wigbels.net/cgi-bin/hhw.rb?sensorid=1&data=10'))
[53aed1c]32  system("rrdtool update #{$mypath}/gas.rrd N:10")
[0955336]33end
34
35PiPiper.wait
Note: See TracBrowser for help on using the repository browser.