[SOLVED] Analog Value Changes... HELP

My analog value changes from on one value on my LCD screen to another when I unplug my USB cable. I am powering my UNO with a 12v to 5v convertor. I am reading a pressure sensor. With USB plugged in i'm getting about 0 pressure reading. When I unplug my USB I'm getting 15.

I am mapping reading from 0, 1023, -50, 50

//LCD2 VPSR Print
  VPSR = analogRead(VPS);
  //delay(500);
  VPSR = map(VPSR, 0, 1023, -50, 50);
  lcd2.setCursor(2, 0);
  lcd2.print("Suction Pressure ");
  lcd2.setCursor(9, 1);
  lcd2.print(VPSR);
  lcd2.print("   ");

I need to read "0" either way.... In use or plugged into computer for Diagnostics.

The voltage reference for analog measurements defaults to Vcc, which is not the same for USB power as from other power inputs.

For stability, on the Uno use the 1.1 V internal voltage reference. It is not calibrated, so you need to do that, and you will probably need to add a voltage divider to the input.

How do I calibrate it? I am fairly new to this.

Thanks

Google "calibrate arduino voltage reference" for any number of tutorials.

This is an excellent, comprehensive tutorial on the ADC.

Which sensor?

CJMCU-36

If I plug my 5v external powers + into the IOREF with a jumper... This stabilizes the analog reading, whether I'm plugged into the USB or X-Power supply. The reading stays correct. IS THIS OK?

No, it is not OK. You will set up a conflict that could destroy the Arduino, and even damage the PC via the USB port.

For stable analog readings, you need a stable analog voltage reference. End of story.

IOREF is +5V on a REV 3 Arduino.

Suggest you not do this.

When I Google "CJMCU-36", I get an MPX7002 pressure sensor.
These sensors are ratiometric, and must be read with default Aref to be stable.
Not with a voltage reference, and not with 1.1volt Aref.

Show us how you have connected the sensor (real picture).
Leo..

These sensors are ratiometric, and must be read with default Aref to be stable.

If you bothered to read the original post, that is what the OP seems to have done, and it doesn't work. Agreed, we need to see a complete circuit diagram to know for sure.

However, it is not true that a ratiometric sensor must be read with the default ADC reference voltage. Either make the sensor power voltage stable and use a stable ADC reference, or read the sensor power voltage with the ADC and form the ratio programmatically.

jremington:
If you bothered to read the original post, that is what the OP seems to have done, and it doesn't work.

I did read it, and 15 mapped values out of 100 (153 A/D values, 15%) is quite a lot.
USB supply and 5volt from the internal regulator shouldn't be that far off.
Therefore I asked for a real picture of the setup.

jremington:
It is simply not true that a ratiometric sensor must be read with the default ADC reference voltage. Either make the sensor power voltage stable and use a stable ADC reference, or read the sensor power voltage with the ADC and form the ratio programmatically.

Sure, but is't a lot easier to work with one variable than with three.
Leo..

The MPXV7002DP pressure sensor is specified for operation only between 4.75 and 5.25 V.

According to the data sheet, the sensor is not guaranteed to be ratiometric if operated outside this voltage range, therefore operation with USB power is not recommended.

In other words, power the Uno via the barrel jack or regulated 5V to Vcc, use the Arduino 5V to power the sensor and use the default AREF.

USB supply is AFAIK usually well within that voltage range, and the Uno with mosfet backflow protection has very little voltdrop between USB and 5volt rail (different story for a Nano).
Still like to see a real picture of the setup, because 15% off doesn't sound 'normal'.
Leo..

Hopefully when you use your 12-5v power supply you have it connected to the 5v pin on the Arduino and not the Vin connection

Wawa:
USB supply is AFAIK usually well within that voltage range, and the Uno with mosfet backflow protection has very little voltdrop between USB and 5volt rail (different story for a Nano).
Still like to see a real picture of the setup, because 15% off doesn't sound 'normal'.
Leo..

Its easy to lose voltage in a low-voltage setup if somethings taking current and the wiring is cheap and flimsy though. Without knowing the details of the power source, wiring and load current I'd never assume USB power is so spot-on!

Sorry took so long to get back... I've been out of town. I think I got it figured out. I was only inputting 5v. That is not enough for the Arduino to run on. The specs RECCOMEND 7-12v input for the UNO, but limit is 6-20v. The 5v was below the RECCOMENDED. I am now using my 120v to 12v convertor and am inputting 12v. My readings are now staying the same no matter if USB in plugged in or not. Thank everyone for their thoughts and help.