-3

Which python library is best one to use for programming RPI? I want to program RPI zero and Rpi 3 model B+ using python.

I know that there is a GPIO library available for RPI. However, in its readme file, it was mentioned that it is not suitable for time critical applications.

Still, is it the only library available for programming rpi in python? In my application, I may have to use the 1kHz loop. Will it be possible with the GPIO library?

closed as unclear what you're asking by Steve Robillard, Milliways, joan, Dmitry Grigoryev, tlhIngan Jul 23 '18 at 16:36

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Consistent timing with microsecond resolution is impossible to implement in a Linux application. – Dmitry Grigoryev Jul 9 '18 at 11:03
  • @DmitryGrigoryev thanks. what is the solution to get the microsecond resolution timing loop. is there a real time OS available? – Aayvu.com Jul 10 '18 at 4:34
  • @DmitryGrigoryev That is not true. I use microsecond timing on a regular basis on the Pi under Linux. Linux not being real-time is true but that does not prevent microsecond timing in specific cases, it depends on what you are actually doing. – joan Jul 10 '18 at 8:48
  • @joan Yeah, that's what I meant by consistent. Does nanosleep(1000) always take 1 microsecond? – Dmitry Grigoryev Jul 10 '18 at 10:57
  • @DmitryGrigoryev No, all Linux sleeps are a minimum time. If you use a 4 core Pi it is possible to reserve a core and some people report that gives very good results. Personally I would use the DMA timing capabilities exposed by (my) pigpio for microsecond timing and above. – joan Jul 10 '18 at 12:17
1

It is a pity you didn't originally ask about GPIO libraries. Your original question made little sense.

There are at least 5 Python GPIO libraries.

They each have their own merits.

See https://elinux.org/RPi_GPIO_Code_Samples#Python for code examples of most.

The RPi.GPIO, pigpio, and gpiozero Python modules are normally pre-installed on full Raspbian images. gpiozero is the Raspberry Pi foundations preference.

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