Nano analogue input reading oscillates incorrectly

Sorry if this is a tedious questions but I'm new to Arduino so bear with me please.

I'm trying to do a simple voltage reading with my Arduino Nano (which is powered by USB).

I have a circuit laid out on my breadboard powered by a 9V battery, and I'm trying to read the voltage going into my buzzer. But the reading on the serial monitor oscillates from 0v to 5v. Is the pin floating? It shouldn't be???

Also when the Nano is standalone ie. when there is no input connected, it prints voltages ranging from 1.10V to 2V. Is this just noise?

The code for the Nano is here:

int analogPin = 6;  //Pin A6
float voltage = 0.0;

void setup() {
  Serial.begin(9600); //Setup serial monitor
}

void loop() {
  // read the raw data coming in on analog pin 0:
  int analogIn = analogRead(analogPin); 
  // Convert the raw data value (0 - 1024) to voltage (0.0V - 5.0V):
  voltage = analogIn * (5.0 / 1024.0); 
  
  Serial.println(voltage);
  delay(200);
}

I've attached a screenshot of the reading when the Nano is standalone and another screenshot of when there is a input at pin A6.

I'd appreciate any suggestions!
Thanks

Is the buzzer being driven by a DC voltage? Is there a common ground between the buzzer circuit and the Arduino?

You can check the analog input by grounding it (should read about 0v) and then by connecting it to +5V.

Is the buzzer being driven by a DC voltage?

Yes? The circuit is powered by a 9V battery (E battery?)

Is there a common ground between the buzzer circuit and the Arduino?

Sorry I don't know what you mean here. The Nano isn't connected to the circuit on the breadboard, its sits separately on the other half of the breadboard.

You can check the analog input by grounding it (should read about 0v) and then by connecting it to +5V.

If I stick the pin into the +ve or -ve of the breadboard power rail that is being powered by the 9V battery, the Nano continues to oscillate between 0V-5V. So no change there.

If I stick the pin into the Nano's own 5V then it prints 5V, and if I stick it into the Nano's GND then it reads 0V.

A common ground means that all grounds in a system are connected together. Without it then external things will not work.
A much more useful thing would be if you post a picture of your wiring and schematic in place of two rather useless screen dumps.

I fixed it.
I wasn't connecting the Nano ground to the circuit ground. :sweat_smile:

Thanks for the help!