logo elektroda
logo elektroda
X
logo elektroda

LED strip control with D1 Wemos + IR TSOP1736 by Domoticz

maystero 7278 43
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 17568296
    maystero
    Level 24  
    Hello

    I want to use the D1 Wemos module to control an LED strip.
    The functions are to be as follows:
    - On/OFF
    - brightness adjustment (e.g. from 1% to 100%)
    D1 module connected to Domoticz.

    In addition, I want to connect an IR receiver (e.g. TSOP1736) to the GPIO of e.g. D3
    so that I can perform the same functions with the TV remote control.

    Is this feasible?
    I have looked in the options of ESP Easy for PWM support, but have not found it.
    Also, is ESP Easy able to handle the IR commands of the remote control?
  • ADVERTISEMENT
  • #2 17568460
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • Helpful post
    #3 17568706
    Slawek K.
    Level 35  
    ESP Easy can be controlled by PWM. You do this by calling up the URL as follows :

    http://<espeasyip>/control?cmd=PWM,13,500

    Where 13 is the GPIO pin number and 500 is the PWM fill value between 0-1023.

    You can also specify short pulses :
    http://<espeasyip>/control?cmd=Pulse,14,1,500 - one pulse lasting 500ms on GPIO 14

    Of course, beforehand you have to set the pins accordingly in the ESP Easy configuration (as output). You can also control HIGH/LOW states or servos.
    More can be found here :
    https://www.letscontrolit.com/wiki/index.php/GPIO

    As far as IR handling is concerned, there is such a possibility - TSOP4838. You can assign specific rules to the port it is connected to.
    Log into ESP Easy, go to the Tools tab, select Advanced and put a tick next to Rules. You will then see an additional tab called Rules, where you can define local rules.

    Example (from the web) : Switch Input named Button.

    
    on PrzyciskOn do
    gpio 12,1
    gpio 13,0
    inputswitchstate 0,1
    endon
    
    on PrzyciskOff do
    gpio 12,0
    gpio 13,1
    inputswitchstate 0,0
    endon
    
    on Przycisk#switch do
    if [Przycisk#switch]=1
    event PrzyciskOn
    else
    event PrzyciskOff
    endif
    endon
    .

    And again to read the literature https://www.letscontrolit.com/wiki/index.php/Tutorial_Rules

    Greetings
  • #4 17568970
    maystero
    Level 24  
    Super. Thanks for the tips.
    Of course, I guessed that you would have to use the Rules option to operate the IR remote. Just wondering... If I use the 4 buttons on the remote.
    1. ON
    2. OFF
    3. LOWER
    4. DARKER

    Then how do you capture the RC commands and how do you "place" them in the RULES?
  • Helpful post
    #5 17569924
    Slawek K.
    Level 35  
    I'll take a look in my spare time and try to help you out.

    Best regards
  • #6 17570596
    maystero
    Level 24  
    I have started PWM control
    Code: C / C++
    Log in, to see the code
    .
    Admittedly Domoticz does not support this type of control, but the idea itself works.

    The question of IR control remains.
  • #7 17621047
    maystero
    Level 24  
    rs6000 wrote:
    I will take a look in my spare time and try to help you.

    Greetings
    .

    Any luck?

    I have the device prepared for testing as shown in the diagram....
    LED strip control with D1 Wemos + IR TSOP1736 by Domoticz
  • #8 17623041
    maystero
    Level 24  
    I found this description on googling:
    https://www.letscontrolit.com/wiki/index.php/IR
    Unfortunately there is no IR Input option on my ESP Easy Mega.
    Why?

    OK
    I found it!
    You need to upload a BIN with IR support. E.g.
    Code: C / C++
    Log in, to see the code
    .

    Hym....
    only I don't know why there is no support for the command in this version:
    Code: C / C++
    Log in, to see the code
    .

    gets a return:
    Code: C / C++
    Log in, to see the code
    .
  • Helpful post
    #9 17623618
    Slawek K.
    Level 35  
    There is a bug, reported on github, I had the same problem, upload mega from 2018.12.04, in later versions there is this bug.

    Greetings
  • ADVERTISEMENT
  • #10 17624195
    maystero
    Level 24  
    Actually the download to an older version restored the functionality of the ESP.
    I was able to get the TSOP4838 working.
    The circuit works because when I send the RC5 remote control signal:

    Code: Bash
    Log in, to see the code
    .

    So I wrote RULES

    Code: Bash
    Log in, to see the code


    So that it switches the state on GPIO 12.
    But something is not working. I don't know if a badly written rule or if ESP is reading RC5 wrong.
  • #11 17624215
    Slawek K.
    Level 35  
    You have endon unnecessarily, but try it like this :
    Code: C / C++
    Log in, to see the code
    .
  • #12 17625429
    maystero
    Level 24  
    Super! Thanks. Works :) .

    I have extended this script,
    so that the 4 GPIO outputs can be controlled from the IR remote control

    Code: Bash
    Log in, to see the code
    .
    Only the script does not work as I would like;

    Because when I press key 1 it activates GPIO 14.
    And when I press key 2 it activates GPIO 12 but deactivates 14

    Code: Bash
    Log in, to see the code
    .
  • #13 17625870
    Slawek K.
    Level 35  
    Put all IF instructions in one ON event. Right now I'm typing from my phone so I'm uncomfortable, if anything, I can't help until the evening, but rest assured you can do it. It works as you wrote, else causes a switch off when the button is not the right one. Inside the IF you need to place another IF that checks the state of the GPIO and changes it to the opposite.


    Greetings
  • #15 17627371
    Slawek K.
    Level 35  
    I understand that you want the state of the pin to change to the opposite when the remote control button is pressed, yes ?

    Greetings
  • #16 17627382
    maystero
    Level 24  
    rs6000 wrote:
    I understand that you want the state of the pin to change to the opposite when the remote control button is pressed, yes ?

    Greetings
    .

    Yes,
    i.e. I press "key_1" GPIO,14 changes to the opposite state. GPIO 12, 16, 13 unchanged.
    I press "key_2" GPIO,12 changes to the opposite state and GPIO 14, 16, 13 unchanged.
    Same with the other keys 3 and 4.

    I suppose it is impossible to do this using IF.
  • #17 17627401
    Slawek K.
    Level 35  
    Add Dummy Device :

    LED strip control with D1 Wemos + IR TSOP1736 by Domoticz .

    This will be the variable into which we will store the state of the button. The instruction will look like this :

    Code: C / C++
    Log in, to see the code
    .

    For each pin you will need to add a Dummy device (variable, otherwise named), correct the task number and add this to the other IF instructions.

    Greetings
  • #18 17627563
    maystero
    Level 24  
    This is what my "variables" look like

    LED strip control with D1 Wemos + IR TSOP1736 by Domoticz


    script:
    Code: Bash
    Log in, to see the code
    .

    I slimmed down to two keys to make it easier to test.

    The script works as in the examples above....



    EDIT:

    I noticed that I made a typo:

    Code: Bash
    Log in, to see the code
    .
    and it should be
    Code: Bash
    Log in, to see the code

    but no effect
  • #19 17627656
    Slawek K.
    Level 35  
    Square brackets, not curly brackets.
  • #20 17627696
    maystero
    Level 24  
    I made typos....
    I corrected the script
    Code: Bash
    Log in, to see the code


    now it works like this:
    I press key 1, it changes GPIO 14 to the opposite (to 1)
    I press key 2, it changes GPIO 14 to the opposite (to 0)
    press key 2 (again), changes GPIO 12 to the opposite (to 1)
    press key 1, it changes GPIO 12 to the opposite (to 0)
  • #21 17627718
    Slawek K.
    Level 35  
    Where do you check the pin states ? In the log ? Check physically e.g. with a pin meter.

    Best regards
  • ADVERTISEMENT
  • #22 17627720
    maystero
    Level 24  
    rs6000 wrote:
    Where do you check the pin states ? In the log ? Check physically e.g. with a pin meter.


    Greetings
    .

    I have LEDs connected to GPIO 14 and 12. The whole thing is watching how the LEDs behave
  • #23 17627920
    Slawek K.
    Level 35  
    Since there are problems with this firmware mega, upload R147 http://www.letscontrolit.com/downloads/ESPEasy_R147_RC8.zip , it is in device TSOP4838. And let's check on this version., at me it works best in the drivers, and I have a dozen of them at home. I think I have this diode somewhere in the house so I will try to test it, but only in the evening.

    Greetings
  • #24 17628108
    maystero
    Level 24  
    rs6000 wrote:
    Since there are problems with this firmware mega, upload R147 http://www.letscontrolit.com/downloads/ESPEasy_R147_RC8.zip , it is in device TSOP4838. And let's check on this version., at me it works best in the drivers, and I have a dozen of them at home. I think I have this diode somewhere in the house so I will try to test it, but only in the evening.

    Greetings
    .

    I have uploaded the R147 version.
    After initial configuration I see that the TSOP does not work as expected:

    Code: Bash
    Log in, to see the code
    .

    I press the same key on the RC remote control. Specifically it is the "1" key (rc5 philips)
    In the Log I get some random values of IR_RECEIVER#IR

    If I don't come up with anything I'll go back to ESP_Easy_mega-20181204_normal_IR_ESP8266_4096.bin

    EDIT:

    I messed around and got this version of the R147 version working.
    I added the Dummy Device
    I took another RC remote (this time from LG - it works better than from Philipis)

    I tweaked the script again:
    Code: Bash
    Log in, to see the code
    .

    The result, it works as I described above. I.e..
    I press key 1, it changes GPIO 14 to the opposite (to 1)
    I press key 2, it changes GPIO 14 to the opposite (to 0)
    I press key 2 (again), it changes GPIO 12 to the opposite (to 1)
    press key 1, it changes GPIO 12 to the opposite (to 0)
  • #25 17629372
    Slawek K.
    Level 35  
    So how about this, in the controller located in the light switch box I have this configuration on R147 :

    LED strip control with D1 Wemos + IR TSOP1736 by Domoticz .

    LED strip control with D1 Wemos + IR TSOP1736 by Domoticz .

    BUTTON is the button I use to switch the light on/off - in your case it's the button key, and LIGHT is the relay pin. When the state is changed (0 or 1) i.e. the BUTTON#Switch event is called, the state of the LIGHT#Switch pin which turns the relay on/off is checked and the state is changed to the opposite.

    The rules look like this :

    Code: C / C++
    Log in, to see the code
    .

    The toggle event is called remotely by Domoticz as follows : http://192.168.1.xxx/control?cmd=event,toggle and does exactly the same as the event "on BUTTON#Switch do", and everything works perfectly, I have it in all the rooms, I have changed the switches to pulse (staircase) switches and it works in parallel when the button is pressed or through the switch in Domoticz, and always changes the state to the opposite, no matter which option I use.

    So try this method, instead of Dummy Device add Input Switch j.w for each pin you want to control.

    Greetings
  • #26 17629653
    maystero
    Level 24  
    Current status:

    I press the "1" key on the RC remote control:
    LED strip control with D1 Wemos + IR TSOP1736 by Domoticz .

    I press the "2" key on the RC remote control:
    LED strip control with D1 Wemos + IR TSOP1736 by Domoticz

    It is better because
    I press key "1" GPIO 14 = 1
    I press key "2" GPIO 14 = 0 and GPIO 12 = 1

    I don't understand why the function of key "1" affects key "2" ?


    Code: Bash
    Log in, to see the code
    .

    edit:
    struggle and fight

    noticed that:
    Code: Bash
    Log in, to see the code
    .

    when I have only a rule for one GPIO and I send IR=2017267209 it changes the state to 1, but sending IR=2017267209 again does not change the state to the opposite. The LED does not go off.
    It only goes off when I press another button on the remote....
    what is wrong with this syntax?
  • #27 17630232
    Slawek K.
    Level 35  
    You are missing the endif closing condition. Check like this :

    Code: C / C++
    Log in, to see the code
    .
  • #28 17630482
    maystero
    Level 24  
    Hello

    Late at night, I also noticed it was missing:
    Code: Bash
    Log in, to see the code
    .

    I have added it to the RULES:
    Code: Bash
    Log in, to see the code
    .

    It works as I described in the post above.
    Quote:
    It only goes off when I press another button on the remote....


    And LOG
    Code: Bash
    Log in, to see the code


    You can see that it didn't change the state to the opposite....
    as if it did not change the Switch_1 value

    Added after 12 [hours] 30 [minutes]:

    I don't know what's going on anymore myself.
    I have assembled a second circuit.
    I am using a TSOP1736 for testing.
    The ESP in the DEVICES list has a TSOP4838.
    Could this be influencing this strange behaviour of the circuit?
  • #29 17851986
    maystero
    Level 24  
    Hello

    I would like to get back on topic as I have not been able to solve the problem.
    I have purchased a TSOP4838.
    I found some time
    I connected to the ESP, according to the schematic:
    LED strip control with D1 Wemos + IR TSOP1736 by Domoticz .

    I connect the power via USB, no signal falls on the IR receiver. And in the LOG

    Code: C / C++
    Log in, to see the code
    [/code].

    There is an awful lot of this interference! Full of "random" waveforms (EVENT: IR_RECEIVER).
    I don't know what I'm doing wrong and where the error lies.
    Anyone who knows, anyone who has seen please help.
  • Helpful post
    #30 17852042
    khoam
    Level 42  
    Maybe connect the power supply to the TSOP as DS recommends to start with:

    LED strip control with D1 Wemos + IR TSOP1736 by Domoticz .

