Changeset af9afaf for de.wigbels.ruby/hotcoldrain
- Timestamp:
- 11/23/2014 08:52:47 AM (10 years ago)
- Branches:
- master
- Children:
- daaef3e
- Parents:
- 516b934
- Location:
- de.wigbels.ruby/hotcoldrain
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
de.wigbels.ruby/hotcoldrain/hotcoldrain.rb
r516b934 raf9afaf 28 28 end 29 29 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 30 45 def run 31 46 begin 32 47 while true do 33 48 openformat = @serialport.readline 49 #openformat = "$1;1;;21,3;20,0;;;;;;;50;55;;;;;;;4,9;74;3,0;6;0;0" 34 50 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 48 66 MQTT::Client.connect('mqtt://notwist:pixies@wigbels.net') do |c| 49 c.publish('oben/temperatur', datagrams[ 3])67 c.publish('oben/temperatur', datagrams[0]) 50 68 end 51 69 #log(INFO, 'added 100 liter of gas to sensor-database') … … 58 76 @serialport.close 59 77 end 60 # puts "Filename: "+__FILE__.to_s61 # puts "Linenumber: "+__LINE__.to_s62 # log(WARN, 'warning', 'mymethod' )63 # @log.error('my_method2') { 'Error!' }64 78 end 65 79 end … … 69 83 status = HotColdRain.new("HotColdRain").start 70 84 71 #if status != 072 # puts "Some error occured."73 #endd74 85 75 86 76 87 77 88 78 79
Note:
See TracChangeset
for help on using the changeset viewer.