element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Experts, Learning and Guidance
  • Technologies
  • More
Experts, Learning and Guidance
Ask an Expert Forum Is there a way to incorporate Linux hardware drivers into Python projects on SBC's?
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Experts, Learning and Guidance to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 9 replies
  • Subscribers 286 subscribers
  • Views 2720 views
  • Users 0 members are here
  • Single Board Computer
  • sbc
  • raspberrypi
  • linux
Related
See a helpful answer?

Be sure to click 'more' and select 'suggest as answer'!

If you're the thread creator, be sure to click 'more' then 'Verify as Answer'!

Is there a way to incorporate Linux hardware drivers into Python projects on SBC's?

BigG
BigG over 2 years ago

After many years of never having a need to use a Raspberry Pi, or other LinuxOS SBC, I've finally been thrown a project where a multi-core 64-bit processor is required.

I've also been pushed back into using Python where I am having to use various SPI and I2C based sensors.

Having grown so used to, and still love using, microcontrollers and C or C++, this would be fairly straightforward and if using Arduino there are libraries already available to deliver what I need.

So I am rather perplexed by what I am seeing within the SBC - Linux ecosystem.

On the one hard, we have Linux OS and within we have the kernel, and within the kernel we have the possibility to use all these amazing hardware drivers, which are freely available to install and the code is also open to review: https://github.com/torvalds/linux/tree/master/drivers/hwmon

As someone familiar with C/C++ this all looks very comforting.

And then I am confronted with Python. This software has now become the go-to option for many early stage application development projects probably due to Raspberry Pi's popularity.

Now, regardless of the config used (i.e. pure Python or a hybrid with CircuitPython or some other combo), it appears that all these commonly available Linux kernel sensor libraries are simply ignored by Python libraries. How so?

All these Python libraries appear to be relying on "spi-dev" or "SMbus", which are very generic and in the case of spi, this spi-dev is being phased out.

I feel I am missing a trick somewhere and that there are all these LinuxOS + Python experts secretly taking advantage of all these efficient hardware drivers but are just not telling others about it.

So I thought to throw this question out to our community experts so that some can spill the beans, as so far I could only find one related stack overflow question and the feedback in the post was uncharacteristically weaker than most: https://stackoverflow.com/questions/62077718/do-python-libraries-make-use-of-linux-device-driversI

Examples of how you've done this will get bonus points.

I look forward to comment/feedback.

  • Sign in to reply
  • Cancel

Top Replies

  • shabaz
    shabaz over 2 years ago +5
    Hi Colin, Most of these drivers you indicate are kernel-space, and will be accessed using the file system (with paths that look like normal files), so there's nothing different that needs to be done…
  • colporteur
    colporteur over 2 years ago +2
    I am going to throw out what I know for what it is worth. I use GPIOzero python library to interface to typical maker type hardware (buttons, LED's..) with the exception of servos. For those I load a…
  • BigG
    BigG over 2 years ago in reply to shabaz +1
    shabaz said: If you're working on a Pi with Python, then you would use one of the modules for it - such as GPIOzero as Sean mentions. There's a summary here: medium.com/.../raspberry-pi-python-libraries…
Parents
  • colporteur
    colporteur over 2 years ago

    I am going to throw out what I know for what it is worth.

    I use GPIOzero python library to interface to typical maker type hardware (buttons, LED's..) with the exception of servos. For those I load a driver pigpio. If you read the GPIOzero doc on servos' they recommend you go to pigpio to get better support. I noticed in the GPIOzero docs there is a listing for SPI device.

    I'm not sure if this helps but you have thrown me helpful bones in the past and felt I owed you a response. Limited as it is.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • BigG
    BigG over 2 years ago in reply to colporteur

    Yes, that is a useful library alright and is not a library I've worked with before. It certainly seems to provide a good range of options. So thanks for the suggestion. I see they offer some functions like this Button function which includes debounce... nice.

    class gpiozero.Button(pin, *, pull_up=True, active_state=None, bounce_time=None, hold_time=1, hold_repeat=False, pin_factory=None)

    I'm now very curious to see what's under the hood...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • colporteur
    colporteur over 2 years ago in reply to BigG

    Well looking there, it has a debounce. I've struggled with that in Arduino but never knew there was a solution in python for Pi. I haven't played with Pi for some time.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • colporteur
    colporteur over 2 years ago in reply to BigG

    Well looking there, it has a debounce. I've struggled with that in Arduino but never knew there was a solution in python for Pi. I haven't played with Pi for some time.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube