MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Button

    Scheduled Pinned Locked Moved Troubleshooting
    23 Posts 9 Posters 21.9k Views 5 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • KirAsh4K Offline
      KirAsh4 Moderator
      last edited by

      Yeah, that’s a floating button. You need a pull-down on it, a known state, so the rpi can detect a change. You can either do that in software with RPi.GPIO and configuring it as such:

      GPIO.setup(PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
      

      Or through hardware:
      https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/buttons_and_switches/

      A Life? Cool! Where can I download one of those from?

      1 Reply Last reply Reply Quote 0
      • D Offline
        dicker182
        last edited by dicker182

        Okay, now I have a script button.py which starts with rc.local after boot.

        import RPi.GPIO as GPIO
        import time
        
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(9, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        GPIO.cleanup()           # clean up GPIO on normal exit
        

        But it´s also not working. Did I miss something?

        1 Reply Last reply Reply Quote 0
        • KirAsh4K Offline
          KirAsh4 Moderator
          last edited by

          Different permissions. Your rc.local runs with system privileges, however the MM² task runs as the pi user. You need to have those GPIO setting in the script that the pi user runs.

          A Life? Cool! Where can I download one of those from?

          1 Reply Last reply Reply Quote 0
          • D Offline
            dicker182
            last edited by dicker182

            Okay thanks, the script now starting as user pi.
            Other question, has my button.py script to run in a loop?

            EDIT: Okay the message “button pressed” are coming when I turn the floor lights on 0o?

            1 Reply Last reply Reply Quote 0
            • KirAsh4K Offline
              KirAsh4 Moderator
              last edited by

              1. Take out that 'GPIO.cleanup()' call that you have. That resets everything you just did above it.
              2. Button getting triggered because you turning on the floor (?) lights is because that button is still floating, see #1 above.
              3. I’m assuming the rpi isn’t on the same circuit as the floor (??) lights, a voltage difference could also falsely trigger the button.

              A Life? Cool! Where can I download one of those from?

              1 Reply Last reply Reply Quote 0
              • D Offline
                dicker182
                last edited by dicker182

                Yes it seems it is on the same circuit. The button is pressed when the light goes on and when the light goes off… :D unbelievable

                C 1 Reply Last reply Reply Quote 0
                • KirAsh4K Offline
                  KirAsh4 Moderator
                  last edited by

                  So your rpi is then experiencing a dip in voltage, which is coming from whatever you have it connected to, I presume a wall adapter. What’s the output of that adapter? What’s the Amp rating on it? Is it a regulated or unregulated? The latter means with no load, it could very well be supplying ad much as 7-9V, and with a load it drops to 5V, however it also means it will dip rather low if something else comes on on the same circuit. Unfortunately there is no easy way to tell other than to measure its power output.

                  A Life? Cool! Where can I download one of those from?

                  1 Reply Last reply Reply Quote 0
                  • C Offline
                    CGabo @dicker182
                    last edited by

                    @dicker182
                    See my previous posting:

                    Probably the cause is some voltage / EMI feedback, likely due to the wires and switches. Try to switch on/off some lights and electrical devices and see the result!
                    To correct this condition, use a combination of current limiting, filtering and shielding.
                    ;-)

                    Did you read the link?
                    https://www.raspberrypi.org/forums/viewtopic.php?t=53548

                    Try following:

                    • Reduce the cable length to the switch.
                    • Detect either only the rising (GPIO.RISING) or falling event.
                    • Use bouncetime in ms (minimum time between two callbacks in milliseconds (intermediate events will be ignored))
                    • Use a capacitor, see folowing example.
                      http://raspberrypihobbyist.blogspot.ch/2014/11/debouncing-gpio-input.html
                    1 Reply Last reply Reply Quote 0
                    • cruunnerrC Offline
                      cruunnerr
                      last edited by

                      Hi,
                      after I install the module and type “pm2 restart mm” there is just a white screen. No UI loaded. Any idea?

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        dicker182
                        last edited by

                        @All, sry for the lait answer, I followed all your guides, but I can´t solve the problem. I have to use another power circuit.

                        @cruunnerr, same here, you have to restart your pi. After the video starts for the first time, the bug is there. You can only reload mm when the video never starts in the same session.

                        1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 3
                        • 1 / 3
                        • First post
                          Last post
                        Enjoying MagicMirror? Please consider a donation!
                        MagicMirror created by Michael Teeuw.
                        Forum managed by Sam, technical setup by Karsten.
                        This forum is using NodeBB as its core | Contributors
                        Contact | Privacy Policy