• I2C1.setup({scl:NodeMCU.D5, sda:NodeMCU.D4});
    var lcd = require("HD44780").connectI2C(I2C1);
    lcd.print("Hello World!");
    lcd.setCursor(0,1);
    lcd.print("ESP8266!");
    
    
    /*                       I2C1  SPI1
    NodeMCU.D1   D5   GPIO5
    NodeMCU.D2   D4   GPIO4
    NodeMCU.D3   D0   GPIO0                 FLASHBTN / Built in LED
    NodeMCU.D4   D2   GPIO2   SDA           Debug Serial - RX1 on FTDI chip
    NodeMCU.D5   D14  GPIO14  SCL  CLK          
    NodeMCU.D6   D12  GPIO12       MISO
    NodeMCU.D7   D13  GPIO13       MOSI         
    NodeMCU.D8   D15  GPIO15       CS
    NodeMCU.D9   D3   GPIO3
    NodeMCU.D10  D1   GPIO1
    NodeMCU.A0   D0   GPIOx
    */
    
    //1011101111110000 101010000 10001111
    /* Apple white remote 33 bits - spaces added
    10111011111100001 0101 000010001111 up
    10111011111100001 1001 000010001111 left
    10111011111100001 1010 000010001111 play
    10111011111100001 0110 000010001111 right
    10111011111100001 0011 000010001111 down
    10111011111100001 1100 000010001111 menu
    longer codes - last 1's are button repeats
    */
    
    var button={5:'up',9:'left',10:'play',6:'rig­ht',3:'down',12:'menu'};
    
    require("IRReceiver").connect(NodeMCU.D1­, function(code) {
      console.log(code);
      if ( code.length >= 33 ) {
        var l=parseInt(code.slice(1,16),2);
        if ( l === 15344 ) {
            lcd.setCursor(0,1);
          var k=parseInt(code.slice(17,21),2);
          console.log({k:k,b:button[k]});
          lcd.clear();
          lcd.print(button[k]);
        }
      }
    });
    
    10111011111100001100100001000111111
    { "k": 9,
      "b": "left"
     }
    10111011111100001010100001000111111
    { "k": 5,
      "b": "up"
     }
    101110111111000010011000010001111
    { "k": 3,
      "b": "down"
     }
    101110111111000011010000010001111
    { "k": 10,
      "b": "play"
     }
    101110111111000010110000010001111
    { "k": 6,
      "b": "right"
     }
    10111011111100001110000001000111111
    { "k": 12,
      "b": "menu"
     }
    
  • This would work with any Espruino - just need to change the pins.

  • Nice - thanks! Is this an old Apple remote? I assumed the Apple TV remotes were radio rather than infra-red.

  • It is the white remote that came with a gen one Apple TV. I'll take a picture and upload tomorrow.


    1 Attachment

    • image.jpeg
  • Nice! Which IR sensor are you using?

  • http://www.jaycar.co.nz/Active-Component­s/Optoelectronics/Optocouplers/IR-LED-Re­ceiver/p/ZD1953

    IR LED Receiver

    CAT.NO: ZD1953
    TSOP4136 IR ReceiverConsists of PIN diode, pre-amplifier, AGC, pass filter, and demodulator. The main benefits are high speed data rates, short burst ...

    It's the 36 rather than 38, but that was 3x the price and it seems to work fine!

  • Edit : Ignore, different pin choices seem to have sorted receive

    Digging up an old thread, but it seems most relevant. I was messing with IR receiver on Puck with no issues, then decided to apply same on NodeMCU ESP8266, with same detection code as used on Puck and the array just fills with false positives, no signal anywhere near. I wondered if you'd encountered anything like this on NodeMCU @Wilberforce? You may not remember I understand.

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

ESP8266 - 16x2 LCD, IR receiver with Apple Remote

Posted by Avatar for Wilberforce @Wilberforce

Actions