Class: RaspberryPi::ThermalSensor

Inherits:
IoT::TemperatureSensor show all
Defined in:
lib/thermal_sensor.rb

Instance Method Summary collapse

Methods inherited from IoT::TemperatureSensor

#celsius, #fahrenheit, #kelvin, #reaumur, #temperature, #to_s

Methods inherited from IoT::DigitalReceptor

one_wire_file

Methods inherited from IoT::Receptor

#model_name, #name, #read

Constructor Details

#initializeThermalSensor

Returns a new instance of ThermalSensor.



7
8
9
10
# File 'lib/thermal_sensor.rb', line 7

def initialize
  @name = 'Internal Thermal Zone'
  super
end

Instance Method Details

#read_dataObject



12
13
14
15
16
17
18
19
# File 'lib/thermal_sensor.rb', line 12

def read_data
  @sensor_file = '/sys/class/thermal/thermal_zone0/temp'
  File.open(@sensor_file, 'r') do |f|
    value = f.read
    @temperature = value.to_i / 1000.00
  end
  @temperature
end