Total Pageviews

Saturday, October 18, 2014

BMP180 sensor and Arduino

   BMP180 sensor can give us information about pressure an temperature.
   This sensor is delivered on small module with 4 pins: Vin (+3.3V), GND, SDA and SCL.
   For testing, schematic is very simple:
   For control BMP180 sensor I use Adafruit-BMP085-Library, them test the example sketch.
   For a stand alone weather station with information about temperature and presure, I put a alphanumeric LCD display with 16 colons and 2 rows (1602):
and test montage is:
   I use this sketch:
// 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("termometru -");  
  lcd.setCursor(0, 1);
  lcd.print("barometru 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("Temperatura = ");
    Serial.print(bmp.readTemperature());
    Serial.println(" *C");
    
    Serial.print("Presiune = ");
    Serial.print(bmp.readPressure());
    Serial.print(" Pa / ");
    
 //   Serial.print("Presiune = ");
    float presiune1 = bmp.readPressure()/101.325;
    presiune1 = presiune1 * 0.760;
    Serial.print(presiune1);
    Serial.println(" mmHg");
    
    
    // Calculate altitude assuming 'standard' barometric
    // pressure of 1013.25 millibar = 101325 Pascal
    Serial.print("Altitudine = ");
    Serial.print(bmp.readAltitude());
    Serial.println(" m");

    Serial.print("Presiune la nivelul marii (calculata) = ");
    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("Altitudine reala = ");
    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);
}
24.11.2014
   In last weak-end, I received 3 pics from Dave (http://g4rvh.wordpress.com/) with a shield for Arduino Uno, made after my schematic:
   He made with board with CNC Cutter:
   I change the sketch for present the temperature in Fahrenheit, not in Celsius degree, using information from article http://www.mathsisfun.com/temperature-conversion.html:

14 comments:

  1. Replies
    1. thx... a photo with montage can send to me for put on article?

      Delete
  2. not Work... RA9YS

    ReplyDelete
  3. Arduino: 1.6.4 (Windows 8.1), Плата"Arduino Uno"

    sketch_jun20c.ino: In function 'void loop()':
    sketch_jun20c:94: error: 'class Adafruit_BMP085' has no member named 'readSealevelPressure'
    sketch_jun20c:99: error: 'class Adafruit_BMP085' has no member named 'readSealevelPressure'
    Multiple libraries were found for "Adafruit_BMP085.h"

    Used: C:\Users\user\Documents\Arduino\libraries\Adafruit_BMP085

    Not used: C:\Program Files (x86)\Arduino\libraries\Adafruit-BMP085-Library-master

    Not used: C:\Program Files (x86)\Arduino\libraries\Adafruit_BMP085

    Multiple libraries were found for "LiquidCrystal.h"

    Used: C:\Users\user\Documents\Arduino\libraries\LiquidCrystal

    Not used: C:\Users\user\Documents\Arduino\libraries\LiquidCrystal_I2C

    Not used: C:\Program Files (x86)\Arduino\libraries\LiquidCrystal

    Not used: C:\Program Files (x86)\Arduino\libraries\LiquidCrystal_I2C

    'class Adafruit_BMP085' has no member named 'readSealevelPressure'

    de RA9YS

    ReplyDelete
    Replies
    1. in sketch it use some data:
      // https://github.com/adafruit/Adafruit-BMP085-Library
      ...
      #include
      go to this link and download sensor library to work...

      Delete
  4. Hi. I'm using a BMP180 to read the pressure. But at !bmp.begin() it gives me the error message and stops. Can you help clear this out for me pleasE?

    ReplyDelete
    Replies
    1. you have error when you compile/verify the sketch? or after upload the sketch?
      you have Adafruit_BMP085.h from https://github.com/adafruit/Adafruit-BMP085-Library ?
      what Arduino board you use?

      Delete
  5. felicitari !!!
    folosesc un bmp280, verific sketch totul ok.il scriu pe arduino totul ok.
    dar nu imi afiseaza nimic pe display !!!!!
    oare ce am gresit?
    de la bmp 280 la arduiono folosesc: VCC- 3.3 v; gnd-gnd; scl-a5; sda-a4

    ReplyDelete
    Replies
    1. eu am folosit BMP180... afisajul trebuia sa indice macar "Temp.=" si "Pres.="
      vad pe net ca BMP280 e total diferit: http://www.instructables.com/id/How-to-Use-the-Adafruit-BMP280-Sensor-Arduino-Tuto/

      Delete
    2. am conectat doar bmp 280 la arduino asa :VCC- 3.3 v; gnd-gnd; scl-a5; sda-a4, si cand citesc cu putty imi vin date de temp si presiune, dar cand folosesc si lcd (se lumineaza displayul dar nu afiseaza nimik)
      mmmhhhhhh????
      PS: am alimentat bmp280 si pe 5 v dar tot nimik

      Delete
  6. RESPECT pt ceea ce faci si pt faptul ca invetii si pe altii.blogul tau e o comoara informationala .LA CIT MAI MULTE PROIECTE BRAVO !

    ReplyDelete
  7. Focus on the consumer electronics charging products such as Power banks, Wireless Charge, Power Adaptors. We create products that help people realize the power of technology and make people’s lives better, easier and more fulfilling.

    ReplyDelete
  8. Focus on the consumer electronics charging products such as Power banks, Wireless Charge, Power Adaptors. We create products that help people realize the power of technology and make people’s lives better, easier and more fulfilling.

    ReplyDelete
  9. Focus on the consumer electronics charging products such as Power banks, Wireless Charge, Power Adaptors. We create products that help people realize the power of technology and make people’s lives better, easier and more fulfilling.

    ReplyDelete