Python Library Navigator help with BMP280

Hi everyone! I’m new to the forum, and I’m trying to some example code using the Blue Navigator Flight Controller for an ArduSub.

Here’s what Im running:

  • Raspberry Pi 4b
  • Navigator Flight Controller
  • Blue OS 1.4.2
  • Using Jupyter to run code
import os
import platform
import bluerobotics_navigator as navigator
from bluerobotics_navigator import AdcChannel, UserLed

from bluerobotics_navigator import NavigatorVersion, Raspberry
navigator.set_navigator_version(NavigatorVersion.Version1)
navigator.set_raspberry_pi_version(Raspberry.Pi4)


def navigator_check():
    print(f"Functions available: {navigator.__all__}")

    if os.environ.get("CI") == "true":
        print("Running in CI")
        print("Not possible to test navigator sensors yet.")
        return

    print("Initializing navigator module.")

    if platform.machine() == "aarch64":
        # It's possible to set the configuration before initializing the navigator, check this example
        from bluerobotics_navigator import NavigatorVersion, Raspberry
        print("Setting up for Navigator V2 on Raspberry Pi 5")
        navigator.set_rgb_led_strip_size(1)
        navigator.set_navigator_version(NavigatorVersion.Version2)
        navigator.set_raspberry_pi_version(Raspberry.Pi5)

    navigator.init()

    print("Setting led on!")
    navigator.set_led(UserLed.Led1, True)

    print(f"Temperature: {navigator.read_temp()}")

    print(f"Pressure: {navigator.read_pressure()}")

    print(f"Leak sensor: {navigator.read_leak()}")

    Data = navigator.read_adc_all()
    print(
        f"Data ADC Channels: 1 = {Data[0]}, 2 = {Data[1]}, 3 = {Data[2]}, 4 = {Data[3]}"
    )

    print(f"Data ADC Channel: 1 = {navigator.read_adc(AdcChannel.Ch1)}")

    Data = navigator.read_mag()
    print(f"Magnetic field: X = {Data.x}, Y = {Data.y}, Z = {Data.z}")

    Data = navigator.read_accel()
    print(f"Acceleration: X = {Data.x}, Y = {Data.y}, Z = {Data.z}")

    Data = navigator.read_gyro()
    print(f"Gyroscope: X = {Data.x}, Y = {Data.y}, Z = {Data.z}")

    print("Setting led off!")
    navigator.set_led(UserLed.Led1, False)


if __name__ == "__main__":
    navigator_check()

Im trying to run this code and then this is the output I get

Functions available: ['AdcChannel', 'UserLed', 'AxisData', 'Raspberry', 'NavigatorVersion', 'init', 'set_rgb_led_strip_size', 'set_navigator_version', 'set_raspberry_pi_version', 'self_test', 'set_led', 'get_led', 'set_led_toggle', 'set_led_all', 'set_neopixel', 'set_neopixel_rgbw', 'read_adc_all', 'read_adc', 'read_pressure', 'read_temp', 'read_leak', 'read_mag', 'read_accel', 'read_gyro', 'set_pwm_enable', 'set_pwm_freq_hz', 'set_pwm_channel_value', 'set_pwm_channel_duty_cycle', 'set_pwm_channels_value', 'set_pwm_channels_duty_cycle', 'set_pwm_channels_values', 'set_pwm_channels_duty_cycle_values']
Initializing navigator module.
Setting led on!
thread '<unnamed>' panicked at 'Failed to create Bmp280: Other(())', /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/navigator-rs-0.6.0/src/lib.rs:442:22
---------------------------------------------------------------------------
PanicException                            Traceback (most recent call last)
Cell In[15], line 61
     57     navigator.set_led(UserLed.Led1, False)
     60 if __name__ == "__main__":
---> 61     navigator_check()

Cell In[15], line 32, in navigator_check()
     29 navigator.init()
     31 print("Setting led on!")
---> 32 navigator.set_led(UserLed.Led1, True)
     34 print(f"Temperature: {navigator.read_temp()}")
     36 print(f"Pressure: {navigator.read_pressure()}")

PanicException: Failed to create Bmp280: Other(())

It keeps on trying to create the Bmp280 but I know the Navigator is running a BMP390. What can i do about this to fix it?

I figured it out, I just had to switch this

navigator.set_navigator_version(NavigatorVersion.Version1)

to

navigator.set_navigator_version(NavigatorVersion.Version2)

I didn’t realize there were 2 versions until I dug deeper in the navigator library.