Page 1 of 1

Problem with multiple IR-emitters (only the first one works)

Posted: 09 Jan 2022, 20:07
by mrjulius
Dear community,

Here's a brain teaser:

I have multiple IR emitters (IR-leds) added to Devices-section, named as "IRTX1" and "IRTX2".

PROBLEM
All IR commands are sent through IRTX1, even if I specifically try to send them via IRTX2. In other words, I'm unable to send any commands through IRTX2.

I've tried both HTTP and MQTT, with the same results. More specifically:
1) MQTT:
Address: ESP1/IRTX2/cmd
Message: "IRSEND,SONY,28B97,20"
2) HTTP:
http://192.168.100.51/control?cmd=IRSEND,SONY,28B97,20

Both methods succesfully send command through IRTX1, but not through IRTX2. Hardware is ESP8266.

QUESTION
Is there a way to send a command via IRTX2 ?

Any pointers would be greatly appreciated.

-Julius

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 09 Jan 2022, 20:44
by Ath
You can prefix any command with the name of the task, and a period as a separator, so in your case that would be "irtx1.irsend,....." and "irtx2.irsend,.....".
The taskname can also be wrapped in square brackets, to improve readability, like "[irtx1].irsend,...." and "[irtx2].irsend,...." (fill the rest of the command on the dots ;))

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 10 Jan 2022, 18:38
by mrjulius
Thank you Ath for your quick answer!
I tried adding IRTX2 as the prefix as you suggested, on both the HTTP and MQTT methods, but it still always sends via IRTX1, and the IRTX2 led doesn't send anything.

Specifically:

1) MQTT:
Address: ESP1/IRTX2/cmd
Message: "IRTX2.IRSEND,NEC,FFE817,32"

2) HTTP:
http://192.168.100.51/control?cmd=IRTX2 ... ,FFE817,32

Electrically the first IR-led is on D7 and the second on D6.

I also tried a couple of other things:
- Erased flash. Flashed the latest ESP_Easy_mega_20211224_minimal_IRext_ESP8266_4M1M.bin. Reconfigured. Didn't help.
- Disabled IRTX1: Still no reaction from IRTX2
- Eliminated the possibility of electric problems (in GPIO, LEDs and wiring) by:
A) Swapping IR LEDs: Still IRTX1 drives the swapped led as expected, but IRTX2 does nothing
B) Swapping IRTX1 to D6 and IRTX2 to D7 from device settings: First no effect, but after boot, the situation reversed as expected (only the second led fires, but the first never)

Anything else I could try?

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 10 Jan 2022, 20:08
by Ath
Ah, this plugin P035 has the same issue as many other plugins: It is explicitly single-instance, as it defines 1 global object to control the IR led.
This has already be fixed for all I2C plugins, allowing multiple instances, since I2C multiplexers are now supported, to enable multiple I2C devices with a fixed address on a single ESP unit.

I've opened an issue on the github issue tracker, #3906 to get that fixed.

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 10 Jan 2022, 20:39
by mrjulius
Nice. Thank you!

Just gotta add - the project you guys have created is absolutely astounding. Thank you for everything.

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 10 Jan 2022, 21:00
by Ath
You're welcome :D

Are you also using the IR receiver (P016) plugin? As that has exactly the same issue, no multi instance possible, that can get the same treatment (in a separate issue & PR).

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 10 Jan 2022, 21:50
by mrjulius
Indeed, I am using the IR Receiver module with TSOP4838, but just one per module - so I'm maybe not the best person to say :)

I don't even realize how much work it is to modify one driver into the new structure, and all pro bono.

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 10 Jan 2022, 22:06
by Ath
mrjulius wrote: 10 Jan 2022, 21:50 Indeed, I am using the IR Receiver module with TSOP4838, but just one per module - so I'm maybe not the best person to say :)
Question is more: Would it be feasible to even have multiple IR receivers in use on a single unit?
mrjulius wrote: 10 Jan 2022, 21:50 I don't even realize how much work it is to modify one driver into the new structure, and all pro bono.
You've got to have a hobby, right? :lol:
It is quite satisfying, just improving code, and in the process, helping others getting their projects up and running ;)

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 11 Jan 2022, 10:18
by mrjulius
I suppose someone might have multiple receivers, for instance
- covering of multiple angles or adjacent rooms
- covering different carrier frequencies (with non-38kHz receivers)

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 11 Jan 2022, 12:35
by TD-er
Multiple receivers I can understand, but multiple transmitters?
Only if more than one device may react and you only want to address a single one.

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 11 Jan 2022, 13:40
by mrjulius
You're right. I'm actually controlling multiple identical TOSLink-matrixes, so they have to be commanded individually (using a blinding tape over the emitters).

