🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Help with UNIT IR and NanoC6 in Uiflow2

    UiFlow 2.0
    3
    4
    175
    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.
    • H
      HybridZach
      last edited by

      Hi. I usually use M5 products with esphome. I an completely novice with UIflow2 and mycropython. I would like some help using the unit IR to decode a ac remote. I followed the video example on m5docs, and I have an error.

      Here is the code:

      import os, sys, io
      import M5
      from M5 import *
      from unit import IRUnit
      
      
      
      ir_0 = None
      
      
      data = None
      addr = None
      
      
      def ir_0_rx_event(_data, _addr, _ctrl):
        global ir_0, data, addr
        data = _data
        addr = _addr
        print(data)
      
      
      def setup():
        global ir_0, data, addr
      
        M5.begin()
        ir_0 = IRUnit((1, 2))
        ir_0.rx_cb(ir_0_rx_event)
        data = 0
        addr = 27
      
      
      def loop():
        global ir_0, data, addr
        M5.update()
      
      
      if __name__ == '__main__':
        try:
          setup()
          while True:
            loop()
        except (Exception, KeyboardInterrupt) as e:
          try:
            from utility import print_error_msg
            print_error_msg(e)
          except ImportError:
            print("please update to latest firmware")
      

      I get error:

      Traceback (most recent call last):
        File "<stdin>", line 25, in <module>
        File "<stdin>", line 17, in setup
        File "unit/ir.py", line 24, in rx_cb
        File "driver/ir/nec.py", line 116, in __init__
        File "driver/ir/nec.py", line 67, in __init__
        File "driver/ir/receiver.py", line 47, in __init__
      ValueError: invalid Timer number
      

      The only thing that is different from the YouTube video is instead of setting a label to print the data value I am printing it to console, could this be the problem?

      1 Reply Last reply Reply Quote 0
      • Y
        yuyun2000
        last edited by

        The "invalid Timer number" error occurs because the IRUnit is trying to use a hardware timer that's either unavailable or already in use on your M5 device. ESP32-based boards have limited hardware timers (usually 4, IDs 0-3), and the default timer allocation in the IR library might conflict with other system functions.
        Solution:Explicitly specify a valid timer ID when initializing the IRUnit. Modify your setup code to include the timer_id parameter with a value between 0-3:
        ir_0 = IRUnit((1, 2), timer_id=1) # Try timer IDs 0, 1, 2, or 3

        Troubleshooting Tips:

        Test different timer IDs (0-3) if the first attempt fails
        Ensure no other libraries/features are using the same timer (e.g., PWM, other sensors)
        Verify your M5 device's firmware is up-to-date via UIFlow2

        https://chat.m5stack.com/

        H 1 Reply Last reply Reply Quote 0
        • H
          HybridZach @yuyun2000
          last edited by

          @yuyun2000

          Traceback (most recent call last):
            File "<stdin>", line 25, in <module>
            File "<stdin>", line 16, in setup
          TypeError: unexpected keyword argument 'timer_id'
          
          V 1 Reply Last reply Reply Quote 0
          • V
            Vortrax @HybridZach
            last edited by

            @HybridZach

            New M5Stack user here..I encountered the same problem with a CoreS3 and getting the same "invalid timer number" error messages when trying to configure the IR Unit. The S3 was reflashed to UIFlow 2.3.3, but this did not resolve the problem.

            yuyun2000's helpful suggestion didn't work either as timer_id does not appear to be in the constructor for the IRUnit. Is this a more fundamental software problem?

            The IR Unit with UIFlow2 is completely unusable at the moment

            1 Reply Last reply Reply Quote 0
            • First post
              Last post