I connected my Arduino Uno to my raspberry via USB serial. I'm able to read out both digital and analog pins of my Arduino using the Python nanpy library (v.0.8). However, I can't find support for the pulseIn() function. It seems nanpy doesn't support pulseIn() at all.

What is the best way to measure PWM signals with the Arduino and forward the results to the Raspberry Pi?

I am able to measure PWM using the Arduino GUI, however I would to take PWM samples at fixed time intervals over a long period of time and combine this data with other measurements that my Raspberry is making.I also tried pyFirmata, but it doesn't support pulseIn() measurements either.

  • It seems like this could be a fairly trivial addition, if you can find the source code for both the Arduino and host portions, and successfully build and use new versions. Often it's useful to try to create and test a from scratch build before you try to modify it. But it may also be possible you run into more complicated interactions, for example if the usual pulse timing mechanism delays expected traffic. Nov 11, 2014 at 17:13

2 Answers 2


You can just have a sketch in the arduino that takes the measurements at whatever interval you want using the analogRead(pin) function and then forward those results to the raspberry pi via serial using Serial.print(whatever you want here). If you don't know how to use serial with arduino just go to their site, they have very good documentation. Hope that helps :)


Nanpy seems to have a CounterClass that does frequency measurements.

Or do you want to measure the PWM duty-cycle?

  • I would like to measure the downratio. Preferably I would use pulseIn to measure one uptime pulse and one downtime pulse. From this I can calculate the desired downratio.
    – Timtico
    Nov 10, 2014 at 19:52

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.