Changeset af9afaf


Ignore:
Timestamp:
11/23/2014 08:52:47 AM (10 years ago)
Author:
njw <njw@…>
Branches:
master
Children:
daaef3e
Parents:
516b934
Message:

RRD Support, Testing mit MQTT

Location:
de.wigbels.ruby/hotcoldrain
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • de.wigbels.ruby/hotcoldrain/hotcoldrain.rb

    r516b934 raf9afaf  
    2828  end
    2929
     30  def logOutReadableData(datagrams)
     31    puts "TemperaturUnten: " + datagrams[3]
     32    puts "LuftfeuchtigkeitUnten: " + datagrams[11]
     33    puts
     34    puts "TemperaturOben: " + datagrams[4]
     35    puts "LuftfeuchtigkeitOben: " + datagrams[12]
     36    puts       
     37    puts "TemperaturAussen: " + datagrams[19]
     38    puts "LuftfeuchtigkeitAussen: " + datagrams[20]
     39    puts "Windgeschwindigkeit km/h: " + datagrams[21]
     40    puts "Niederschlag: " + datagrams[22]
     41    puts "Regen ja/nein: " + datagrams[23]       
     42    puts "---------------------"
     43  end
     44
    3045  def run
    3146    begin
    3247      while true do
    3348        openformat = @serialport.readline
     49        #openformat = "$1;1;;21,3;20,0;;;;;;;50;55;;;;;;;4,9;74;3,0;6;0;0"
    3450        datagrams = openformat.split(';')
    35 #        puts openformat
    36         puts "TemperaturUnten: " + datagrams[3]
    37         puts "LuftfeuchtigkeitUnten: " + datagrams[11]
    38         puts
    39         puts "TemperaturOben: " + datagrams[4]
    40         puts "LuftfeuchtigkeitOben: " + datagrams[12]
    41         puts       
    42         puts "TemperaturAussen: " + datagrams[19]
    43         puts "LuftfeuchtigkeitAussen: " + datagrams[20]
    44         puts "Windgeschwindigkeit km/h: " + datagrams[21]
    45         puts "Niederschlag: " + datagrams[22]
    46         puts "Regen ja/nein: " + datagrams[23]       
    47         puts "---------------------"
     51
     52        logOutReadableData(datagrams)
     53
     54        # $1;1;;21,3;20,0;;;;;;;50;55;;;;;;;4,9;74;3,0;6;0;0
     55        # extract only data
     56        # then replace empty data with U
     57        # then localize float value
     58        # finally prepare updatestring for rrdtool
     59        datagrams = datagrams.values_at(3..23)
     60        datagrams.collect! { |element| (element.empty?) ? "U" : element }
     61        datagrams.collect! { |element| (element.include? ',') ? element.sub!(',','.') : element }
     62        rrddata = 'N:'+datagrams.join(':')
     63
     64        system("rrdtool update weather.rrd #{rrddata}")
     65
    4866        MQTT::Client.connect('mqtt://notwist:pixies@wigbels.net') do |c|
    49           c.publish('oben/temperatur', datagrams[3])
     67          c.publish('oben/temperatur', datagrams[0])
    5068        end
    5169        #log(INFO, 'added 100 liter of gas to sensor-database')
     
    5876      @serialport.close
    5977    end
    60 #    puts "Filename: "+__FILE__.to_s
    61 #    puts "Linenumber: "+__LINE__.to_s
    62 #    log(WARN, 'warning',  'mymethod' )
    63 #    @log.error('my_method2') { 'Error!' }
    6478  end
    6579end
     
    6983status = HotColdRain.new("HotColdRain").start
    7084
    71 #if status != 0
    72 #  puts "Some error occured."
    73 #endd
    7485
    7586
    7687
    7788
    78 
    79 
Note: See TracChangeset for help on using the changeset viewer.