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

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mrjulius
Normal user
Posts: 10
Joined: 09 Jan 2022, 19:42

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

#1 Post by mrjulius » 09 Jan 2022, 20:07

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

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

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

#2 Post by Ath » 09 Jan 2022, 20:44

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 ;))
/Ton (PayPal.me)

mrjulius
Normal user
Posts: 10
Joined: 09 Jan 2022, 19:42

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

#3 Post by mrjulius » 10 Jan 2022, 18:38

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?

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

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

#4 Post by Ath » 10 Jan 2022, 20:08

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.
/Ton (PayPal.me)

mrjulius
Normal user
Posts: 10
Joined: 09 Jan 2022, 19:42

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

#5 Post by mrjulius » 10 Jan 2022, 20:39

Nice. Thank you!

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

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

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

#6 Post by Ath » 10 Jan 2022, 21:00

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).
/Ton (PayPal.me)

mrjulius
Normal user
Posts: 10
Joined: 09 Jan 2022, 19:42

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

#7 Post by mrjulius » 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 :)

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

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

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

#8 Post by Ath » 10 Jan 2022, 22:06

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 ;)
/Ton (PayPal.me)

mrjulius
Normal user
Posts: 10
Joined: 09 Jan 2022, 19:42

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

#9 Post by mrjulius » 11 Jan 2022, 10:18

I suppose someone might have multiple receivers, for instance
- covering of multiple angles or adjacent rooms
- covering different carrier frequencies (with non-38kHz receivers)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

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

#10 Post by TD-er » 11 Jan 2022, 12:35

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.

mrjulius
Normal user
Posts: 10
Joined: 09 Jan 2022, 19:42

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

#11 Post by mrjulius » 11 Jan 2022, 13:40

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.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

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

#12 Post by TD-er » 11 Jan 2022, 14:47

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.

mrjulius
Normal user
Posts: 10
Joined: 09 Jan 2022, 19:42

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

#13 Post by mrjulius » 11 Jan 2022, 16:34

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.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

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

#14 Post by TD-er » 11 Jan 2022, 16:40

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.

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

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

#15 Post by Ath » 11 Jan 2022, 20:53

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.
/Ton (PayPal.me)

mrjulius
Normal user
Posts: 10
Joined: 09 Jan 2022, 19:42

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

#16 Post by mrjulius » 12 Jan 2022, 16:41

Thank you for the effort. That's good news.

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

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

#17 Post by Ath » 12 Jan 2022, 21:34

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 153 times
/Ton (PayPal.me)

mrjulius
Normal user
Posts: 10
Joined: 09 Jan 2022, 19:42

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

#18 Post by mrjulius » 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!

Now how do I buy you a beer?

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

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

#19 Post by Ath » 13 Jan 2022, 11:20

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
/Ton (PayPal.me)

mrjulius
Normal user
Posts: 10
Joined: 09 Jan 2022, 19:42

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

#20 Post by mrjulius » 13 Jan 2022, 19:26

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests