Toggle Nav

Interfacing MPS20N0040D Barometric Pressure Sensor with Arduino

Table of Contents

MPS20N0040D Pressure Module Features

The MPS20N0040D Pressure and Altitude Sensor Module is an MPS20N0040D pressure sensor that receives altitude data and transmits it to the HX710 IC, which is an ADC converter. This module is used to measure the ambient pressure and the pressure difference of liquid levels.

Note:

This module does not support I2C communication.

You can download the datasheet of this module here.

MPS20N0040D Pressure Module Pinout

This sensor has 4 pins:

  •  VIN: Module power supply – 3.3-5 V
  •  GND: Ground
  •  SLC: I2C Clock
  •  OUT: Digital output data

You can see pinout of this module in the image below.

Required Materials

Hardware Components

Arduino UNO R3 × 1
MPS20N0040D Pressure Module × 1
Male Female Jumper Wire × 1

Software Apps

Arduino IDE

Interfacing MPS20N0040D Sensor with Arduino

Step 1: Circuit

The following circuit shows how you should connect Arduino to MPS20N0040D module. Connect wires accordingly.

Step 2: Code

Tip

If you need more help with installing a library on Arduino, read this tutorial: How to Install an Arduino Library

Upload the following code to your Arduino
/*
  on Sep 21, 2020
  by MohammedDamirchi
  https://electropeak.com/learn/
*/
/*
  on Sep 21, 2020
  by MohammedDamirchi
  https://electropeak.com/learn/
*/

#include <Q2HX711.h>
#include <Average.h>

const byte MPS_OUT_pin = 2; // OUT data pin
const byte MPS_SCK_pin = 3; // clock data pin
int avg_size = 10; // #pts to average over

Q2HX711 MPS20N0040D(MPS_OUT_pin, MPS_SCK_pin); // start comm with the HX710B
Average<long> ave(avg_size);

void setup() {
  Serial.begin(9600); // start the serial port
}

void loop() {
  ave.push(MPS20N0040D.read());
  Serial.println(ave.mean());
}

After running the code, you will see the following image in the serial monitor.

Liked What you see?

Get updates and learn from the best

More To Explore

Comments (2)

  • Domingo Vega Reply

    Hi thks for your input…but which units are obtained with this code..KPa?

    November 16, 2020 at 6:12 pm
    • Mehran Maleki Reply

      Hi Domingo, you’re welcome. Actually the output of HX711 is an integer. So the output of the code the average of 10 integers. It is not Pascal. For calculating the pressure accurately, the module needs to be calibrated in the region that it’s going to be used. And for calibration you can follow these steps: First go to a place where you already know the pressure, then use this module with the given code and write the output of it. Then you can easily calculate the pressure of different places by using proportionality.

      December 2, 2020 at 9:34 am

Leave a Reply

Your email address will not be published. Required fields are marked *