I was reading sensor data from my BMP180 with the photon via i2c, until it suddenly stopped working. I am not sure if it stopped working while actually running or after I re-connected it to the power supply. When I flash the code (which worked before), the first message in my setup()
is still sent, and then, after calling bmp.begin()
the execution seems to stop (no further messages are sent). This also happens when calling begin() on other i2c sensors. After the code gets stuck, I can neither flash new code nor ping the device; the LED breathes cyan and I have to enter safe mode in order to flash new code.
In the console, I get spark/flash/status started & success as well as
sys/status Starting v0.1
(my first line in setup()
)
EDIT: The same happens for the i2c scanner from arduino: I get on the serial port
I2C Scanner
Scanning...
but then, nothing happens and the LED continues breathing cyan.
Thank you in advance for any help!
The (simple!) BMP sensor reading code is:
String version ="0.1";
#include <Adafruit_BMP085.h>
Adafruit_BMP085 bmp; // BMP180 for PRESSURE, not using temp (using module BMP180; the library is the same as BMP085)
void setup()
{
Particle.publish("sys/status","Starting v"+version);
if(bmp.begin()){
// everything ok
Particle.publish("sys/status","bmp 180 successfully init");
} else {
delay(1000); // wait so that publish will definetely work
Particle.publish("sys/error", "bmp 180 could not be init");
while (1){}; // infinity loop
}
Particle.publish("sys/status","all sensors successfully init. Continuing...");
}
void loop()
{
Particle.publish("LOOP","LOOP start");
double bmp_press = bmp.readPressure()/100; // in hPa
double bmp_temp = bmp.readTemperature(); // in deg C
String bmp_data = String::format(
"{"
"\"press_raw\":%.2f, "
"\"temp\":%.1f, "
"}",
bmp_press,
bmp_temp);
Particle.publish("data/bmp",bmp_data,60,PRIVATE);
Particle.publish("LOOP","LOOP end");
delay(5000);
}
The i2c scanner code is taken from:
Arduino