analogReference(INTERNAL) while using 9v adapter as power supply

Hi all,
I am working on an IOT project and I am measuring an piezoelectric vibration detection, and after a lot of work and some of the help here it works GREAT.
So THANK YOU arduino community .

I have one last problem (I hope), while debugging with the usb serial port, that also acts as the power supply, the code works great.

When I switch to the 9v power supply the relay pin just toggle on off and i pretty sure the analog pin reading have changed.
Some how related to the analog ref pin and my power supply I guess ..
What will be the best solution?

1.I need the 9v to power light via the relay and to power the arduino in parallel
2.I need the internal ref to get the very light vibration sensing ..
Thanks for the help!

Some details on this supply? (ie full details) - and what exactly are the loads you mentioned?

With USB your arduinos supply voltage is at the mercy of the host computer's motherboard and losses
in the cambling, so you'd normally see 4.6 to 4.8V or so.

With a 9V supply to Vin, you are likely to get a decent 4.9 to 5.1V on the Arduino 5V courtesy the on-board

Hi MarkT,
Thanks for replaying.
I am using a 12V power supply 2Amp general adapter.
I didn't write anything about loads, but I will refine that I am using a piezo beam connected to analogread A0 with 1 mega resistor in parallel.
The code also activate a relay that switch the leds.
I use the 5V pin to power the relay and I use the Vin to get 12V to the switch circuit of the relay.

I am using internal reference function that gives a ref of 1.1V.

When connected with usb only -> The system works good
When connected with usb +12v adapter -> The system works good

When connected only with the 12V adapter -> The relay just toggle on and off I think it's because the Ref signal isn't stable
It got something to do with that I am connecting the relay to the Vin pin
Please any suggestions ?

Your relay has free-wheel diode?