Arduino Nano BLE 33 Sense- Odd Error(?) When Attempting to Read BMP180

I am currently trying to use an Arduino Nano BLE 33 Sense to read a BMP180 barometric pressure sensor, but when I upload my code to it, something odd happens. Once it completes the upload, the onboard LED will blink four times rapidly, then four times slowly, repeating this pattern forever. While it is doing this, I am unable to upload any other code to it, and must repeatedly click the reset button until the LED starts fading in and out (I assume some sort of ‘recovery’ mode). By incrementally commenting out code, I have found that this only occurs when I attempt to call the line “status = pressure.startPressure(3);”.

Here is my code.

#include <SFE_BMP180.h>
#include <Wire.h>
#include <Arduino_LSM9DS1.h>

char status;
double T,P,pz,a,f;
int startingAltitude = 200;
const int heightLimit = 29999;
int calibrated = 0;
SFE_BMP180 pressure;
#define ALTITUDE 61

int outRed = LOW;
int outGreen = LOW;
int outRelay = LOW;

long previousMillis = 0;
long interval = 999;

const int pinRed = 2;
const int pinGreen = 3;
const int pinRelay = 13;

void setup() {
  pinMode(pinRed, OUTPUT);
  pinMode(pinGreen, OUTPUT);
  pinMode(pinRelay, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  unsigned long currentMillis = millis();

  if(currentMillis - previousMillis > interval){
    previousMillis = currentMillis;
    status = pressure.startPressure(3);
    if (status != 0)
    {
      delay(status);
      status = pressure.getPressure(P,T);
      if (status != 0)
      {
        if(calibrated == 0){
          //setting the current altitude
          pz = pressure.sealevel(P,ALTITUDE);
          calibrated = 1;
        }
        a = pressure.altitude(P,pz);
        f = a*3.28084;
      }else Serial.println("error retrieving pressure measurement\n");
    }else Serial.println("error starting pressure measurement\n");
  }
}

Any advice on what is happening / how I could avoid it?

steamstuckdragon:
Once it completes the upload, the onboard LED will blink four times rapidly, then four times slowly, repeating this pattern forever.

A 4X long, 4X short blink pattern indicates Mbed OS has crashed. This causes the USB code that creates the CDC serial port to stop running, thus no port.


Debug information is printed on Serial1 when Mbed OS crashes. You can view the debug output by following these instructions (no guarantee it will be helpful though):

Unplug your Nano 33 BLE board from the computer or power supply.

Make the following connections between a USB to TTL serial adapter (AKA “FTDI”) and your Nano 33 BLE:

| Adapter | | Nano 33 BLE |
| - | - |
| ----------- | |------- |
| RX | | TX1 |
| ----------- | |------- |
| GND | | GND |

You will also need to power the Nano 33 BLE. You can do this via the USB socket, or power it from the USB to TTL serial adapter’s VCC pin. If the serial adapter’s VCC pin is outputting 5 V, connect it to the Nano 33 BLE’s VIN pin. If the serial adapter’s VCC pin is outputting 3.3 V, connect it to the Nano 33 BLE’s 3.3 V pin.

Connect the serial adapter to your computer with a USB cable.

Select the port of the serial adapter from the Arduino IDE’s Tools > Port menu.

Tools > Serial Monitor

Set the baud rate menu at the bottom right corner of Serial Monitor to 115200.

Press and release the reset button on the Nano 33 BLE. You should now see the “MbedOS Error Info” output in the Serial Monitor output field.


steamstuckdragon:
While it is doing this, I am unable to upload any other code to it, and must repeatedly click the reset button until the LED starts fading in and out (I assume some sort of 'recovery' mode).

When you reset the board twice quickly, you cause the bootloader to run. The bootloader is a separate program, so it's unaffected by the bad code that crashed Mbed OS. This is why you will see the port appear and be able to upload to the board again after putting it in bootloader mode.