Here , I try to explain is that a pressure sensor detects the pressure and passes an accordingly scaled voltage to microcontroller which converts it into digital data .

For this,i have used ATMEGA32   and MPX4115 pressure sensor. MPX4115 pressure sensor integrates on-chip, bipolar op amp circuitry and thin film resistor networks to provide a high level analog output signal and temperature compensation.More details can be found here MPX4115.

Code is written in C using AVR Studio 4 and winavr gcc compiler.

The ATMEGA32 has an  built-in ADC module. ADC module needs to be initialized.To know  details about ADC initialization and ADC  channel selection,see ATMEGA32 Data sheet.

ADC Initialization

ADMUX=(1<<REFS0);                         // For Aref=AVcc;
ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); //prescalar div factor =128

ADC Channel Selection

//Select ADC Channel ch must be 0-7

//Start Single conversion
//Wait for conversion to complete
while(!(ADCSRA & (1<<ADIF)));


I have converted  ADC value to pressure using this formula:

adc_result= (5.0/1023.0)*ReadADC(0);


Source Code

This example code reads analog value from channel 0 and displays it on LCD.

#include <avr/io.h>
#include <inttypes.h>
#include <util/delay.h>
#include “lcd.h”

void InitADC()
ADMUX=(1<<REFS0);                         // For Aref=AVcc;
ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); //Rrescalar div factor =128

uint16_t ReadADC(uint8_t ch)
//Select ADC Channel ch must be 0-7

//Start Single conversion

//Wait for conversion to complete
while(!(ADCSRA & (1<<ADIF)));



int main(void)
float adc_result;
DDRB = 0x00;
//Initialize LCD

//Initialize ADC

LCDWriteString(“Pressure monitor”);
adc_result= (5.0/1023.0)*ReadADC(0);           // Read Analog value from channel-0


LCDWriteIntXY(9,1,adc_result,3); //Print the value in 4th column second line

return 1;

Circuit Diagram

Pressure sensor interfacing

Pressure sensor interfacing Circuit

Download Source code and circuit diagram


Comments on: "Pressure sensor interfacing with Microcontroller" (29)

  1. Nice work… will u please help me out in implementing this Pressure sensor interfacing with 8051 Microcontroller..?

    Basically i’m doing a industrial base project using control area network. in which i want to use this pressure sensor.
    looking forward to your cordial response.
    Thank you.

  2. NIce Work…… Can u please explain why you add this 48 in str[i] when you are calling the LCDData Function this is written in the last line of below given function…..this function is from your source code….

    void LCDWriteInt(int val,unsigned int field_length)

    char str[5]={0,0,0,0,0};
    int i=4,j=0;
    while(str[j]==0) j++;

    if(val<0) LCDData('-');

  3. hi…
    i am doing a project named design of low power altimeter. Will you please suggest me a micro controller that is efficient for interfacing with the pressure sensor…

  4. thanks for your reply.
    but i need a micro controller that have high resolution. It should display the output voltage in the range 4-4.5 with a high resolution in the range of milli volts..
    will you please suggest a microcontroller with these features and it should be interfaced with pressure sensor MPX4115A. please do favour in this.

  5. cud u give me complete circuit and code for blood pressure,heart rate and temp as i m stuck with my masters project.please .i have all but with different microcontrollers .i want with one controller.please help.liked dis circuit very much

  6. very nice work.please help me 2.

  7. Sivaprakash.R said:

    Please help me to buy the MPX4115 sensor, where to buy in india. I am planning to use this measure the tyre pressure in my project.. I am in chennai, india. Sivaprakash.R

  8. can you tell me the code of 1211 sensor interfacing with atmega32 microcontroller?
    please reply me.

  9. i am doing project on data acquisition using fpga.we need to write vhdl code for ADC,temperature and humidity sensors and interfacing them to adc.pleaze can you give me the vhdl code for sensors interfacing to ADC.

  10. what is the cost of microcontroller u have used?

  11. paul_dean said:

    how did u get the pressure to be 33kpa? isnt atmospheric pressure around 100kpa

  12. Hamza Khan said:

    the download link seems to be expired.
    can you give some other link or can you mail it on .
    i’ll be very thankful to you.

  13. Does this still work if I change the sensor used? or I have to change the codes also if I change the sensor?

  14. Anonymous said:

    Hello can u give me the complete cicuit blood presure and the program C..pls pls
    emil to me

  15. hello
    is the source code can be applied to PIC with a little modification?

  16. Anonymous said:

    Can you please tell me why you have connected pin no 32 i.e Aref to ground , it should be connected to VCC according to ur code right ?

  17. could u jst tell me why r u using this code
    rather than simply puting it to the LCD,,,,,
    may be bcz LCD showing pressure around double…..

  18. and i also dnt understand this 5/1023

  19. hello i develop blood pressure monitor i use the sensor MPXV5050GP and i want to convert that data digital and display the pressure so please can you help me for programming. i have on difficulties found on calibrating this sensor.
    i used AN0 as input pin of the microcontroller PIC18f4550 and lcd is conncted on Dport

  20. Darshan Jain said:

    Hey i am working on anti theft car system based on lpc2148.
    Will u tell me with pressure sensor i need to use for any persons pressure on seat.

  21. devidas said:


  22. Shafraz Mohamed said:

    i’m trying a blood pressure monitor using a PIC16F877A, please somebody help me to write the C code to detect the Systolic and Diastolic pressure using ADC readings.

  23. after i ran the design i would like to increase and decrease the pressure

  24. please send me blood pressure interfacing system

  25. Hi sir want program in assembly language program please help me

  26. Hy, I want a C code for Water Level Sensor using PIC18F550. Please help me out

  27. peter mangore said:

    hie friends
    am doing diploma in electronics and currently i am doing a project; pressure monitoring system using pic 16f877a, mpx4115 and lcd.
    challenge is i do not know the c code. pliz help me guys

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: