Created
April 20, 2012 15:29
-
-
Save benhosmer/2429623 to your computer and use it in GitHub Desktop.
Arduino temperature sensor readings from the BMP0895
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A portion of this began as an example sketch from anologReadSerial | |
AnalogReadSerial | |
Reads an analog input on pin 0, prints the result to the serial monitor | |
This example code is in the public domain. | |
*/ | |
/* From http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1267245927 | |
* Somehow incorporate the temperature reading from the BMP0895 | |
* and replace my_room_temperature with that value | |
*/ | |
float val = 0; | |
float RH = 0; | |
void setup() | |
{ | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
val = analogRead(0); | |
delay(500); | |
Serial.println(val); | |
RH = ((((val/1023)*5)-0.8)/3.1)*100; | |
Serial.println(RH); | |
//RH = ((0,0004*20 + 0,149)*val)-(0,0617*20 + 24,436); | |
//Serial.println(RH); | |
delay(500); | |
} | |
//For Centigrade Measurement | |
max_voltage = (3.27-(0.006706*my_room_temperature)) ; // The max voltage value drops down 0.006705882 for each degree C over 0C. The voltage at 0C is 3.27 (corrected for zero precent voltage) | |
// For Fahrenheit Measurement | |
max_voltage = (3.27-(0.00372549*my_room_temperature)) ; // The max voltage value drops down 0.00372549 for each degree F over 32F. The voltage at 32F is 3.27 (corrected for zero precent voltage) | |
/* | |
/* | |
* The original example sketch | |
* | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
int sensorValue = analogRead(A0); | |
Serial.println(sensorValue, DEC); | |
Serial.println("\n"); | |
Serial.println("Humidty Sensor Reading: "); | |
delay(2000); | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment