Sending Infrared signal to TV - not working

Posted on
  • I have a TSOP31236 connected to a NodeMCU:

    • Ground to NodeMCU Gnd pin
    • VCC to NodeMCU 3.3V pin
    • Data to NodeMCU D1 pin

    I am using the following code to record IR codes from the remote from my TV:

    // https://www.espruino.com/Pico+Infrared
    
    pinMode(NodeMCU.D1,"input_pullup");
    // Keep somewhere to put the signal times
    var times = [];
    
    // now watch the input
    setWatch(function(e) {
      // work out how long the pulse was, in milliseconds
      var pulseLen = 1000 * (e.time - e.lastTime);
      // then save it, if it was less than 1 second
      if (pulseLen < 1000)
        times.push(pulseLen);
      else
        times = [];
    }, NodeMCU.D1, {repeat:true});
    

    I press the Standbye-key on the remote and when I type console.log(times) I see the contents of the times-array:

    [ 2.69600000001, 0.853, 0.48300000003, 0.84700000002, 0.47899999992, 0.40800000010, 0.47899999992, 0.40800000010, 1.36699999995, 1.29399999991, 0.48100000003, 0.406, 0.48100000003, 0.406, 0.48200000003, 0.405, 0.48199999991, 0.40500000011, 0.48300000003, 0.40499999988, 0.48200000003, 0.40499999988, 0.48300000003, 0.40400000011, 0.48299999991, 0.40400000011, 0.48299999991, 0.404, 0.48399999991, 0.404, 0.48300000003, 0.40400000011, 0.92199999983, 0.41000000010, 0.48800000001, 0.84199999992, 0.48400000002, 0.404, 0.48400000002, 83.35299999998, 2.703, 0.84700000002, 0.51, 0.82, 0.48499999991, 0.402, 0.48599999990, 0.40100000012, 1.37300000005, 1.28699999993, 0.48799999990, 0.4, 0.48800000001, 0.39900000001, 0.48800000001, 0.39899999990, 0.47800000004, 0.40900000010, 0.48899999990, 0.39900000001, 0.48800000001, 0.39900000001, 0.48900000001, 0.39799999990, 0.47900000004, 0.40800000010, 0.47899999992, 0.408, 0.48, 0.408, 0.47900000004, 0.40799999987, 0.92900000004, 0.403, 0.48400000002, 0.84700000002, 0.47900000004, 0.40699999988, 0.48 ]
    

    So, the receiving part seems to work.

    Now from this page I found that you can send the times-array to an IR transmitter led. I have connected an IR led to pin NodeMCU.D2 and NodeMCU ground and use the following command to submit the times-array to my TV:

    pinMode(NodeMCU.D2, "output")
    digitalPulse(LED1,1,times);
    

    Nothing seems to happen, at least the TV doesn't switch off or on. When I exchange the IR led with a normal led I see that there are pulses sent out. Any idea what could be wrong or does anyone have working code with Espruino on an ESP8266?

  • check this page too , it also explains how round the grabbed values.

  • Also on the page @MaBe mentions is :

    http://www.espruino.com/pronto

    http://irdb.tk contains a list of common remote control codes for different devices.

    So you can look up your tv, get the code and try using the pronto library...

  • Thank you for your suggestions @MaBe and @Wilberforce.

    First I tried to fix the pulse times from the receiver to 1 decimal, but that didn't work.

    Next I wanted went the Pronto-way. I found codes for my TV, but run into a problem with the Pronto module:

    >var p=require("pronto")
    WARNING: Module "pronto" not found
    =undefined
    > 
    

    I found the pronto module on the Espruino site and took the function to decode the hex-string and used it to send to to my TV with digitalPulse... To no avail.

    Has anyone ever got this to work with a NodeMCU?

  • The IR page you linked also mentions a whole bunch of other stuff you need - specifically analogWrite on the other pin the IR LED is connected to.

    There are a few posts on the ESP8266 forum about this already, but basically the code given won't work on ESP8266 because there's no way of getting a 40kHz square wave at the same time as executing digitalPulse.

    The solutions for you would be to:

    • Use a proper Espruino device.
    • Set up a 555 timer to give you a 40kHz signal as well.
    • Build a new array that contained a series of 40kHz pulses, instead of your current ~1-2ms pulses - see the attached image from eevblog


    1 Attachment

    • demodulation.jpg
  • Thank you @Gordon!

    Hmmm, maybe this way is over my head then...

    I have an Espruino, so I might try to go that way first but the idea was to build this into an iTead S20 smartswitch so I think that the other options (555 timer or an array with 40khz pulses) would better suit me.

    Any pointers on how to generate such an array or do you have a link to the page where you found the above image @Gordon?

    Much appreciated!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Sending Infrared signal to TV - not working

Posted by Avatar for CrashingDutchman @CrashingDutchman

Actions