Coder Social home page Coder Social logo

Comments (4)

Gadgetoid avatar Gadgetoid commented on July 30, 2024

Are you sure that the first example actually works? In both cases the fan should turn back on again because the Python script will release control of the GPIO upon exit and the pin should return to being an input.

There's no simple way around this, since the GPIO shouldn't be owned or asserted by a script that's not running. One approach is to ensure your Python script continues to run, and use it like a service to control the fan/light. We're lacking a good example of this in action and I think we should have one since this is a common question.

from fanshim-python.

thunderbiscuit avatar thunderbiscuit commented on July 30, 2024

Weird. Indeed the first example works (keeps the fan off after the script returns) for me! I tested this very script this morning:

from fanshim import FanShim

fanshim = FanShim()

fanshim.set_fan(False)
print('The fan is now off')

And the fan does stay off after the script prints to console and returns. @Gadgetoid would you like me to open a separate issue for this?

from fanshim-python.

Gadgetoid avatar Gadgetoid commented on July 30, 2024

I'll have to try this myself- I can't fathom any reason why the scripts would differ. Either way, keeping a program running is the "technically correct" way to assert the fan as off, but since on the Raspberry Pi it's normal to completely bypass any proper userspace GPIO interface and write the registers directly ... well things don't really work how they should.

from fanshim-python.

thunderbiscuit avatar thunderbiscuit commented on July 30, 2024

All right well thanks for looking into it and clearing things out! It does look like it's a small inconsistency probably coming from proper use of userspace GPIO then. Let me know if there is anything I could do to help test further!

from fanshim-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.