Сбор информации о погодных условиях

Dependencies:   RF24 USBDevice mbed

Committer:
pro100kot14
Date:
Thu Oct 22 20:31:06 2015 +0000
Revision:
2:ad2653bcf93f
Child:
3:346b49152f1e
Added the class of information processing with photoresist with the interpretation of it as light levels.; Added lighting classification as enum Illumination; Fixed bug in calculation of the temperature read from thermistor.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pro100kot14 2:ad2653bcf93f 1 #include "Photoresistor.h"
pro100kot14 2:ad2653bcf93f 2
pro100kot14 2:ad2653bcf93f 3 Photoresistor::Photoresistor(AnalogIn inputChanel):input(inputChanel){}
pro100kot14 2:ad2653bcf93f 4
pro100kot14 2:ad2653bcf93f 5 Illumination Photoresistor::getIllumination(){
pro100kot14 2:ad2653bcf93f 6 double realV;
pro100kot14 2:ad2653bcf93f 7 //3.3 - ADC maximum
pro100kot14 2:ad2653bcf93f 8 realV = input.read()*3.3;
pro100kot14 2:ad2653bcf93f 9
pro100kot14 2:ad2653bcf93f 10 if(realV > 0){
pro100kot14 2:ad2653bcf93f 11 double resistance = (10.0 * 3.3) / realV - 10.0; //resistance in kOhms.
pro100kot14 2:ad2653bcf93f 12 if(resistance >= 1000.0) return dark;
pro100kot14 2:ad2653bcf93f 13 if(resistance >= 19.0) return veryCloudy; //approximately <10 lx
pro100kot14 2:ad2653bcf93f 14 if(resistance >= 0.7) return cloudy; //approximately <5000 lx
pro100kot14 2:ad2653bcf93f 15 if(resistance >= 0.25) return clear; //approximately <10000 lx
pro100kot14 2:ad2653bcf93f 16 return verySunny; //approximately >10000 lx
pro100kot14 2:ad2653bcf93f 17 }else{
pro100kot14 2:ad2653bcf93f 18 return dark; //resistance == +inf. No light
pro100kot14 2:ad2653bcf93f 19 }
pro100kot14 2:ad2653bcf93f 20 }