Need IR reader and writer with almost any controller
-
I've been trying to get the various IR programs to work, and have not been successful. I have almost every controller (M5StickCPlus, M5Atom, M5Core2) and even IR Reflective sensor.
I just want a simple program that will read the IR from a TV remote control, and let the program sent that same IR to the TV (a universal remote).
I also don't know what it means in the code examples:
now, you can see the infrared light through mobile phone camera
Anyway, getting this to work would be great for my disabled users.
ps. I'm using Arduino C++ code.
thanks,
scott -
"now, you can see the infrared light through mobile phone camera" - this is just simple way to tell if your controller or remote is sending anything out (IR diode flashes on transmission)
few devices have IR transmitter build in so by adding IR reciever you are almost there...you can read...save and send TV IR codes
-
Most IR Remote use RC-5 coding. See https://en.wikipedia.org/wiki/RC-5
Often the IR LED is pulsed with high current on very low duty to increase the working distance (refer the datasheet of your IR LED for maximal pulse ratings). If you have a "normal" IR LED on a GPIO it might be less effective. In this case you have to try very close to the receiver. -
@holofloh Thanks for the reply. I'm not using RC-5 with my ESP32 M5 controllers.
I'm using the IR for the M5.
So any examples that work with that would be nice.
thanks, -
@robski I guess I haven't seen IR on my iPhone "mobile phone camera".
So I'm looking for code that works, not a couple examples that aren't working for me (eg. the IR doesn't turn the TV on).
Any production example would be nice.
thanks,
scott -
@konacurrents You wrote "I'm not using RC-5 with my ESP32 M5 controllers" and in the next posting "eg. the IR doesn't turn the TV on"
So do you want to remote control a TV or another device? If you not using RC-5 what alternative protocol does your device use?For the mentioned test by the mobile phone camera: Test if ANY working remote from TV or HiFi etc... is visible by your mobile phone camera. Point the transmitter to the camera and press a button. If you see a flashing light, then your camera is able to see the IR light.
Now do the same at the M5StickCPlus when one of the examples is running.If there is no flashing IR then investigate on the port number of the IRLED on your device and change it in the code to the right one. If it flashes but your receiving device is not reacting to it, it may be a wrong protocol or command.
It may help if you post the code you are trying and a description of what exactly you want to control.
-
what is the code that isn't working for you and what devices are you using with it? I can take M5Stick with M5 IR module connected via groove port and it works fine
-
@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 GROVESo any examples that work would be helpful. Every time I run them they never detect anything.
thanks,
-
@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 etcfor play with audio/tv remote controllers which are sending coded signals for each button press you need something like this:
IR Emitter/Reciver -
@robski thanks, I'll order that part and hope it solves my challenge.
-
@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,
-
@konacurrents I also just found this IR library that I'll look at:
https://github.com/crankyoldgit/IRremoteESP8266 -
@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
andIRSender
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); }
-
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 -
@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)?
-
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 -
@felmue It looks like I need the binary version of
getProtocolString
. It seems the following is needed for sending anIRData
(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 theIRData
information. So It seems this is in thedecodedIRData
from theIrReceiver.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.