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

    Need IR reader and writer with almost any controller

    General
    4
    17
    2.4k
    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.
    • konacurrentsK
      konacurrents @holofloh
      last edited by

      @holofloh Using the latest iPhone I cannot see anything on the camera when pressing an IR transmitter. So I don't see that feature.

      I still don't know what RC-5 is in the M5 Stack of capabilities. All I have are M5 controllers.

      @robski said in Need IR reader and writer with almost any controller:

      M5 IR module

      Can you provide the IR Model? I'm using the Infrared Reflective Sensor (https://shop.m5stack.com/products/infrared-reflective-sensor-unit).

      The sample code is one of
      From device
      or
      IR Reflective via GROVE

      So any examples that work would be helpful. Every time I run them they never detect anything.

      thanks,

      robskiR 1 Reply Last reply Reply Quote 0
      • robskiR
        robski @konacurrents
        last edited by

        @konacurrents said in Need IR reader and writer with almost any controller:

        I'm using the Infrared Reflective Sensor (https://shop.m5stack.com/products/infrared-reflective-sensor-unit).

        You won't detect any logic (coded) IR signals from TV or audio remote controllers with this unit
        ie It is to detect "brake" of IR signal when object travels on production line etc

        for play with audio/tv remote controllers which are sending coded signals for each button press you need something like this:
        IR Emitter/Reciver

        M5StickC, M5StickCPlus, M5StickCplus2,M5GO, M5Core, M5Tough, M5Core2, M5 Demo Board, M5Dial, M5Paper, M5Atom, M5Cardputer, M5StampS3, CoreMP135, StamPLC, AirQ

        konacurrentsK 1 Reply Last reply Reply Quote 0
        • konacurrentsK
          konacurrents @robski
          last edited by

          @robski thanks, I'll order that part and hope it solves my challenge.

          konacurrentsK 1 Reply Last reply Reply Quote 0
          • konacurrentsK
            konacurrents @konacurrents
            last edited by

            @konacurrents thanks, I've ordered that part and hope it solves my challenge. (I thought I had all the IR and RF controls, but that one slipped through.)

            I assume the code will let me receive the code from buttons on a TV remote control, which I could then send from the M5 device later.

            Thanks,

            konacurrentsK 1 Reply Last reply Reply Quote 0
            • konacurrentsK
              konacurrents @konacurrents
              last edited by

              @konacurrents I also just found this IR library that I'll look at:
              https://github.com/crankyoldgit/IRremoteESP8266

              konacurrentsK 1 Reply Last reply Reply Quote 0
              • konacurrentsK
                konacurrents @konacurrents
                last edited by

                @konacurrents I have the IR Remote sensor, and I can now receive IR signals.

                Cannot send IR
                But I cannot send any IR signals (just repeating what was received). This is the volume on 3 or my remotes. I'm using the M5Atom button (which is Button B) to make do the IRSend command.

                I found the IRremote and IRSender objects. I'm also using the Port B of my I2S using pins 33 and 32.

                I'm trying to send what was printed from receiving the IR:

                Send with: IrSender.sendSamsung(0x7, 0x7, <numberOfRepeats>);
                

                By calling:

                    IrSender.sendSamsung(0x7, 0x7, 1);
                

                Any ideas?

                My sample program is below:

                /******************************************************************************
                  Please connect to Port B,Use IR Unit to receive and test infrared receiving
                  and transmitting 请连接端口B,使用红外单元接收和测试红外接收和发射.
                */
                #include <Arduino.h>
                //#include <M5Core2.h>
                #include <M5StickCPlus.h>
                #include <IRremote.hpp>
                #include <IRSend.hpp>
                
                
                // I2S (middle port on Atom's port extender I2s driver)
                int ir_recv_pin = 33;  // set the input pin.  设置引脚
                int ir_send_pin = 32;
                
                #define DELAY_AFTER_SEND 2000
                #define DELAY_AFTER_LOOP 500
                
                //!see https://forum.arduino.cc/t/irremote-sending-samsung-code-but-not-working/1312154
                
                #define IR_RECEIVE_PIN ir_recv_pin
                #define IR_SEND_PIN    ir_send_pin
                
                void setup() {
                  Serial.begin(115200);
                  Serial.println();
                
                  M5.begin();
                
                  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
                  delay(DELAY_AFTER_LOOP);
                  IrSender.begin(IR_SEND_PIN);
                
                  Serial.print(F("Ready to receive IR signals of protocols: "));
                  printActiveIRProtocols(&Serial);
                  //Serial.println(F("at pin " STR(IR_RECEIVE_PIN));
                }
                
                void loop() {
                  
                  //Serial.println("loop");
                  M5.update();  // Read the press state of the key.  读取按键 A, B, C 的状态
                  if (M5.BtnA.wasReleased())
                  { 
                    // If the button A is pressed.  如果按键 A 被按下
                    Serial.println("A");
                  }
                  else if (M5.BtnB.wasReleased())
                  { 
                    // If the button B is pressed. 如果按键
                    // B 被按下,
                    Serial.println("B");
                
                    //! seems to be the main button.. B
                    //! lets send the volume UP
                    //Protocol=Samsung Address=0x7 Command=0x7 Repeat gap=46750us Raw-Data=0xF8070707 32 bits LSB first
                    Serial.println("IrSender.sendSamsung(0x7, 0x7, 1)");
                    IrSender.sendSamsung(0x7, 0x7, 1);
                
                    IrReceiver.restartAfterSend(); // Is a NOP if sending does not require a timer.
                
                    delay(DELAY_AFTER_SEND);
                
                  }
                  else if (M5.BtnB.wasReleasefor(700))
                  {
                    // The button B is pressed for 700ms. 按键 B 按下
                    // 700ms,屏幕清空
                
                    Serial.println("b 700");
                  }
                
                  /*
                     Check if received data is available and if yes, try to decode it.
                     Decoded result is in the IrReceiver.decodedIRData structure.
                
                     E.g. command is in IrReceiver.decodedIRData.command
                     address is in command is in IrReceiver.decodedIRData.address
                     and up to 32 bit raw data in IrReceiver.decodedIRData.decodedRawData
                  */
                  if (IrReceiver.decode()) {
                
                    /*
                       Print a summary of received data
                    */
                    if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
                      Serial.println(F("Received noise or an unknown (or not yet enabled) protocol"));
                      // We have an unknown protocol here, print extended info
                      IrReceiver.printIRResultRawFormatted(&Serial, true);
                
                      IrReceiver.resume(); // Do it here, to preserve raw data for printing with printIRResultRawFormatted()
                    } else {
                      IrReceiver.resume(); // Early enable receiving of the next IR frame
                
                      IrReceiver.printIRResultShort(&Serial);
                      IrReceiver.printIRSendUsage(&Serial);
                    }
                    Serial.println();
                  }
                  delay(DELAY_AFTER_LOOP);
                }
                
                felmueF 1 Reply Last reply Reply Quote 0
                • felmueF
                  felmue @konacurrents
                  last edited by

                  Hello @konacurrents

                  by Atom's port extender do you mean M5AtomABC? If yes, the middle port is using GPIO33 and GPIO23 (not GPIO32) - see here.

                  Thanks
                  Felix

                  GPIO translation table M5Stack / M5Core2
                  Information about various M5Stack products.
                  Code examples

                  konacurrentsK 1 Reply Last reply Reply Quote 0
                  • konacurrentsK
                    konacurrents @felmue
                    last edited by konacurrents

                    @felmue Wow, I'll be. I can get this to send now. Pin 23 was the key.
                    I thought I tried that. But then I looked at the image and it showed 32 (but now I realized I read it backward:-)

                    actually worse: I misread that the numbers instead of right to left, I used top/bottom or bottom/top (the 33 threw my pattern off) - and I had seen the GPIO link you sent.

                    So I'm on my way. Thanks so much.

                    Is there a process on how to repeat these calls to the various remote messages?

                    eg. I'm testing and it's sendNEC vs sendSamsung. How would a universal remote know this just from scanning (learning)?

                    IMG_2363.png

                    felmueF 1 Reply Last reply Reply Quote 0
                    • felmueF
                      felmue @konacurrents
                      last edited by

                      Hello @konacurrents

                      yes, that silk screen can be a bit misleading.

                      There is function IrReceiver.getProtocolString() which gives you the protocol (e.g. NEC, Samsun, etc.) to use when sending a learned code. Have you tried that?

                      Thanks
                      Felix

                      GPIO translation table M5Stack / M5Core2
                      Information about various M5Stack products.
                      Code examples

                      konacurrentsK 1 Reply Last reply Reply Quote 0
                      • konacurrentsK
                        konacurrents @felmue
                        last edited by konacurrents

                        @felmue It looks like I need the binary version of getProtocolString. It seems the following is needed for sending an IRData (the mirror of what was learned from receiving.)

                        /**
                         * Interprets and sends a IRData structure.
                         * @param aIRSendData The values of protocol, address, command and repeat flag are taken for sending.
                         * @param aNumberOfRepeats Number of repeats to send after the initial data if data is no repeat.
                         * @return 1 if data sent, 0 if no data sent (i.e. for BANG_OLUFSEN, which is currently not supported here)
                         */
                        size_t IRsend::write(IRData *aIRSendData, int_fast8_t aNumberOfRepeats) 
                        

                        And I need a way to get the IrReceiver to provide the IRData information. So It seems this is in the decodedIRData from the IrReceiver.decode call.

                        /** 
                         * Main class for receiving IR signals
                         */ 
                        class IRrecv {
                        public:
                            IRData decodedIRData;       // Decoded IR data for the application
                        }
                        

                        I assume I save these values with the associated functions (volume up, change channel, etc). I see that a lot of those functions are defined for various known operations, but for now I will learn from the IR receiver.

                        Thanks for the help.

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