Skip to content

Instantly share code, notes, and snippets.

@benhosmer
Created April 20, 2012 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhosmer/2429623 to your computer and use it in GitHub Desktop.
Save benhosmer/2429623 to your computer and use it in GitHub Desktop.
Arduino temperature sensor readings from the BMP0895
/*
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