Hello everyone, i have a problem with my sensor or with my code idk, because the result for the sensor is 3.6V in the beginning, i dont give any pressure, anyone can help me please (my english so bad, sorry)
i use this code
<
float rawADC;
float sensorValue;
float pressureValue;
void setup ()
{
Serial.begin(9600);
}
void loop()
{
rawADC = analogRead(36); // raw data
sensorValue = (rawADC * 5.0) / 1023.0; // raw data convert to volt
pressureValue = (sensorValue - 0.2) / 4.5 * 700.0; // sensor-offset = 0.2V, voltage range = 4.5V, pressure range = 700kPa, pressure = mV/kPa
// print out the value you read:
Serial.print("Raw value:");
Serial.println(rawADC);
The MPX5700 is a ratiometric 5volt-logic only sensor.
You might get it working with a 3.3volt-logic ESP32, but you can never get it right (stable).
Change to a sensor with I2C output.
Leo..
The MPX5700 is a ratiometric sensor, meaning it's output voltage not only depends on pressure, but also on it's supply voltage. You should code in ratios and A/D values, not in voltages.
This sensor can work with a classic Nano (5volt logic), but not with the newer 3.3volt Nanos.
Copied/corrected from a previous thread I wrote:
If you read the datasheet of the MPX5700, then you find a typical output voltage range of 0.2volt (no pressure) to 4.7volt (full pressure). That should actually be converted to a percentage for the ratiometric A/D of an Arduino, so typical sensor output range is 4% to 94% of VCC.
That translates to an offset of 4% of 1024 = 41,
and a fullScale of 96% of 1024 = 983.
It seems you want to display in kPA.
declare
int offset = 41; // adjust for zero kPa
int fullScale = 983; // adjust for accurate top scale readout if... you have a calibration instrument
float pressure;
Edit: You only have 983 - 41 = 942 A/D values for that 700kPa range,
so don't expect meaningful decimal places.
You can use Serial.print(pressure, 1); // display one decimal place
thanks leo, for the code, I followed your instructions but it's still the same, I've tried with nano and the results are different from using esp, with the same power supply, but the results are also not satisfactory
Try to test the sensor on it's own.
With it's output not connected to the Nano or ESP.
Only connect it to 5volt and ground (from the Nano),
and measure it's output with a voltmeter (assuming you have one).
It should be about 0.2volt without pressure.
Leo..
No pressure voltage of an MPX5700 should be between 0volt and 0.4volt.
Is this a new sensor from a trusted place.
Does voltage increase with pressure.
Try a bicycle pump (it's a 7bar sensor).
Leo..