Сбор информации о погодных условиях
Dependencies: RF24 USBDevice mbed
Revision 4:7cd67d988145, committed 2015-10-28
- Comitter:
- pro100kot14
- Date:
- Wed Oct 28 20:50:56 2015 +0000
- Parent:
- 3:346b49152f1e
- Child:
- 5:ce998523d17d
- Commit message:
- Reorganization of the structure of files
Changed in this revision
--- a/Illumination.h Wed Oct 28 20:49:13 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#ifndef ILLUMINATION_H -#define ILLUMINATION_H - -enum Illumination{ - DARK, VERY_CLOUDLY, CLOUDLY, CLEAR, VERY_SUNNY -}; - -#endif \ No newline at end of file
--- a/Photoresistor.cpp Wed Oct 28 20:49:13 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -#include "Photoresistor.h" - -Photoresistor::Photoresistor(AnalogIn inputChanel):input(inputChanel){} - -Illumination Photoresistor::getIllumination(){ - double realV; - //3.3 - ADC maximum - realV = input.read()*3.3; - - if(realV > 0){ - double resistance = (10.0 * 3.3) / realV - 10.0; //resistance in kOhms. - if(resistance >= 1000.0) return DARK; - if(resistance >= 19.0) return VERY_CLOUDLY; //approximately <10 lx - if(resistance >= 0.7) return CLOUDLY; //approximately <5000 lx - if(resistance >= 0.25) return CLEAR; //approximately <10000 lx - return VERY_SUNNY; //approximately >10000 lx - }else{ - return DARK; //resistance == +inf. No light - } -} \ No newline at end of file
--- a/Photoresistor.h Wed Oct 28 20:49:13 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -#ifndef PHOTORESISTOR_H -#define PHOTORESISTOR_H - -#include "mbed.h" -#include "Illumination.h" -/** -* Reads the resistance of photoresistor and associates it with -* the light level of illumination provided by enum Illumination. -*/ -class Photoresistor{ -public: - /** - * Constructor - * - * @param inputChanel The analog input is connected to the photoresistor - */ - Photoresistor(AnalogIn inputChanel); - - /** - * Level of illumination provided by enum Illumination - * - * @returns Level of illumination - */ - Illumination getIllumination(); - -private: - AnalogIn input; -}; - -#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sensors/Illumination.h Wed Oct 28 20:50:56 2015 +0000 @@ -0,0 +1,8 @@ +#ifndef ILLUMINATION_H +#define ILLUMINATION_H + +enum Illumination{ + DARK, VERY_CLOUDLY, CLOUDLY, CLEAR, VERY_SUNNY +}; + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sensors/Photoresistor.cpp Wed Oct 28 20:50:56 2015 +0000 @@ -0,0 +1,20 @@ +#include "Photoresistor.h" + +Photoresistor::Photoresistor(AnalogIn inputChanel):input(inputChanel){} + +Illumination Photoresistor::getIllumination(){ + double realV; + //3.3 - ADC maximum + realV = input.read()*3.3; + + if(realV > 0){ + double resistance = (10.0 * 3.3) / realV - 10.0; //resistance in kOhms. + if(resistance >= 1000.0) return DARK; + if(resistance >= 19.0) return VERY_CLOUDLY; //approximately <10 lx + if(resistance >= 0.7) return CLOUDLY; //approximately <5000 lx + if(resistance >= 0.25) return CLEAR; //approximately <10000 lx + return VERY_SUNNY; //approximately >10000 lx + }else{ + return DARK; //resistance == +inf. No light + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sensors/Photoresistor.h Wed Oct 28 20:50:56 2015 +0000 @@ -0,0 +1,30 @@ +#ifndef PHOTORESISTOR_H +#define PHOTORESISTOR_H + +#include "mbed.h" +#include "Illumination.h" +/** +* Reads the resistance of photoresistor and associates it with +* the light level of illumination provided by enum Illumination. +*/ +class Photoresistor{ +public: + /** + * Constructor + * + * @param inputChanel The analog input is connected to the photoresistor + */ + Photoresistor(AnalogIn inputChanel); + + /** + * Level of illumination provided by enum Illumination + * + * @returns Level of illumination + */ + Illumination getIllumination(); + +private: + AnalogIn input; +}; + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sensors/Thermistor.cpp Wed Oct 28 20:50:56 2015 +0000 @@ -0,0 +1,56 @@ +#include "Thermistor.h" + +Thermistor::Thermistor(AnalogIn inputChanel, double a, double b, double c):input(inputChanel), error(0){ + this->a = a; + this->b = b; + this->c = c; +} + +double Thermistor::getTemperature(){ + double temp; + double realV; + double resistance; + //3.3 - ADC maximum + realV = input.read()*3.3; + resistance = (10000 * 3.3) / realV - 10000; + //Considering the error + resistance -= error; + //Calculations using Steinhart–Hart equation + temp = log(resistance); + temp = 1/(a+b*temp+c*temp*temp*temp); + //Convert from Fahrenheit to Celsius + temp -= 273.15; + return temp; +} + + void Thermistor::setError(double error){ + this->error = error; + } + + double Thermistor::getError(){ + return error; + } + + void Thermistor::setCoefficientA(double a){ + this->a = a; + } + + void Thermistor::setCoefficientB(double b){ + this->b = b; + } + + void Thermistor::setCoefficientC(double c){ + this->c = c; + } + + double Thermistor::getCoefficientA(){ + return a; + } + + double Thermistor::getCoefficientB(){ + return b; + } + + double Thermistor::getCoefficientC(){ + return c; + } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sensors/Thermistor.h Wed Oct 28 20:50:56 2015 +0000 @@ -0,0 +1,88 @@ +#ifndef Thermistor_H +#define Thermistor_H + +#include "mbed.h" +#include <math.h> +/** +* Reads the resistance of thermistor and using Steinhart–Hart equation +* converts it to Celsius +* +*/ +class Thermistor{ +public: + /** + * Constructor. In the calculations used a model of + * the resistance of a semiconductor at different temperatures - + * The Steinhart–Hart equation. Need to set the coefficients a, b, c. + * + * @param inputChanel The analog input is connected to the sensor + * @param a Steinhart–Hart coefficient + * @param b Steinhart–Hart coefficient + * @param c Steinhart–Hart coefficient + */ + Thermistor(AnalogIn inputChanel, double a, double b, double c); + + /** + * The temperature in degrees Celsius + * @returns Temperature + */ + double getTemperature(); + + /** + * Set error value used in the calculation. + * The resulting resistance is computed as <real resistance> - error; + * @param error Error in Ohms + */ + void setError(double error); + + /** + * Error value used in the calculation + * The resulting resistance is computed as <real resistance> - error; + * @returns Error in Ohms + */ + double getError(); + + /** + * Set a coefficient of Steinhart–Hart equation + * @param a a-coefficient + */ + void setCoefficientA(double a); + + /** + * Set b coefficient of Steinhart–Hart equation + * @param b b-coefficient + */ + void setCoefficientB(double b); + + /** + * Set c coefficient of Steinhart–Hart equation + * @param c c-coefficient + */ + void setCoefficientC(double c); + + /** + * a coefficient of Steinhart–Hart equation + * @returns a coefficient + */ + double getCoefficientA(); + + /** + * b coefficient of Steinhart–Hart equation + * @returns b coefficient + */ + double getCoefficientB(); + + /** + * c coefficient of Steinhart–Hart equation + * @returns c coefficient + */ + double getCoefficientC(); + +private: + AnalogIn input; + //Thermistor error in Ohms + double error; + double a, b, c; +}; + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sensors/ThermometerTmp36.cpp Wed Oct 28 20:50:56 2015 +0000 @@ -0,0 +1,14 @@ +#include "ThermometerTmp36.h" + +double ThermometerTmp36::getTemperature(){ + double temp; + double realV; + //3.3 - ADC maximum + realV = input.read()*3.3; + //500mV - voltage in 0 degree + //For mo information look datasheet + //Low Voltage Temperature Sensors TMP35/TMP36/TMP37 + //Page 5 of 20, Figure 6 (Output Voltage vs. Temperature) + temp = (realV - 0.5)*100; + return temp; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sensors/ThermometerTmp36.h Wed Oct 28 20:50:56 2015 +0000 @@ -0,0 +1,29 @@ +#ifndef ThermometerTMP36_H +#define ThermometerTMP36_H + +#include "mbed.h" +/** +* Reads the data from the sensor TMP36, +* connected to the analog input and converts them to Celsius +*/ +class ThermometerTmp36{ +public: + /** + * Constructor + * + * @param inputChanel The analog input is connected to the sensor + */ + ThermometerTmp36(AnalogIn inputChanel):input(inputChanel){} + + /** + * The temperature in degrees Celsius + * + * @returns Temperature + */ + double getTemperature(); + +private: + AnalogIn input; +}; + +#endif \ No newline at end of file
--- a/Thermistor.cpp Wed Oct 28 20:49:13 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -#include "Thermistor.h" - -Thermistor::Thermistor(AnalogIn inputChanel, double a, double b, double c):input(inputChanel), error(0){ - this->a = a; - this->b = b; - this->c = c; -} - -double Thermistor::getTemperature(){ - double temp; - double realV; - double resistance; - //3.3 - ADC maximum - realV = input.read()*3.3; - resistance = (10000 * 3.3) / realV - 10000; - //Considering the error - resistance -= error; - //Calculations using Steinhart–Hart equation - temp = log(resistance); - temp = 1/(a+b*temp+c*temp*temp*temp); - //Convert from Fahrenheit to Celsius - temp -= 273.15; - return temp; -} - - void Thermistor::setError(double error){ - this->error = error; - } - - double Thermistor::getError(){ - return error; - } - - void Thermistor::setCoefficientA(double a){ - this->a = a; - } - - void Thermistor::setCoefficientB(double b){ - this->b = b; - } - - void Thermistor::setCoefficientC(double c){ - this->c = c; - } - - double Thermistor::getCoefficientA(){ - return a; - } - - double Thermistor::getCoefficientB(){ - return b; - } - - double Thermistor::getCoefficientC(){ - return c; - } \ No newline at end of file
--- a/Thermistor.h Wed Oct 28 20:49:13 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -#ifndef Thermistor_H -#define Thermistor_H - -#include "mbed.h" -#include <math.h> -/** -* Reads the resistance of thermistor and using Steinhart–Hart equation -* converts it to Celsius -* -*/ -class Thermistor{ -public: - /** - * Constructor. In the calculations used a model of - * the resistance of a semiconductor at different temperatures - - * The Steinhart–Hart equation. Need to set the coefficients a, b, c. - * - * @param inputChanel The analog input is connected to the sensor - * @param a Steinhart–Hart coefficient - * @param b Steinhart–Hart coefficient - * @param c Steinhart–Hart coefficient - */ - Thermistor(AnalogIn inputChanel, double a, double b, double c); - - /** - * The temperature in degrees Celsius - * @returns Temperature - */ - double getTemperature(); - - /** - * Set error value used in the calculation. - * The resulting resistance is computed as <real resistance> - error; - * @param error Error in Ohms - */ - void setError(double error); - - /** - * Error value used in the calculation - * The resulting resistance is computed as <real resistance> - error; - * @returns Error in Ohms - */ - double getError(); - - /** - * Set a coefficient of Steinhart–Hart equation - * @param a a-coefficient - */ - void setCoefficientA(double a); - - /** - * Set b coefficient of Steinhart–Hart equation - * @param b b-coefficient - */ - void setCoefficientB(double b); - - /** - * Set c coefficient of Steinhart–Hart equation - * @param c c-coefficient - */ - void setCoefficientC(double c); - - /** - * a coefficient of Steinhart–Hart equation - * @returns a coefficient - */ - double getCoefficientA(); - - /** - * b coefficient of Steinhart–Hart equation - * @returns b coefficient - */ - double getCoefficientB(); - - /** - * c coefficient of Steinhart–Hart equation - * @returns c coefficient - */ - double getCoefficientC(); - -private: - AnalogIn input; - //Thermistor error in Ohms - double error; - double a, b, c; -}; - -#endif \ No newline at end of file
--- a/ThermometerTmp36.cpp Wed Oct 28 20:49:13 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -#include "ThermometerTmp36.h" - -double ThermometerTmp36::getTemperature(){ - double temp; - double realV; - //3.3 - ADC maximum - realV = input.read()*3.3; - //500mV - voltage in 0 degree - //For mo information look datasheet - //Low Voltage Temperature Sensors TMP35/TMP36/TMP37 - //Page 5 of 20, Figure 6 (Output Voltage vs. Temperature) - temp = (realV - 0.5)*100; - return temp; -} \ No newline at end of file
--- a/ThermometerTmp36.h Wed Oct 28 20:49:13 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -#ifndef ThermometerTMP36_H -#define ThermometerTMP36_H - -#include "mbed.h" -/** -* Reads the data from the sensor TMP36, -* connected to the analog input and converts them to Celsius -*/ -class ThermometerTmp36{ -public: - /** - * Constructor - * - * @param inputChanel The analog input is connected to the sensor - */ - ThermometerTmp36(AnalogIn inputChanel):input(inputChanel){} - - /** - * The temperature in degrees Celsius - * - * @returns Temperature - */ - double getTemperature(); - -private: - AnalogIn input; -}; - -#endif \ No newline at end of file