Read Waveshare BMP388 sensor on Raspberry Pi

4 ビュー (過去 30 日間)
Adrian Ramirez Cedres
Adrian Ramirez Cedres 2023 年 5 月 7 日
回答済み: Pratheek 2023 年 5 月 25 日
Can anyone share their code to read pressure and temperature from a Waveshare BMP388 sensor on a Raspberry Pi?
Tried as far as I could, but I ended up in desperation. bmp388Demo.py file from Waveshare works properly, but I can only get -273.15 degC and 0 hPa on Matlab. Thanks!

回答 (1 件)

Pratheek
Pratheek 2023 年 5 月 25 日
Hi Adrian,
I undestand that you want to read sensor data with Raspberry Pi in MATLAB, to use Raspberry Pi in MATLAB you will need to install the MATLAB Support Package for Raspberry Pi Hardware, which is a hardware support package. You can refer to the documentation for detailed installation instructions:
Alternatively, if you prefer a video tutorial, you can refer to the following video:
Once you have installed the support package, you can utilize predefined functions to read sensor data if your sensor is listed in the supported sensors. However, if you wish to read data from a sensor that is not listed, you will need to write a custom script to accomplish this.
To read sensor data in MATLAB using Raspberry Pi, follow these steps:
Steps to read sensor data in MATLAB using Raspberry Pi:
  1. Establish a connection to the Raspberry Pi.
  2. Create an object that represents your sensor. For detailed instructions on how to achieve this, refer to the following documentation page: Use the Raspberry Pi I2C Interface to Connect to a Device - MATLAB & Simulink (mathworks.com)
  3. Initialize the sensor by using the writeRegister function and set the appropriate registers.
  4. Use the readRegister function to read the registers for temperature and pressure (Please refer to the datasheet for the correct register values).
  5. The data obtained from step 4 will be in raw sensor format. You may need to convert this data into the desired units.
  6. Finally, display the obtained sensor data.
I hope this help!

カテゴリ

Help Center および File ExchangeInstallation Setup and Configuration についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by