# How to read a signal from an 24v speed sensor (two of them are available)

**URL:** <https://forum.arduino.cc/t/how-to-read-a-signal-from-an-24v-speed-sensor-two-of-them-are-available/1201959>\
**Category:** Sensors\
**Created:** [December 19, 2023, 4:47pm UTC](https://forum.arduino.cc/t/how-to-read-a-signal-from-an-24v-speed-sensor-two-of-them-are-available/1201959 "2023-12-19T16:47:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sediksultan](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sediksultan/32/1026029_2.png) [@sediksultan](https://forum.arduino.cc/u/sediksultan)\
**Post date:** [December 19, 2023, 4:47pm UTC](https://forum.arduino.cc/t/how-to-read-a-signal-from-an-24v-speed-sensor-two-of-them-are-available/1201959/1 "2023-12-19T16:47:11Z")

</div>

Hello people, I would like to connect the sensor cable (see picture) to the Arduino and read out the signal. However, the signal is 24 V, which is of course too much for the Arduino. Would a voltage divider make sense in this case?  
And what is the best way to read the signal? Are there special code or libraries that are recommended for this? (this is a PWM signal)

 ![Screenshot 2023-12-19 171723](https://europe1.discourse-cdn.com/arduino/original/4X/2/c/2/2c2a6866d364847401e378edcbd47ae5da6bdd84.png)

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [December 19, 2023, 4:51pm UTC](https://forum.arduino.cc/t/how-to-read-a-signal-from-an-24v-speed-sensor-two-of-them-are-available/1201959/2 "2023-12-19T16:51:35Z")

</div>

The safest approach is to use an optoisolator between the sensor output and the Arduino input.

---

<div class="post-metadata">

**Author:** ![gilshultz](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gilshultz](https://forum.arduino.cc/u/gilshultz)\
**Post date:** [December 19, 2023, 4:57pm UTC](https://forum.arduino.cc/t/how-to-read-a-signal-from-an-24v-speed-sensor-two-of-them-are-available/1201959/3 "2023-12-19T16:57:37Z")

</div>

I have seen similar units and the output is an open collector from an NPN transistor or contact. Try connecting it with a pull up to 5V and measure the voltage. This would be the simplest solution. For an optoisolator you will need power on both the diode side (from the encoder) and the output side to the Arduino. These could be simple resistors on the input and an Arduino internal pull up for the isolator output.

---

<div class="post-metadata">

**Author:** ![sediksultan](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sediksultan/32/1026029_2.png) [@sediksultan](https://forum.arduino.cc/u/sediksultan)\
**Post date:** [December 19, 2023, 6:40pm UTC](https://forum.arduino.cc/t/how-to-read-a-signal-from-an-24v-speed-sensor-two-of-them-are-available/1201959/5 "2023-12-19T18:40:50Z")

</div>

Thank you i did it, but i still need the Arduino code for it! Do you perhaps also have a suitable code that could be used to read the speed value?

---

<div class="post-metadata">

**Author:** ![gilshultz](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gilshultz](https://forum.arduino.cc/u/gilshultz)\
**Post date:** [December 19, 2023, 8:09pm UTC](https://forum.arduino.cc/t/how-to-read-a-signal-from-an-24v-speed-sensor-two-of-them-are-available/1201959/6 "2023-12-19T20:09:42Z")

</div>

Not anymore but the code also needs to support the clock rate you will be seeing. This has a big impact on how the code is written.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 16, 2024, 8:10pm UTC](https://forum.arduino.cc/t/how-to-read-a-signal-from-an-24v-speed-sensor-two-of-them-are-available/1201959/7 "2024-06-16T20:10:16Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
