Digital Barometer Circuit diagram

The Motorola MPX4115A is an atmospheric pressure sensor powered by 5V and delivers and output from ~0.25V to ~4.75V based on the pressure detected at room temperature (25°C). The device provides a linear output based on pressure. As the pressure rises, the output voltage of the sensor rises as well with ~0.25V represents <15 kPa pressure relative to a vacuum and ~4.75V represents >115 kPa.
Note that  1 atmosphere of pressure at sea level is equal to 101,325 Pa or 101 kPa.
The graph below shows a typical output response of an MPX4115A pressure sensor, below 15KPa and
above 115KPa the voltage doesn’t change.
The MPX4115A is thus an ideal sensor for microcontroller based barometer or altimeter applications.

Extract from the MPX4114A Datasheet

Extrait from the MPX4114A Datasheet

Features 

  • 1.5% Maximum Error over 0° to 85°C
  • Ideally suited for Microprocessor or Microcontroller– Based Systems
  • Temperature Compensated from –40° to +125°C
  • Durable Epoxy Unibody Element or Thermoplastic (PPS) Surface Mount Package

Application Examples

  • Aviation Altimeters
  • Industrial Controls
  • Engine Control
  • Weather Stations and Weather Reporting Devices

   MPX4114A Pin Configurations                  MPX4114A Pressure Sensor

The pin configurations                                  MPX4115A Pressure Sensor

More information can be found from the MPX4115A Datasheet

Circuit diagram

As shown on the circuit diagram above, it is very easy to interface the MPX4115A to a PIC, if you are using the 8-pin sensor, connect pin 2 to +5V, pin 3 to ground and the output is on pin 4 (connect to analog pin of PIC). leave the rest unconnected. If you are using the 6-pin sensor, pin 1 is the output (connect to analog pin of PIC), pin 2 to ground and pin 3 to +5V. Leave the rest unconnected.
Note: Pin 1 is noted by the notch in the lead
VDD and VSS of the pic microcontroller is not shown in the circuit diagram. VDD should be connected to +5V and VSS to GND. The MCLR is disabled in software and an internal oscillator clock is selected so no need for external crystal.
A 16 x 2 lines LCD display is connected to PORT B. refer to the Interfacing LCD Display with PIC microcontroller 

mikroC Pro for PIC Code

The sensor is connected to analog channel of the PIC, please refer to the article Analog to Digital Converter in PIC Microcontroller to learn more.

/*
 * Project name: Digital Barometer with MX4115A Pressure Sensor
 * Author: www.studentcompanion.co.za
 * Date: February 2016
 * Test configuration:
     MCU:             PIC18F26K20
     Oscillator:      8.0000 MHz Internal Oscillator
     MCLR Disabled
     SW:              mikroC PRO for PIC  v6.6.1
 */

// LCD module connections
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D4 at LATB0_bit;
sbit LCD_D5 at LATB1_bit;
sbit LCD_D6 at LATB2_bit;
sbit LCD_D7 at LATB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections

unsigned int ADCResult=0;
float pressure;
unsigned char txt[15];

void main() {
  OSCCON=0x66;                    //Configure to use 8MHz internal oscillator.
  TRISA.RA0 = 1;                    // Configure RA0 pin as input

  ADC_Init();                        // Initialize ADC

  Lcd_Init();                        // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off

  Lcd_Out(1, 1, "StudentCompanion");  // Display "StudentCompanion"
  Lcd_Out(2, 1, "Digital Barometer");        // Display "Thermometer"
  Delay_ms(2000);                      // 2 Second delay
  Lcd_Cmd(_LCD_CLEAR);               // Clear display

   do {
    ADCResult = ADC_Read(0);          // Get 10-bit results of AD conversion
    pressure = (ADCResult*5.0)/1024; // Read the output voltage from the sensor
                                     //we devide by 1024 because its a 10-bit converted data
    pressure = (pressure + 0.475)/0.0475; //Convert the output Voltage to pressure in kPa using
                                          //the transfer function:
                                          //Vout = Vs x ((0.009 x P) - 0.095) ± Error
                                          // to get the result in millibar, multiply the result by 10

    FloatToStr(pressure, txt);            // Convert temperature to string
    Lcd_Out(1, 1, "Pressure = ");
    Lcd_Out_Cp(txt);
    Lcd_Out_Cp("KPa");

  } while(1);

}

You can download the full project files (mikroC source code and Proteus Schematic design) below here. All the files are zipped, you will need to unzip them (Download a free version of the Winzip utility to unzip files).

Download mikroC Project:

Download Schematic: