Skip to content

Instantly share code, notes, and snippets.

@didasy
Created May 18, 2017 10:55
Show Gist options
  • Select an option

  • Save didasy/aca2d30a8410a30aab9ead6d2fef2f36 to your computer and use it in GitHub Desktop.

Select an option

Save didasy/aca2d30a8410a30aab9ead6d2fef2f36 to your computer and use it in GitHub Desktop.
MPX4250AP to PSI for Arduino
float getPressure(int raw) {
// raw 0-1023, get from analogRead();
// 0.004887585532746823 is from 5v/1023
// General info:
// range of voltage reading is 0v-5v
// the sensor outputs MPV to (MPV + 4.692v), while the range is (0.133v - 0.204v - 0.274v) to (4.826v - 4.896v - 4.966v)
// each KPa is 20mV or 0.02V
float voltage = raw * 0.004887585532746823;
// Typical MPV is 0.204v@20KPa
// Maximum pressure is 250KPa
// pressure = voltage * (250 / (MPV + 4.692))
float pressure = voltage * 51.06209150326797;
return pressure * 0.145037738; // convert KPa to PSI
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment