Pressure sensor square waves/noise

Hi,
Have anyone seen this issue with this pressure gauge sensor MPRLS0300YG00001BB honeywell? We're using an Arduino Nano.

We tried to use a voltage stepper and it was still showing the same issue.

Thank you!

here is our circuit:


and here is our code:

type or paste code here
// #include <Adafruit_MPRLS.h>
#include<Arduino.h>
#include <Wire.h>

// You dont *need* a reset and EOC pin for most uses, so we set to -1 and don't connect
/*#define RESET_PIN  -1  // set to any GPIO pin # to hard-reset on begin()
#define EOC_PIN    -1  // set to any GPIO pin to read end-of-conversion by pin
Adafruit_MPRLS mpr = Adafruit_MPRLS(RESET_PIN, EOC_PIN);
*/
uint8_t id = 0x18; // i2c address
uint8_t data[7]; // holds output data
uint8_t cmd[3] = {0xAA, 0x00, 0x00}; // command to be sent
double press_counts = 0; // digital pressure reading [counts]
double pressure = 0; // pressure reading [bar, psi, kPa, etc.]
double outputmax = 3374874; // output at maximum pressure [counts] //15099494
double outputmin = 419430; // output at minimum pressure [counts] //1677722
double pmax = 300; // maximum value of pressure range [bar, psi, kPa, etc.] //1
double pmin = 0; // minimum value of pressure range [bar, psi, kPa, etc.]
double percentage = 0; // holds percentage of full scale data
char printBuffer[200], cBuff[20], percBuff[20], pBuff[20], tBuff[20];

int switchState=0;
int lastState=0;
int motorState=0;
int t=0;
void setup() {
//  lcd.begin(16,2); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display 
  Serial.begin(9600);
  while (!Serial) {
    delay(10);
  }
  Wire.begin();
  sprintf(printBuffer, "\nPressure Output\n");
  Serial.println(printBuffer);
  
  /*Serial.println("MPRLS Simple Test");
  if (! mpr.begin()) {
    Serial.println("Failed to communicate with MPRLS sensor 1, check wiring?");
    while (1) {
      delay(10);
    }
  }
  */
  pinMode(9,OUTPUT); //motorPin
  pinMode(3,OUTPUT); //valvePin
 pinMode(12,INPUT); //switchPin
}

void loop() {
  Wire.beginTransmission(id);
  int stat = Wire.write (cmd, 3); // write command to the sensor
  stat |= Wire.endTransmission();
  delay(10);
  Wire.requestFrom(id,(uint8_t) 7); // read back Sensor data 7 bytes
  int i = 0;
  for (i = 0; i < 7; i++) {
    data [i] = Wire.read();
  }
  press_counts = data[3] + data[2] * 256 + data[1] * 65536; // VIP calculate digital pressure counts
  pressure = (((press_counts - outputmin) * (pmax - pmin)) / (outputmax - outputmin)) + pmin; //VIP LINE
  dtostrf(pressure, 4, 3, pBuff);
  sprintf(printBuffer, "% s \n", pBuff);
  Serial.print(printBuffer);
  
  switchState=digitalRead(12);
  float Pressure_mmHg=pressure;
 
  
 
  /*
  float pressure_hPa = mpr.readPressure();
  //float Pressure_mmHg=pressure_hPa*0.75006157584566-740;
  float Pressure_mmHg=pressure_hPa-21901;
 */

  //Serial.print("Pressure (mmHg): "); Serial.println(Pressure_mmHg);
  //Serial.print("Base Pressure Sensor 1 (mmHg): "); Serial.println(pressure_hPa*0.75006157584566);
  //Serial.print("Base Pressure Sensor 2 (mmHg): "); Serial.println(base_Pressure*0.75006157584566);
  
  if (switchState != lastState){
       lastState= switchState;
       if (switchState==LOW){
        motorState = (motorState == HIGH) ? LOW: HIGH;
       digitalWrite (9,motorState);
       digitalWrite(3,motorState);
       Serial.println("Button is pressed");
       t=1;
       delay(10);
       }
    }
  if (t>=1){
    t++;
    //Serial.print("t is "); Serial.println(t);
  }
  if (Pressure_mmHg>=150 ||t==300){
         digitalWrite (9, LOW);
         digitalWrite(3, HIGH);
       
         //for (int t=0;t<5;t++){
          
         //delay(500);
         //Serial.println(t);
         //pressure_hPa = mpr.readPressure();
         //Pressure_mmHg=pressure_hPa*0.75006157584566-740;
         //Pressure_mmHg=pressure;
         //Serial.println(Pressure_mmHg);
         
         //}
         //digitalWrite(3,LOW);
       }
  if (t>=330){
    digitalWrite(3,LOW);
  }
  /*lcd.setCursor(0,0);
  lcd.print("Pressure "); lcd.print(Pressure_mmHg);*/
  delay(100);
 }

The sensor is 3.3V only, and cannot be used with a 5V Arduino, unless you have logic level shifters for the data lines. If the logic level shifters are not already on the sensor module (post a link to it), I recommend this one.

Unless the "power module" in the schematic is very well filtered, it will introduce electrical noise on the 5V line, which in turn will corrupt analog input readings.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.