Example Code for Raspberry Pi-FIFO water level or full interrupt function

FIFO water level or full interrupt function

Hardware Preparation

  • Raspberry Pi 4th Generation Type B (or similar) main control board x 1
  • BMP390L digital barometric pressure sensor × 1
  • Jumper wires

Software Preparation

Wiring Diagram

 Wiring Diagram

Other Preparation Work

Install driver

Step 1. Start the I2C interface of the Raspberry Pi. If it is already enabled, you can skip this step. Open the terminal (Terminal), type the following command, and press Enter:

sudo raspi-config

Then use the up and down keys to select "5 Interfacing Options", press Enter, select "P5 I2C", and press Enter to confirm "YES". Restart the Raspberry Pi main control board.

Step 2. To install Python dependent libraries and git, the Raspberry Pi needs to be connected to the Internet. If it is already installed, you can skip this step. In the terminal, type the following commands in sequence and press Enter:

sudo apt-get update
sudo apt-get install build-essential python-dev python-smbus git

Step 3. Download the BMP3 series driver library. In the terminal, type the following commands in sequence and press Enter:

cd Desktop
git clone https://github.com/cdjq/DFRobot_BMP3XX

**Notice: **If you choose to use I2C or SPI communication, you need to modify the demo to the corresponding communication. You may encounter a situation where you do not have permission to modify the sample program. The following is the solution:

Step 1. Query permissions under the file directory to be modified, the command is:

ls -al

Step 2. Modify the file permissions, the command is:

sudo chmod a+w XXX.py

At this point, everyone has write access to the file.

Sample Code

  • In the terminal, type the following command and press Enter to run the sample code:
cd DFRobot_BMP3XX/python/raspberrypi/example
python3 interrupt_using_FIFO.py

Result

Result

Additional Information

**Notice: **The tutorial example uses an altitude of 540 meters in Wenjiang District, Chengdu (China). Please change to the local altitude calibration when actually using it.

Was this article helpful?

TOP