Hello, I wanted to connect this 24v sensor to my arduino, I would power it using a 24v power supply, my question is, do I have to connect the ground of my power supply to arduino GND?
Make a drawing telling how You intend to connect things.
Yes, you do.
However, given that if you get this wrong 24V will fry an Arduino instantly please post a schematic showing how you intend to connect everything and let us check before you connect power.
Hand drawn and photographed is fine.
Thanks for the schematic.
It is normal practice to use black for negative and red for positive, using them opposite way round is confusing!
You have drawn gnd, positive and negative separately on your 24V power supply, this is almost certainly wrong if you have the kind of power supply I suspect you have. Please post a photo of the power supply clearly showing the connections and how they are labelled.
Thanks for the fast respone, sorry I didn't know about the color convention! The power supply I use is of this type, I've read online that it's possible to short the gnd and negative( in this case connecting -V and the ground symbol) to put it at the same voltage of the house earth.
Ground Earth on that PSU is a connection to the metal body of the case and is for safety, you should connect it to the safety earth wire from the power lead. It is not connected to either output connection, so won't help you as you have it drawn.
Ground / 0V (zero volts, not 'no volts') is as designated by the circuit designer and is often the negative pole of the power supply but can be the positive pole if the circuit design requires it.
In your case connect the ground / 0V / negative from the Arduino 5V power supply to the negative of the 24V power supply. Please draw a new schematic so I can check you have understood correctly.
More information:
Thank you , I've read your article and it was helpful. 1) So connecting grounds is necessary to close the 'loop' and allow the current to circulate in the right way in the circuit, is that right?Also the ground is the reference point from which all the voltages are measured, therefore we have to connect them to avoid problems of "reference" in various electronic components.
2)If I have understood correctly that earth symbol must be connected to the wire that goes to the power outlet, so the schematic should be like this:
One last question, why sometimes earth and negative ports are shorted in power supplies, here's an example:

Your schematic is good, but there's still a potential problem: You've not told us what the mystery sensor is that is powered by 24V, and you've not told us what the output voltage range is from the sensor. I cannot confidently say there won't be more than 5V on its output, so there still remains the danger that more then 5V will be presented to the Arduino. What is this sensor?
Can also be positive 'ports', it depends on whether ground / 0V is negative or positive. Negative is common these days, but positive is also used in some circuits. It can be for safety, to make sure there is a path to earth (the muddy stuff outside) in the event of a fault, it can be to provide a path for noise to earth, it can be so that a radio transmitter / receiver has a path to ground (I don't know much about radio, someone else can comment about that).
Thank you for the fast answer,it's a 10-30volts photoeletric sensor, I fear that by connecting it directly to arduino I would ruin my arduino, those are the infos I was able to find
So do I, but there's not enough information there to know. You need information about what output it gives. Do you have a multimeter? If not buy one, a cheap one is far better than none at all. Measure the output voltage and how it changes when the sensor does its thing.
Post the brand name and exact part number of your sensor.
Yes thank you, I'm going to buy a multimeter because there's much information about this sensor (it's from china so that's pretty much all I know about it)
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.