004 - ESP32 MicroPython: External Interrupt

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ส.ค. 2024
  • In this video, we will learn 2 ways to read the state of an input device like a button switch. Firstly, is by using a polling method and secondly, by using interrupts. At the last part, I will demonstrate an example of controlling a DC motor with limit switch at both ends using interrupts.
    Circuit diagram and source code is available at my blogpost at:
    techtotinker.c...
    Please COMMENT, LIKE, SHARE and SUBSCRIBE.
    Thank you.
    #TechToTinker

ความคิดเห็น • 42

  • @ancientegyptandthebible
    @ancientegyptandthebible 3 ปีที่แล้ว +2

    Nice tutorial. Very clearly explained. I like the clarity of your engineering.

    • @TechToTinker
      @TechToTinker  3 ปีที่แล้ว

      Hi, Im happy to hear that. Thank you.

  • @ahmedrg7131
    @ahmedrg7131 ปีที่แล้ว

    Thank you sir, this helped me to start with microPython and improve my CV 🙏🙏

  • @karlivares8401
    @karlivares8401 3 ปีที่แล้ว +1

    Great video !

    • @TechToTinker
      @TechToTinker  3 ปีที่แล้ว

      @Karl Ivares, thank you.

  • @the_truth_seeker334
    @the_truth_seeker334 ปีที่แล้ว

    I am coming from JavaScript background. This interrupt callback makes me feel at home.

  • @mytechnotalent
    @mytechnotalent 4 ปีที่แล้ว +2

    This is great and wont block other code. Is there a simple example you can use with serial input like to time a question with interrupts such that respose = input('Enter answer: ') if response == None, print('Fail!') but based on a timer?

  • @punjabilog
    @punjabilog 3 ปีที่แล้ว

    very easy to understand weldone

    • @TechToTinker
      @TechToTinker  3 ปีที่แล้ว

      Hi @Unique Food Machinery ltd, I am glad that you like it. Thank you.

  • @NesbyBone
    @NesbyBone 4 ปีที่แล้ว +1

    Great material, would you create a GUI, for instance in Livy to control a motor? Thanks for the video

    • @TechToTinker
      @TechToTinker  4 ปีที่แล้ว +3

      Hi @NesbyBone, thank you. As of now, I have no experience with Livy. Lets see in the future, I look into it.

  • @Yes-Man
    @Yes-Man ปีที่แล้ว +1

    Isn't there a problem with the parsing operation in the IRQ handler? As far as I understand it, you're not supposed to do anything that allocates memory. What about the str() conversion?

  • @anokhautomation4453
    @anokhautomation4453 3 ปีที่แล้ว

    Very useful tutorial 👍👍

    • @TechToTinker
      @TechToTinker  3 ปีที่แล้ว

      Glad you think so! Thanks.

  • @AzharMdNoh
    @AzharMdNoh 5 หลายเดือนก่อน

    SIr, how can I disable OTA memory in my esp32E by using Thonny. I need more memory

  • @animlwild
    @animlwild ปีที่แล้ว +1

    I don't understand pin parsing. For example for pin 21 ,str(pin) is '21:IN:PULL_UP' then how come str(pin)[4:-1] returns pin number but not ':PULL_U'
    .......
    Please explain

    • @jumbo999614
      @jumbo999614 ปีที่แล้ว

      me too. Don't understand this part.

    • @iskander419
      @iskander419 5 หลายเดือนก่อน

      Try to play with this code and you will understand it :-)
      import machine
      led = machine.Pin(2, machine.Pin.OUT)
      sw = machine.Pin(0, machine.Pin.IN)
      def handle_interrupt(pin):
      led.value(not led.value())
      print("Original string: " + str(pin) + " Parsed string: " + str(pin)[4:-1])

      print("Press BOOT button
      ")
      sw.irq(trigger=machine.Pin.IRQ_FALLING, handler=handle_interrupt)

  • @alzalame
    @alzalame 3 ปีที่แล้ว

    Good explanation

    • @TechToTinker
      @TechToTinker  3 ปีที่แล้ว +1

      Hi Jan, Im glad that you like it. Thank you.

    • @alzalame
      @alzalame 3 ปีที่แล้ว

      @@TechToTinker Please can you explain more the code line : irq_pin = int(str(pin)[ 4 : -1]) is the number 4 detrmining the speed and what -1 presents ?

    • @TechToTinker
      @TechToTinker  3 ปีที่แล้ว +1

      @@alzalame that line of code is use to parse the actual pin number of the interrupt.

  • @jumbo999614
    @jumbo999614 ปีที่แล้ว

    What is the meaning of int(str(pin)[4:-1])
    where does number 4 and - 1 come from? and what is the symbol : between mean?

  • @longhuynh7306
    @longhuynh7306 ปีที่แล้ว

    I have a question sir.
    I realized that the program only runs when I connect the COM port to the computer if I want to do a project on battery power, what should I do sir please answer a question that I am pondering.

  • @ProfessorMarcosCarnevali
    @ProfessorMarcosCarnevali 4 ปีที่แล้ว

    Obrigado pelo vídeo! Like e Inscrito! Abraços...

    • @TechToTinker
      @TechToTinker  4 ปีที่แล้ว +1

      You are welcome @Professor Marcos Carnevali. Cheers and thank you.

    • @ProfessorMarcosCarnevali
      @ProfessorMarcosCarnevali 4 ปีที่แล้ว

      @@TechToTinker também estou fazendo vídeos sobre Micropython, estou aprendendo e ensinando também! Compartilhei o seu vídeo com os meus amigos! Parabéns!!! Abraços...

    • @TechToTinker
      @TechToTinker  4 ปีที่แล้ว +1

      @@ProfessorMarcosCarnevali wow that's cool. Can you share your videos here? I would like to check it out. Thanks

    • @ProfessorMarcosCarnevali
      @ProfessorMarcosCarnevali 4 ปีที่แล้ว

      @@TechToTinker são vídeos bem humildes, para pessoas que apenas conhecem o idioma português. Tthese are very humble videos, for people who only know the Portuguese language. My playlist: th-cam.com/play/PLCcdteC1rwSFvJnUoe0DfORHv4p_1EFps.html

    • @TechToTinker
      @TechToTinker  4 ปีที่แล้ว +1

      @Professor Marcos Carnevali you've got a lot of MicroPython tuts there. Only problem is I can't understand Portuguese :). Anyways I love knowing other people doing similar things as I doing.

  • @matthiasandreas6549
    @matthiasandreas6549 3 ปีที่แล้ว

    Hello is it possible to enable and disable an interrupt?

    • @TechToTinker
      @TechToTinker  3 ปีที่แล้ว

      @Matthias Andreas, I haven't tried it before it says machine.disable_irq() which will disable all esps interrupts. Call machine.enable_irq() to re/enable interrupts. Refer to:docs.micropython.org/en/latest/library/machine.html

    • @matthiasandreas6549
      @matthiasandreas6549 3 ปีที่แล้ว

      @@TechToTinker , hi and thank you yes this way i tried out but on ESP32 i get OSErrors. I will try it again. By the way please can you make a video about Socket Server with ESP32 and micropython?

    • @TechToTinker
      @TechToTinker  3 ปีที่แล้ว

      @@matthiasandreas6549 MicroPython web server: th-cam.com/video/i8b-ZM2VeeU/w-d-xo.html
      Esp32 web server: th-cam.com/video/Lqn2J7LesCY/w-d-xo.html

  • @prakashkalvin7678
    @prakashkalvin7678 ปีที่แล้ว

    Bro.meaning of led.value(not led.value())

    • @prakashkalvin7678
      @prakashkalvin7678 ปีที่แล้ว

      Bro please reply

    • @jumbo999614
      @jumbo999614 ปีที่แล้ว

      @@prakashkalvin7678 toggle the status of the led
      if it's ON then turn it off
      it it's OFF then turn it on.