Arduino Yun compatibility with bmp180

I recently purchased the Arduino Yun and the BMP180 Barometric Pressure/Temperature/Altitude Sensor (http://www.adafruit.com/products/1603) from Adafruit and was hoping to log some data and possibly push the data up to the cloud somewhere (TBD). However, I’m having trouble getting the sensor to work with the Yun. I’ve modified the code from the example given on the adafruit site for this sensor. The original code uses a Serial object to write data to the serial monitor. However, from what I understand, that isn’t possible since I’m using Yun and connnected to it wirelessly. So instead, I’m using the Console object. When using the non-modified code from adafruit and instead connecting the sensor to an Arduino Uno, the sensor works perfectly. But when using my modified code on the Yun, it appears to get stuck when trying to check if the bmp sensor is running ( at this line: if(!bmp.begin())). Any thoughts? I’m probably overlooking the obvious. Here’s my code:

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085_U.h>
#include <Console.h>

/* This driver uses the Adafruit unified sensor library (Adafruit_Sensor),
   which provides a common 'type' for sensor data and some helper functions.
   
   To use this driver you will also need to download the Adafruit_Sensor
   library and include it in your libraries folder.

   You should also assign a unique ID to this sensor for use with
   the Adafruit Sensor API so that you can identify this particular
   sensor in any data logs, etc.  To assign a unique ID, simply
   provide an appropriate value in the constructor below (12345
   is used by default in this example).
   
   Connections
   ===========
   Connect SCL to analog 5
   Connect SDA to analog 4
   Connect VDD to 3.3V DC
   Connect GROUND to common ground
    
   History
   =======
   2013/JUN/17  - Updated altitude calculations (KTOWN)
   2013/FEB/13  - First version (KTOWN)
*/
   
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);

/**************************************************************************/
/*
    Displays some basic information on this sensor from the unified
    sensor API sensor_t type (see Adafruit_Sensor for more information)
*/
/**************************************************************************/
void displaySensorDetails(void)
{
  sensor_t sensor;
  bmp.getSensor(&sensor);
  Console.println("------------------------------------");
  Console.print  ("Sensor:       "); Console.println(sensor.name);
  Console.print  ("Driver Ver:   "); Console.println(sensor.version);
  Console.print  ("Unique ID:    "); Console.println(sensor.sensor_id);
  Console.print  ("Max Value:    "); Console.print(sensor.max_value); Console.println(" hPa");
  Console.print  ("Min Value:    "); Console.print(sensor.min_value); Console.println(" hPa");
  Console.print  ("Resolution:   "); Console.print(sensor.resolution); Console.println(" hPa");  
  Console.println("------------------------------------");
  Console.println("");
  delay(500);
}

/**************************************************************************/
/*
    Arduino setup function (automatically called at startup)
*/
/**************************************************************************/
void setup(void) 
{
  //Serial.begin(9600);
  Bridge.begin();
  Console.begin();
  
  while (!Console){
    ; // wait for Console port to connect.
  }
  
  Console.println("Pressure Sensor Test"); Console.println("");
  
  /* Initialise the sensor */
  if(!bmp.begin())
  {
    /* There was a problem detecting the BMP085 ... check your connections */
    Console.print("Ooops, no BMP085 detected ... Check your wiring or I2C ADDR!");
    while(1);
  }
  
  /* Display some basic information on this sensor */
  displaySensorDetails();
}

/**************************************************************************/
/*
    Arduino loop function, called once 'setup' is complete (your own code
    should go here)
*/
/**************************************************************************/
void loop(void) 
{
  /* Get a new sensor event */ 
  sensors_event_t event;
  bmp.getEvent(&event);
 
  /* Display the results (barometric pressure is measure in hPa) */
  if (event.pressure)
  {
    /* Display atmospheric pressue in hPa */
    Console.print("Pressure:    ");
    Console.print(event.pressure);
    Console.println(" hPa");
    
    /* Calculating altitude with reasonable accuracy requires pressure    *
     * sea level pressure for your position at the moment the data is     *
     * converted, as well as the ambient temperature in degress           *
     * celcius.  If you don't have these values, a 'generic' value of     *
     * 1013.25 hPa can be used (defined as SENSORS_PRESSURE_SEALEVELHPA   *
     * in sensors.h), but this isn't ideal and will give variable         *
     * results from one day to the next.                                  *
     *                                                                    *
     * You can usually find the current SLP value by looking at weather   *
     * websites or from environmental information centers near any major  *
     * airport.                                                           *
     *                                                                    *
     * For example, for Paris, France you can check the current mean      *
     * pressure and sea level at: http://bit.ly/16Au8ol                   */
     
    /* First we get the current temperature from the BMP085 */
    float temperature;
    bmp.getTemperature(&temperature);
    Console.print("Temperature: ");
    Console.print(temperature);
    Console.print(" C/");
    Console.print(((1.8)*temperature) + 32);
    Console.println(" F");



    /* Then convert the atmospheric pressure, SLP and temp to altitude    */
    /* Update this next line with the current SLP for better results      */
    float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA;
    Console.print("Altitude:    "); 
    Console.print(bmp.pressureToAltitude(seaLevelPressure,
                                        event.pressure,
                                        temperature)); 
    Console.print(" m/");
    Console.print((bmp.pressureToAltitude(seaLevelPressure,
                                        event.pressure,
                                        temperature) * 3.28084)); 
    Console.println(" Ft");

    Console.println("----------");
  }
  else
  {
    Console.println("Sensor error");
  }
  delay(5000);
}

Thanks,
benddennis

I found the answer on another post. The SCL pin on the Yun goes to pin 3 and the SDA pin goes to pin2. This is different from the Arduino Uno, which the original sketch was based on.

Helpful forum post http://forum.arduino.cc/index.php?topic=203862.0

Board details http://arduino.cc/en/Main/ArduinoBoardYun

Thanks, benddennis

Hi, I tried your code but it didn't work for me, the serial gets stuck on "Pressure sensor test". Have made other changes to make it work? I would very much appreciate if you could confirm the code and the Pin position of the BMP805. thanks! olivier