ATTiny85 Interrupt

I am using an ATTiny85 with a contactless water sensor and a buzzer.
The idea is that when NO water is detected, the buzzer will sound.
I am using the PinChangeInterrupt library.
The following code works great and the interrupt fires and switches the buzzer on.
However, I am using CHANGE with the interrupt and the problem is that a change must take place before the interrupt fires.
This creates a problem in that on power ON, the buzzer sounds even though water is detected.
Is it possible to have a FALLING or RISING event to fire the interrupt?
I have tried both and the interrupt does not fire when water is not detected by the sensor.

/*
 * Sensor is active HIGH - when NO water is sensed
 */


#include "PinChangeInterrupt.h"

const int  sensorPin = 3;    // the pin that the pushbutton is attached to
const int buzzerPin = 1;       // the pin that the LED is attached to
int sensorState = 1;

void setup() {
  // set pin to input with a pullup, led to output
  pinMode(sensorPin, INPUT_PULLUP);
  pinMode(buzzerPin, OUTPUT);

  // Attach the new PinChangeInterrupt and enable event function below
  attachPCINT(digitalPinToPCINT(sensorPin), senseSensor, CHANGE);
}

void senseSensor(void) {
  sensorState = digitalRead(sensorPin);
}

void loop() {
  if (sensorState == 1){
    digitalWrite(buzzerPin, HIGH);
  }
    if (sensorState == 0){
    digitalWrite(buzzerPin, LOW);
  }
}

Try this

/*
 * Sensor is active HIGH - when NO water is sensed
 */


#include "PinChangeInterrupt.h"

const int  sensorPin = 3;    // the pin that the pushbutton is attached to
const int buzzerPin = 1;       // the pin that the LED is attached to

volatile int sensorState = 1;

void setup() {
  // set pin to input with a pullup, led to output
  pinMode(sensorPin, INPUT_PULLUP);
  pinMode(buzzerPin, OUTPUT);

  // Attach the new PinChangeInterrupt and enable event function below
  attachPCINT(digitalPinToPCINT(sensorPin), senseSensor, CHANGE);
  
  sensorState = digitalRead(sensorPin); // Read the state
}

void senseSensor(void) {
  sensorState = digitalRead(sensorPin);
}

void loop() {
  if (sensorState == 1){
    digitalWrite(buzzerPin, HIGH);
  }
    if (sensorState == 0){
    digitalWrite(buzzerPin, LOW);
  }

No idea why you use an interrupt for that.
Assuming your code does nothing else...
Leo..

const byte  sensorPin = 3;
const byte buzzerPin = 1;

void setup() {
  pinMode(sensorPin, INPUT_PULLUP);
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  digitalWrite(buzzerPin, digitalRead(sensorPin));
}

I still get buzzer on Power ON

Yes, many thanks, I have also created the same code and it works great.
This is my code:

const byte  sensorPin = 3;
const byte buzzerPin = 1;

void setup() {
  pinMode(sensorPin, INPUT_PULLUP);
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  delay(5000);
  digitalWrite(buzzerPin, digitalRead(sensorPin));
}

I don't know is the delay is in the correct position.
I only want to delay for 5 seconds if the sensorPin is HIGH.
I must now create a beeping sound, not a constant beeeeeeep.

Even with this code, I still get buzzer with Power ON.
My sensor output:
5.12V - NO water detected
26.8mV - Water Detected

What could possibly be the problem?

Tell us about this sensor.
How is it powered?
If it outpus 5V, then you don't need a pullup

Then try something like this as your loop function:-

void loop() {
if(analogRead(sensorPin) < 6) {
      for(int i = 0; i<5 ; i++){
          digitalWrite(buzzerPin, HIGH);
          delay(500);
          digitalWrite(buzzerPin, LOW);
          delay(500);
    }
   }
}

It is a noncontact device that fits on the outside of the non-conductive container.
It is powered by 5v

The same supply that powers the ATtiny?
Maybe this sensor outputs a Highlevel while it is being turned on.
Try putting a 5 to 10 second delay in setup()

This is the sensor I am using:

Did you read the notes on the product wiki.
The liquid level needs to be BELOW the sensor when you apply power, otherwise it will NOT work correctly.

OK,
That is the problem - this sensor will not work for me

If the water level is above the sensor when you apply power, then no that sensor will not work
Can you leave power to the sensor on all the time?

Yes - that is no problem

Then, make sure the glass is empty.
Apply power to the sensor and give it a few seconds to calibrate.
Fill the glass
Then start the Arduino program.
It should work but if you turn off power to the sensor then you need to start over with the empty glass.

Sorry, my mistake.
The device is fitted to a vehicle and monitors the water coolant level in the coolant bottle.
Every time the ignition is turned ON, the device powers up.
I am thinking of a way that I can "Fool" the device (ATTiny85) into thinking that it has started (Booted) up with the sensor in an empty state, then read the sensor and record either an empty or full state.
Possibly by using additional pins on the ATTiny85 as 1 output and 1 input and use this as a phantom empty state on Boot?

If the sensor is powered up with liquid in front of it, it will never work.
There is nothing you can do.
The sensor must be powered up ONLY when there is no liquid in front of it.

Many, many thanks for all your input.
Much appreciated.

I sorry it can't be made to work the way you need.
Will you try a diferent sensor?