Skip to content

Instantly share code, notes, and snippets.

@schappim
Created November 22, 2014 04:58
Show Gist options
  • Select an option

  • Save schappim/7caeb20e3891cd54e452 to your computer and use it in GitHub Desktop.

Select an option

Save schappim/7caeb20e3891cd54e452 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
set :bind, '0.0.0.0'
set :port, 80
get '/' do
sensor = '28-000005314719'
file_contents = `cat /sys/bus/w1/devices/#{sensor}/w1_slave`
sensor_reading = file_contents.split("=").last.to_f / 1000
"The temperature is #{sensor_reading} C."
end
get '/camera' do
`raspistill -w 640 -h 480 -t 50 -o ./public/image.jpg`
"<img src='/image.jpg' />"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment