-short answer: using an arduino does the Job- "Reading PWM Receiver Signal Using Arduino": https://www.youtube.com/watch?v=ncBDvcbY1l4

I have just started controlling electronic circuits with software, so I have very little experience.

I am searching for a way to get a PWM signal into my raspberry pi. (In particular form a RC receiver, so that I can modify the signal and pass it on to the servos, a bit like fly by wire used by modern airliners. I have already succeeded in sending PWM to the servos using the pca9685).

If there would be a similar device, that can to the exact opposite -reading incoming PWM signals and converting them to a signal I could get via I²C- it would be awesome. I have not found anything like that. If there is no such thing, do you have any idea how I could overcome the problem?

My PWM is around 50kHz with pulses between 900 and 2100 ns. I need at least +-25ns accuracy.

  • \$\begingroup\$ Why not low-pass filter and use an ADC? \$\endgroup\$
    – The Photon
    Commented Oct 12, 2016 at 15:56
  • \$\begingroup\$ You could always run the PWM into an integrator circuit (RC), and then use and I2C ADC to read it, then not have to worry about nanosecond timings \$\endgroup\$
    – infixed
    Commented Oct 12, 2016 at 16:11
  • \$\begingroup\$ what do you want to measure about the PWM? the Duty Cycle? In that case, your +-25ns specification doesn't make too much sense. If you need the absolute pulse duration, the problem is a bit harder, but might be manageable by cycle counting. \$\endgroup\$ Commented Oct 12, 2016 at 16:11
  • \$\begingroup\$ If it is for RC application then you probably need pulse width, not duty cycle. \$\endgroup\$
    – Wesley Lee
    Commented Oct 12, 2016 at 18:07

1 Answer 1


On Raspberry Pi (any model) you have a number of GPIO inputs. You may want to program them for rising and falling edge detection, marking the timestamp on each of the events and calculating the PWM programmatically. This however requires Linux kernel driver programming skills as userspace interface to GPIO may be too slow to provide an adequate response.

Alternatively, you could use Raspberry Pi's ADC input connected to your incoming PWM signal via a low-pass RC filter.

You may also use an external I2C ADC with a RC low-pass filter or you may craft your own digital I2C PWM reader using an additional STM32F030 chip and it's general purpose timer in Input Capture mode.

You may want to review the answers to this question at Raspberry Pi StackExchange: https://raspberrypi.stackexchange.com/questions/9787/pwm-input-in-raspberry-pi

  • 1
    \$\begingroup\$ Thanks for your answer, but I just found a solution my self: just using an arduino for reading the values and sending them via i2c or USB to my Pi seems to do the job completely fine. \$\endgroup\$
    – Simon
    Commented Oct 19, 2016 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.