Hi there, I'm quite new to electronics and am having some trouble getting a PNP liquid sensor to work properly. I'm using an Aduino Uno with a 12V DC power supply. I understand that I need to use a potential divider to drop the voltage but I'm slightly confused as to where to wire everything else. The data sheet for the sensor can be found here:https://www.sick.com/media/dox/5/85/385/Product_information_MHF15_Level_sensors_en_IM0039385.PDF
Looks like the signal voltage will be about 9.1 volts so a 2:1 divider would give about 4.5V to a digital input pin, bring your signal to one end of a 10k resistor, the other end of that resistor to a second 10k, the other end of that to GND, connect a wire from the center point of the 2 Rs to a digital input pin of your choice.
EDIT: You also need to connect the sensor GND (blue wire) to Arduino GND.
EDIT II: Might be better to go with 12 or 15k to limit current into the pin in case of wiring fault.
I should mention that before knowing all of this, I had the sensor powered by the 12V with no voltage divider. The black wire (output) was connected to the 1st analogue pin on the arduino. It seemed to read 0V even when submerged in liquid. I understand that this was a mistake (I misread the datasheet) since the output voltage is too high for the analogue pins but nothing seemed to happen. I haven't damaged the arduino and the pins are all working since I checked using another 5V sensor. Is it normal to see constant 0V if a PNP sensor is wired this way?
Well, putting more than 4.96 volts on an analog pin should read 1023 on the ADC count, did you have the blue wire connected to Arduino GND at that time?
Yeah it was connected to ground on the bread board, which was wired to the arduino. The sensors are definitely functioning as I can see the red LED come on when the circuit is powered.
Test your analog pins with the 3.3V supply, you should see about 675 on the ADC count, if not your your Mega328 chip was probably damaged, but if you have a UNO with the DIP chip it's easy to replace.
BTW, you don't need to use an analog input with an ON/OFF signal unless you're short on digital pins.
They don't appear to be broken, testing them with the method you mentioned returns about 677 each time.
Edit: I'm using analog pins since I'm carrying out an investigation to see if minor fluctuations in the output voltage are caused by different scenarios.
Update: I wired it the way you explained except I chose to use a 15K as R1 and a 10K as R2. The sensor switches on and I now get 4.33V at the analog pin. To check again to ensure that it wasn't damaged I wired the the analog pin to the 3.3V and it read about 677 again. I find it odd that the pin reads 4.33V when with that voltage divider, shouldn't it be closer to 3.6V?