Topic summary

The discussion addresses controlling an LED strip using a D1 Wemos module integrated with Domoticz, focusing on on/off switching and brightness adjustment via PWM. The user aims to add IR remote control functionality using a TSOP1736 or TSOP4838 IR receiver connected to GPIO pins (e.g., D3). ESP Easy firmware is used for device control, with PWM commands issued through HTTP URLs. PWM control is confirmed feasible via ESP Easy, but Domoticz lacks native PWM support. IR command handling requires enabling the Rules feature in ESP Easy and uploading a firmware version with IR support (e.g., ESP_Easy_mega-20181208_normal_IR_ESP8266_4096.bin or R147). Users report issues with IR decoding, firmware bugs, and syntax errors in Rules scripts, such as missing spaces after IF statements and incorrect bracket usage. Solutions include using Dummy Devices to store toggle states, consolidating IF conditions within a single ON event, and ensuring proper wiring and power supply to the TSOP IR receiver, including adding a 4.7µF capacitor for stability. The IR remote codes are captured as events, and Rules scripts toggle GPIO outputs accordingly. Firmware version compatibility is critical, with older versions sometimes more stable for IR functions. PWM commands follow the syntax http:///control?cmd=PWM,,,,, with fill values from 0 to 1023; a fill of 0 immediately turns off LEDs without smooth dimming. Firmware updates (e.g., ESP_Easy_mega-20190903_normal_core_241_ESP8266_4M1M.bin) resolve some PWM issues. The discussion includes practical examples of Rules scripting for IR command handling and PWM control, emphasizing careful syntax and device configuration.
Summary generated by the language model.
ADVERTISEMENT