Pressure sensor arduino and LCD

Hi,

I have recently set up a pressure sensor that is connected to an Arduino and displays the pressure output in PSI and Bars on the LCD screen. The pressure sensor is plumbed in line with a 10Bar gauge to check the output of the pressor sensor. For some reason the output constantly changes and also enters negative values even though the relationship between voltage and pressure is linear for the sensor. I am not sure what is causing this, please could someone help?

I will attach a copy of the code on my Arduino, a link to the datasheets for the Sensata Pressure sensor and the Pressure sensor attachment.

Sensata: https://www.sensata.com/sites/default/files/media/documents/2018-04-13/ourproducts_2cp_datasheet.pdf

Attachment: https://sensing.honeywell.com/honeywell-sensing-heavy-duty-pressure-px3-series-datasheet-32313757.pdf

CODE:

/*
LiquidCrystal Library - Serial Input

Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.

This sketch displays text sent over the serial port
(e.g. from the Serial Monitor) on an attached LCD.

The circuit:

  • LCD RS pin to digital pin 11
  • LCD Enable pin to digital pin 9
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2
  • LCD R/W pin to digital pin 10
  • 10K potentiometer ends to +5V and ground, wiper to LCD VO pin (pin 3)

Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
modified 7 Nov 2016
by Arturo Guadalupi

This example code is in the public domain.

*/

// include the library code:
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to.

// 8-bit mode initialisation:
const int rs = 11, en = 9, d0 = 12, d1 = 8, d2 = 7, d3 = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d0, d1, d2, d3, d4, d5, d6, d7);

/*
// 4-bit mode initialisation:
const int rs = 11, en = 9, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
*/

int offset = 102; // zero pressure adjust
int fullscale = 922; // Max pressure (span) adjust
float pressure; // Final pressure

void setup() {
//Sets rw (pin 10) to read mode:
pinMode(10, OUTPUT);
digitalWrite(10, LOW);
delay(100);

// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// initialize the serial communications:
Serial.begin(9600);
//delay(200);

// Print a message to the LCD:

lcd.setCursor(0, 0); // set the cursor to column 0, line 1
// Print a message to the LCD:
lcd.print(“University”);
lcd.setCursor(0, 1); // set the cursor to column 0, line 0
// Print a message to the LCD:
lcd.print(“of Warwick”);
delay(2000);
lcd.clear(); // clear the screen
lcd.setCursor(0, 0); // set the cursor to column 0, line 1
// Print a message to the LCD:
lcd.print(“Department of”);
lcd.setCursor(0, 1); // set the cursor to column 0, line 0
// Print a message to the LCD:
lcd.print(“Physics”);
delay(2000);
lcd.clear(); // clear the screen
}

void loop() {
/*
// when characters arrive over the serial port…
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
*/
// display each character to the LCD
//lcd.write(Serial.read());

int rawValue = analogRead(A0);
Serial.print(rawValue);

float voltage = (rawValue*5.0)/1024.0; // Converts analogue integer to voltage
Serial.print("Volts: ");

Serial.print(voltage);
lcd.setCursor(0,0);

float pressure = (rawValue - offset)*500 / (fullscale - offset);
float bar = pressure * 0.06894;
Serial.print("Pressure (psi): ");
Serial.print(pressure);
Serial.print("Pressure (Bar): ");
Serial.print(bar);

//Print a message to the second line of the LCD:

lcd.print("PSI: ");
lcd.print(pressure);

lcd.setCursor(0,1);
lcd.print("Bar: ");
lcd.print(bar);

lcd.print(" V:");
lcd.print(voltage);

delay(1000);
// }
// }

/* //Test:
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
// Print a message to the LCD.
*/
}

Attachment2.jpg

Firstly, please put your code inside the code braces (in the menu bar of the text field). This makes it way easier to read.

About your problem, have you tried connecting a 10-20k resistor in parallel? In the datasheet, it says 'typical output load is 10kOhm'. It might be that the sensor doesn't 'like' the HighZ- input. Just a guess though

Do you reckon the OP is still waiting after 3 months? :slight_smile:

What if he is? Then I'm his hero now :smiley: