139 lines
4.3 KiB
C++
Executable File
139 lines
4.3 KiB
C++
Executable File
// adapted sketch by niq_ro from http://nicuflorica.blogspot.ro/ & http://arduinotehniq.blogspot.com/
|
|
// https://github.com/adafruit/Adafruit-BMP085-Library
|
|
#include <Wire.h>
|
|
#include <Adafruit_BMP085.h>
|
|
|
|
/***************************************************
|
|
This is an example for the BMP085 Barometric Pressure & Temp Sensor
|
|
Designed specifically to work with the Adafruit BMP085 Breakout
|
|
----> https://www.adafruit.com/products/391
|
|
These displays use I2C to communicate, 2 pins are required to
|
|
interface
|
|
Adafruit invests time and resources providing this open source code,
|
|
please support Adafruit and open-source hardware by purchasing
|
|
products from Adafruit!
|
|
|
|
Written by Limor Fried/Ladyada for Adafruit Industries.
|
|
BSD license, all text above must be included in any redistribution
|
|
****************************************************/
|
|
|
|
// Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!)
|
|
// Connect GND to Ground
|
|
// Connect SCL to i2c clock - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 5
|
|
// Connect SDA to i2c data - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 4
|
|
// EOC is not used, it signifies an end of conversion
|
|
// XCLR is a reset pin, also not used here
|
|
|
|
// include the library code:
|
|
#include <LiquidCrystal.h>
|
|
// initialize the library with the numbers of the interface pins
|
|
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
|
|
|
|
/* -------------------
|
|
| LCD | Arduino |
|
|
-------------------
|
|
LCD RS pin to digital pin 7 | RS | D7 |
|
|
LCD Enable pin to digital pin 6 | E | D6 |
|
|
LCD D4 pin to digital pin 5 | D4 | D6 |
|
|
LCD D5 pin to digital pin 4 | D5 | D4 |
|
|
LCD D6 pin to digital pin 3 | D6 | D3 |
|
|
LCD D7 pin to digital pin 2 | D7 | D2 |
|
|
LCD R/W pin to ground | R/W | GND |
|
|
-------------------
|
|
*/
|
|
|
|
|
|
|
|
Adafruit_BMP085 bmp;
|
|
|
|
void setup() {
|
|
lcd.begin(16, 2);
|
|
// Print a logo message to the LCD.
|
|
lcd.print("www.tehnic.go.ro");
|
|
lcd.setCursor(0, 1);
|
|
lcd.print("creat de niq_ro");
|
|
delay (2500);
|
|
lcd.clear();
|
|
|
|
// Print another message to the LCD.
|
|
lcd.setCursor(2, 0);
|
|
lcd.print("Thermometre -");
|
|
lcd.setCursor(0, 1);
|
|
lcd.print("barometre ver1.0");
|
|
delay (2500);
|
|
lcd.clear();
|
|
|
|
Serial.begin(9600);
|
|
if (!bmp.begin()) {
|
|
Serial.println("nu exita senzor compatibil BMP085 sau BMP180");
|
|
while (1) {}
|
|
}
|
|
}
|
|
|
|
void loop() {
|
|
Serial.print("Temperature = ");
|
|
Serial.print(bmp.readTemperature());
|
|
Serial.println(" *C");
|
|
|
|
Serial.print("Pression = ");
|
|
Serial.print(bmp.readPressure());
|
|
Serial.print(" Pa / ");
|
|
|
|
// Serial.print("Presiune = ");
|
|
float pression = bmp.readPressure()/101.325;
|
|
pression = pression * 0.760;
|
|
Serial.print(pression);
|
|
Serial.println(" mmHg");
|
|
|
|
|
|
// Calculate altitude assuming 'standard' barometric
|
|
// pressure of 1013.25 millibar = 101325 Pascal
|
|
Serial.print("Altitude = ");
|
|
Serial.print(bmp.readAltitude());
|
|
Serial.println(" m");
|
|
|
|
Serial.print("Pression au niveau de la mer (calculée) = ");
|
|
Serial.print(bmp.readSealevelPressure());
|
|
Serial.print(" Pa / ");
|
|
|
|
// http://en.wikipedia.org/wiki/Atmospheric_pressure#Mean_sea_level_pressure
|
|
// Serial.print("Presiure la nivelul marii (calculata) = ");
|
|
float presiune = bmp.readSealevelPressure()/101.325;
|
|
presiune = presiune * 0.760;
|
|
Serial.print(presiune);
|
|
Serial.println(" mmHg");
|
|
|
|
|
|
// you can get a more precise measurement of altitude
|
|
// if you know the current sea level pressure which will
|
|
// vary with weather and such. If it is 1015 millibars
|
|
// that is equal to 101500 Pascals.
|
|
Serial.print("Altitude réelle = ");
|
|
Serial.print(bmp.readAltitude(101500));
|
|
Serial.println(" m");
|
|
|
|
Serial.println();
|
|
|
|
|
|
lcd.setCursor(1, 0);
|
|
lcd.print("temp.= ");
|
|
if ( bmp.readTemperature() < 10)
|
|
{
|
|
lcd.print(" ");
|
|
lcd.print(bmp.readTemperature());
|
|
}
|
|
else
|
|
{
|
|
lcd.print(bmp.readTemperature(),1);
|
|
}
|
|
lcd.write(0b11011111);
|
|
lcd.print("C ");
|
|
|
|
lcd.setCursor(1, 1);
|
|
lcd.print("pres.= p");
|
|
lcd.print(presiune,0);
|
|
lcd.print("mmHg ");
|
|
|
|
delay(2500);
|
|
}
|