Class: RaspberryPi::ThermalSensor
- Inherits:
-
IoT::TemperatureSensor
- Object
- IoT::Receptor
- IoT::DigitalReceptor
- IoT::DigitalSensor
- IoT::TemperatureSensor
- RaspberryPi::ThermalSensor
- Defined in:
- lib/thermal_sensor.rb
Instance Method Summary collapse
-
#initialize ⇒ ThermalSensor
constructor
A new instance of ThermalSensor.
- #read_data ⇒ Object
Methods inherited from IoT::TemperatureSensor
#celsius, #fahrenheit, #kelvin, #reaumur, #temperature, #to_s
Methods inherited from IoT::DigitalReceptor
Methods inherited from IoT::Receptor
Constructor Details
#initialize ⇒ ThermalSensor
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_data ⇒ Object
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 |