Furthermore, I use those IR emitters that are mounted to the IR screen of each device (tv, amp, decoder, projector, etc). They look neat and are more reliable than blasting the signal from distance. If the devices have different protocols, you could drive multiple emitters via one transistor, but still it's more convenient to connect each emitter to their individual GPIO pins, eliminating the need for the transistor and also making it easier to debug.

Another workaround could be to drive the ir emitters through a transistor, but grounding each emitter's cathode to GPIO pins. That would allow a crude way of selecting the emitter.

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 11 Jan 2022, 14:47
by TD-er
You can also feed the IR signal into some AND port.
Then you can select which one should be used via other GPIO pins.
Or use the very old 4066 IC as an analog switch.

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 11 Jan 2022, 16:34
by mrjulius
If I'm the only one using per-device emitters, then it's probably not worth anyone else's effort to update the P035 driver, so I won't ask you that :)

And by examining https://github.com/letscontrolit/ESPEas ... 5_IRTX.ino, It's not obvious to me how to make it support multiple instances, so perhaps a workaround is my best option here.

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 11 Jan 2022, 16:40
by TD-er
I don't know what Ton already has done.
Yesterday we talked about it on Signal, and knowing Ton he might already be looking into it.
First we have to check if the library can be used in multiple instances or not. For example if the library uses static variables to keep some internal state, then it cannot be done without changing the library.

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 11 Jan 2022, 20:53
by Ath
I've looked at the IR library used, and while it does have a couple of static variables, they are only in crucial places for the 'IRrecv' part, the receiver. For the sender the only static members are methods and some data arrays used for AC control.

So I expect it to be doable, and not too hard, to improve P035 IRsend to multi-instance.

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 12 Jan 2022, 16:41
by mrjulius
Thank you for the effort. That's good news.

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 12 Jan 2022, 21:34
by Ath
I've just created PR #3911 enabling multi-instance use of the IR Transmit plugin (P035).

As the Github actions run failed (.bin size issue) here is an ESP8266 4M1M ERext build for testing:
ESP_Easy_mega_20220112_minimal_IRext_ESP8266_4M1M.zip
(568.88 KiB) Downloaded 148 times
as well as an ESP32 IRext build:
ESP_Easy_mega_20220112_custom_IR_ESP32_4M316k.zip
(1.93 MiB) Downloaded 154 times

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 13 Jan 2022, 10:31
by mrjulius
Wow. Worked right out of the bat, tested it with both HTTP and MQTT requests.

No need for extra electronics, tricks or workarounds.

Thank you!

Now how do I buy you a beer?

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 13 Jan 2022, 11:20
by Ath
mrjulius wrote: 13 Jan 2022, 10:31 Wow. Worked right out of the bat, tested it with both HTTP and MQTT requests.

No need for extra electronics, tricks or workarounds.

Thank you!
That's great.
I expect you only validated on ESP8266, right?
mrjulius wrote: 13 Jan 2022, 10:31 Now how do I buy you a beer?
:lol: You can come over to NL, if you like, and covid-19 permitting :mrgreen:
And of course you're welcome to make a donation to the project, TD-er has a "Sponsor ESPEasy" link in his profile, redirecting to this thread

Re: Problem with multiple IR-emitters (only the first one works)

Posted: 13 Jan 2022, 19:26
by mrjulius
You're right. I only validated with ESP8266EX.

Bedankt for the invitation, it's been a couple of years since I've enjoyed a fresh bottle of Amstel.

As there's no obvious one-shot options, I'll consider registering to Patreon. This is a project worth supporting.