Test program using the Adafruit_BMP085 library hangs Photon board after about 10m

Hi there. I have one of the little Adafruit breakout boards for the Bosch BMP180 temp/pressure/altitude sensor, and hooked it up to my Photon board. I found the Adafruit_BMP085 library in the Build IDE, added it to my test program and flashed the device. My test program just reads the values from the sensor, prints them out, and sleeps for 500ms in the loop() function. This works perfectly for about 3-5m, and then the board locks up completely. It stops printing to the console, and the LED goes from “breathing” cyan to just solid cyan. A reset, unlocks the board, and it keeps working again for about 3-5m and then the same thing happens. I’m not sure if it’s an I2C problem, or maybe a memory leak in the Adafruit library, or maybe something different. Has anyone else run into this? The code is as simple as it gets:

#include "Adafruit_BMP085/Adafruit_BMP085.h"

Adafruit_BMP085 bmp;

double temp;
double pressure;
double altitude;

void setup() {
  //Particle.variable("readBMP", bmpStr, STRING);

// char output[100];

void loop() {
  temp = bmp.readTemperature();
  pressure = bmp.readPressure();
  altitude = bmp.readAltitude();
  // sprintf(output, "Temperature: %f, pressure: %f, altitude: %f", temp, pressure, altitude);
  Serial.print("Temperature: ");
  Serial.print(", pressure: ");
  Serial.print(", altitude: ");

I’m just printing to the console since I wanted to eliminate any potential memory allocation issues, etc. As always, any help is much appreciated. This is just a little hobby project, but it would be fun to get it to work. Thanks!

I just tried it again, and it locked up after about 3m this time.

Could you also describe how you’ve got thinges wired?

You could also try SYSTEM_MODE(SEMI_AUTOMATIC) just to avoid any WiFi influence on your test.
To OTA flash, you’d need to go into Safe Mode or add some way to call Particle.connect()

Are they any pull up resistors fitted ?

@Bluzcat, one note on the Adafruit tutorial site for their BMP180 V2 breakout regarding using the old BMP085 library:

This repository is not recommended for new projects, but is provided for reference sake for projects that made use of the BMP085 before the updated Unified driver was published.

Which breakout version do you have? There are pull-up resistors on the board so that is not the issue. Do you have other I2C devices connected?

Sorry, I forgot to mention the wiring. From the BMP180 to the Photon: SDA -> D0, SCL -> D1. I’m using the 3.3V pin on the Photon to the 3.3V (not Vin) on the BMP180. Nothing else hooked up to the Photon.

No external pullups. From what I understand, they should be on the breakout board already.

Oh, I see. I was just using the library that was available from inside the online build IDE. Is there a newer one I should use? The BMP180 breakout board is this: https://www.adafruit.com/products/1603

@Bluzcat, I don’t believe there is a newer ported library on the IDE. I will look tonight and see what I can do. The port itself is very simple but if you’ve never done it before, it can be less than obvious. :wink:

1 Like

@Bluzcat, AFAIK the library should be fine for both boards (it even mentions both in the README.md).
But could you try the 5V supply instead? The Photon’s I2C pins are 5V tolerant.

Without the board it’s hard to tell from the picture but it could be that the pull-ups are wired between the signal lines and 5V (would be odd, but thinkable).


Hi @peekay123. What’s involved in adding something to the IDE? Does that have to be done by the Photon folks, or can you add stuff locally? Just curious.

@Bluzcat, you need to create a github repo with the right format and then “publish” it to the IDE. Anyone can do it. Take a look at any IDE library and follow the github link to see how its laid out. :smile:


1 Like

@ScruffR, I finally got a chance to try it with 5V, and it hangs immediately. I don’t even see the debug message from the setup() function.

@peekay123, do you have any pointers (pun intented) :slight_smile: as to what needs to be fixed in the unified library for it to work with the Photon? Sorry I’m pretty new to the world of Arduino Wiring, and the whole firmware build environment, but I’d like to learn more. Thanks.

@Bluzcat, most of the code requires no changes at all. In the .cpp and .h files you can remove most if not all the arduino includes, keeping the math.h include and adding #include "application.h" in the .h file. If you use the included example, rename the file to .ino (from .pde) and change the <> to quotes on the includes (you can remove the wire.h include). :smile:

1 Like

I got the same problem, using this BMP180 from AliExpress. My Photon stops working after 30 seconds, more or less. I have a two more sensors attached to the Photon, one DS18B20 and one DHT22.
The BMP180 is working for sure, I tested it with my Arduino Uno R3.
I don’t know what’s going on with this, it’s kinda strange.

I’m running into the exact same issue!! Use to work days on end logging temp to google spreadsheet and to ubidots.
I eliminated code to bare minimal as per first post and tested on two Photons. Same outcome. Photon hangs.
Anyone with a solution?, a newer working library for bmp 180?