Skip to content

Instantly share code, notes, and snippets.

@schappim
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save schappim/166aca330c88223de709 to your computer and use it in GitHub Desktop.

Select an option

Save schappim/166aca330c88223de709 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'w1temp'
require 'artoo'
require 'httparty'
sensor = Temperature.new
host = `ifconfig | grep -i Bcast`.split(' ')[5].split(':').last
api :host => host, :port => '4321'
connection :raspi, :adaptor => :raspi
device :led, :driver => :led, :pin => 15
work do
every 1.second do
led.toggle
@result = HTTParty.post("http://littlebirdiot.herokuapp.com/update",
:body => { :sensor => sensor.name,
:reading => sensor.reading}
)
puts sensor.name
puts sensor.reading
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment