IR RC - Infrared Remote Control

Posted on
  • Many of the lighting devices -multi color 'bulbs', strips, modules, neopixel xyz, etc. - are infrared remote controlled and come with flimsy, cheap remote. The remotes have quite a number of buttons, for example, 20 buttons in 4 columns and 5 rows. The remote control has a CR2025 3V button cell battery. The receiving side consists of an integrated IR receiver circuitry in a TO-92 style package w/ three (3) leads (as you also see in the conversation about Reusing some RGB LED interior lighting modules).

    Since there was no use anymore for the IR RC parts, I gave it a shot to figure out what the remote control transmits and whether it could be useful to use it as a (remote) control or input device for an Espruino application.


    1 Attachment

    • IR_RC_RemotControl.jpg
  • The approach is to put a "both" edge watch on the IR receiver and cap(ture)() the times of raises and falls. Electrically - schema wise - the device has to run 5V - it did show no signals when powered by 3.3V. The IR receiver data pin - 1, left from front - is on Espruino(-Wifi) pin B0, center pin - 2 - is on 0V / Ground, and pin 3 - right from front - is on 5V (USB Bat/In on Espruino(-Wifi). The paper behind the IR receiver is just there to give it better visibility/contrast in the picture. I used the Espruino-Wifi just because it was just the most handy... ;-)

    In the decode() I first just listed the times in the console - line 28 - from which it was difficult to detect patterns, because all these floats 'floated/flooded my eyes' and made it just a blur. Next step was to calculate and value adjust the interval between the signal changes lines 23..25: still a blur in regard of patterns, but at least I could see some repeated interval values... To 'see' the prevailing interval values s, I sorted the intervals by value ascending, which showed the prevailing values as listed in lines 30..39.

    For the final pattern visualization, I used the average of two adjacent long intervals to to separate and map the interval values to characters and showed latter as a single string for each button... and that's what you see in the console output.

    Once in a while, the start sequence was not very clean - as said: cheap and flimsy is the 'keyboard' of the RC. I noticed that id did not really matter how long the button is pressed: after getting finally getting started with the transmission, it finishes always the same way (...*040-, mostly, once ...*140), and after that, it is just a repetition of a 'hold' pattern (-090-090-...). Pressing the buttons very briefly emitted a very different signals for one and the same button (R(ow)=0, C(ol)=1). Repetition of all the 20 RC buttons showed also differences based on how well each of them made contact in the RC.

    The test sequence was pressing a button on the RC, then BTN (BTN1) on the Espruino-Wifi. To make it really usable, some more code is needed to watch for a sequence and then jump into the decoding... subject of a future post. And = may be .- the repurposing of the 8-legged atTiny85 style mcs w/ code (reverse-engineering / decompiling?) - that were removed from the lighting modules as well - for offloading Espruino from doing this IR RC receiver side of business.

    // infraReceiverTest.js
    // (c)20181002 allObjects
    // B0 on Espruino-Wifi
    
    var t=[];
    function cap(e){t.push(e.time);}
    
    var infraWid;
    
    function w() { // watch
      infraWid = setWatch(cap, B0
        , {repeat:true,edge:"both",debounce:0});
    }
    
    function uw() { // unwatch
      if (infraWid) infraWid = clearWatch(infraWid);
    }
    
    var s, c=-1, r=-1;
    function decode() {
      var l = t.length - 1;
      if (l<2) { t = []; return; }
      t.forEach(function(e,i){ if (i<l)
        t[i] = Math.floor((t[i+1] - e) * 100000)/1000;
      });
      t.pop();
      // t.sort();
      // t.forEach(function(e){ console.log(e); });
    var dummy=` (for legibility in the forum color schema)
    
       --- Prevailing Interval Values (* 100) ----:
                  many .054, few .055
       <0.056: 0
                  many .057, few .058, .059
       <0.115: 1
                  many .169, few .170
       <0.197: *
                  many .225
       <0.569: -
                  4, 9
       >     : Math.floor()
     `;
      s="";
      t.forEach(function(e,i){
        s +=
          (e<0.056)?"0"
         :(e<0.115)?"1"
         :(e<0.197)?"*"
         :(e<0.569)?"-"
         :          ""+Math.floor(e)
         ; });
      c++; if (c % 4 === 0) { r++; c = 0; }
      console.log(r,c,":",s);
      t = [];
    }
    
    function onInit() {
      pinMode(B0,"input_pulldown");
      w();
      setWatch(decode, BTN1
        , {repeat:true, edge:"falling", debounce:100});
      console.log("R C : Data pattern...");
    }
    
    setTimeout(onInit,100);
    

    Console output (first block w/ some spaces removed and truncated for legibility in the forum):

    `
             |_| espruino.com
     2v00 (c) 2018 G.Williams
    >
    RC: Data pattern... (RowCol 00 is top left button on remote control)
    00: 0-11111111111111111*1*1*1*111*1*1*111111­11110101010*0*0*0*0*0*0*0*040-090-
    01: 0-11011111111111010*1*1*1*111*1*1*1*010*­0101010101010*010*0*0*0*0*040-090-
    02: 0-11111111111111111*1*1*1*111*1*1*111*11­11110101010*010*0*0*1*0*0*040-090-
    03: 0-11111111111111101*1*1*1*111*1*1*1*1*11­111111010101010*0*0*0*0*0*040-090-
    10: 0-11111111111111111*1*1*1*111*1*1*11111*­11110101010*0*010*0*0*0*0*040-090-
    11: 0-11111111111111101*1*1*1*111*1*1*1*111*­1111110101010*010*0*0*0*0*040-090-
    12: 0-11111111101111111*1*1*1*111*1*1*111*1*­11110101010*01010*0*0*0*0*040-090-
    13: 0-11111111111110111*1*1*1*111*1*1*1*1*1*­11110101010101010*0*0*0*0*040-090-
    20: 0-11111111111111111*1*1*1*111*1*1*111111­1*110101010*0*0*010*0*0*0*040-090-
    21: 0-11111111111111111*1*1*1*111*1*1*1*1111­1*01010101010*0*010*0*0*0*040-090-
    22: 0-11111111111111111*1*1*1*111*1*1*111*11­1*010101010*010*010*0*0*0*040-090-
    23: 0-11111111111111111*1*1*1*111*1*1*1*1*11­1*0101010101010*010*0*0*0*040-090-
    30: 0-11111111111111111*1*1*1*111*1*1*11111*­1*010101010*0*01010*0*0*0*040-090-
    31: 0-11111111111111111*1*1*1*111*1*1*1*111*­1*01010101010*01010*0*0*0*040-090-
    32: 0-11111111111111111*1*1*1*111*1*1*111*1*­1*110101010*0101010*0*0*0*040-090-
    33: 0-11111111111111111*1*1*1*111*1*1*1*1*1*­1*01010101010101010*0*0*0*040-090-
    40: 0-11111111111111111*1*1*1*111*1*1*111111­110*0101010*0*0*0*010*0*0*040-090-
    41: 0-11111111111110111*1*1*1*111*1*1*1*1111­110*010101010*0*1*010*0*0*040-090-
    42: 0-11111111111111111*1*1*1*111*1*1*111*11­010*1101010*010*0*010*0*0*040-090-
    43: 0-11111111111111101*1*1*1*111*1*1*1*1*11­110*01010101010*0*010*0*0*040-090-
    50: 0-11111111111111111*1*1*1*111*1*1*11111*­110*0101010*1*010*011*0*0*040-090-
    51: 0-11111111111111111*1*1*1*111*1*1*1*111*­110*110101010*010*011*0*0*040-090-
    52: 0-11111111111110111*1*1*1*111*1*1*111*1*­110*0101111*11010*010*1*1*040-090-
    53: 0-11111111111111111*1*1*1*111*1*1*1*1*1*­111*0111111111011*010*1*0*140-190-
    
    ----- once in a while not a regular start:
    0 1 : 710-11111111111111111*1*1*1*111*1*1*1*11­111111110101010*0*0*0*0*0*0*040-090-090-­090-0
    
    ----- sitting 'for ever' on a button:
    0 1 : 0-11111111111110111*1*1*1*111*1*1*1*1111­1111111101010*0*1*0*0*0*0*040-090-090-09­0-090-190-090-090-090-090-090-090-090-09­0-090-090-090-090-090-190-090-090-02568
    
    ----- pressing only 'very briefly' multiple times the same button (with decent pauses):
    0 1 : 0-011040-11111111111101010*1*1*1*001*1*1­*1*01101111111011110*0*1*1*1*1*1*140-0
    0 1 : 0-11001101010110101*1*1*0*101*1*0*1*0101­1011111100111*1*0*1*1*1*1*140-0
    0 1 : 0-11011011011111110*1*1*1*101*1*1*1*0111­1111111101010*1*1*1*1*1*1*140-0
    0 1 : 0-11110010101101010*1*1*1*010*1*0*0*1111­1111110101111*1*1*1*1*1*1*140-090-0
    0 1 : 0-10111011110111010*1*1*1*110*1*0*1*0101­1111111011111*1*1*1*1*1*1*140-090-0
    0 1 : 0-11111011110110110*1*1*1*110*1*0*0*1101­0111110101010*1*1*1*1*1*1*140-0
    `
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

IR RC - Infrared Remote Control

Posted by Avatar for allObjects @allObjects

Actions