Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    [WiPy 2.0] cannot configure Pin to generate interrupts

    Scheduled Pinned Locked Moved WiPy 2&3
    wipy2.0pininterrupt
    3 Posts 2 Posters 1.9k Views 2 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.
    • C Offline
      Corbie Pybytes Beta
      last edited by

      I am trying to set up a simple button on WiPy 2.0 with Expansion board. I have updated the firmware to v1.8.6:

      import os
      os.uname()
      # (sysname='WiPy', nodename='WiPy', release='1.6.3.b1', version='v1.8.6-463-g468b9d27 on 2017-02-16', machine='WiPy with ESP32')
      

      When I am trying to register a event handler like they did in the docs, the irq() function seems not to be available:

      from machine import Pin
      
      def pin_handler(pin):
          print(pin.id())
         
      pin_int = Pin('G17',  mode=Pin.IN,  pull=Pin.PULL_DOWN)
      pin_int.irq(trigger=Pin.IRQ_RISING,  handler=pin_handler)
      #   File "<stdin>", line 7, in <module>
      # AttributeError: 'Pin' object has no attribute 'irq'
      

      Am I doing something wrong or is the function really missing?

      Is there another way to get a simple, external button working on the WiPy?

      1 Reply Last reply Reply Quote 0
      • J Offline
        jmarcelino
        last edited by

        You're following the Micropython.org docs but this is done differently on the latest Pycom boards.

        Follow the Pycom documentation instead:

        https://docs.pycom.io/

        more specifically what you need to is to create a Pin.callback() function:

        https://docs.pycom.io/pycom_esp32/library/machine.Pin.html#machine.pin.callback

        1 Reply Last reply Reply Quote 3
        • C Offline
          Corbie Pybytes Beta
          last edited by Corbie

          Thank you, this has solved the issue:

          pin_int = Pin('P10', mode=Pin.IN, pull=Pin.PULL_DOWN)
          pin_int.callback(Pin.IRQ_RISING, pin_handler)
          
          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            Last post

          Pycom on Twitter

          Pycom