1 /* 2 * Author: Jon Trulson <jtrulson@ics.com> 3 * Copyright (c) 2015 Intel Corporation. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining 6 * a copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sublicense, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be 14 * included in all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 #pragma once 25 26 #include <iostream> 27 #include <string> 28 #include <mraa/aio.hpp> 29 30 namespace upm { 31 /** 32 * @brief DFRobot LM35 Linear Temperature Sensor 33 * @defgroup lm35 libupm-lm35 34 * @ingroup dfrobot analog temp 35 */ 36 37 /** 38 * @library lm35 39 * @sensor lm35 40 * @comname DFRobot LM35 Linear Temperature Sensor 41 * @altname LM35 42 * @type temp 43 * @man dfrobot 44 * @web http://www.dfrobot.com/index.php?route=product/product&product_id=76 45 * @con analog 46 * 47 * @brief API for the DFRobot LM35 Linear Temperature Sensor 48 * 49 * This sensor returns an analog voltage proportional to the 50 * temperature of the ambient environment. 51 * 52 * It has a range of 2C to 150C. 53 * 54 * This driver was developed using the DFRobot LM35 Linear 55 * Temperature Sensor 56 * 57 * @snippet lm35.cxx Interesting 58 */ 59 60 class LM35 { 61 public: 62 63 /** 64 * LM35 constructor 65 * 66 * @param pin Analog pin to use 67 * @param aref Analog reference voltage; default is 5.0 V 68 */ 69 LM35(int pin, float aref=5.0); 70 71 /** 72 * LM35 destructor 73 */ 74 ~LM35(); 75 76 /** 77 * Returns the temperature in degrees Celcius 78 * 79 * @return The Temperature in degrees Celcius 80 */ 81 float getTemperature(); 82 83 protected: 84 mraa::Aio m_aio; 85 86 private: 87 float m_aref; 88 // ADC resolution 89 int m_aRes; 90 }; 91 } 92 93 94