Help on sending IR Codes

Posted on
  • Hi,

    I was trying to send IR code for my Aircondition unit. Unfortunately, none of the methods (hopefully) listed on the espruino website works for me, I was able to deduct the IR code using Arduino and found the following code.

    Hash:  FA36E9A0 For IR Scope/IrScrutinizer: 
    +4400 -4350 +550 -1600 +600 -500 +550 -1650 +550 -1600 +550 -550 +550 -550 +550 -1600 +550 -550 +550 -550 +550 -1600 +550 -550 +550 -550 +550 -1600 +550 -1600 +600 -500 +550 -1650 +550 -550 +550 -1600 +550 -1600 +600 -1600 +550 -1600 +550 -550 +550 -1600 +600 -1600 +550 -1600 +600 -500 +550 -550 +550 -550 +550 -500 +600 -1600 +550 -550 +550 -500 +600 -1600 +550 -1600 +600 -1600 +550 -550 +550 -500 +600 -500 +550 -550 +550 -550 +550 -500 +600 -500 +550 -550 +550 -1600 +600 -1600 +550 -1600 +550 -1650 +550 -1600 +550 -127976 
    
    For Arduino sketch:  unsigned int raw[100] = {4400,4350,550,1600,600,500,550,1650,550­,1600,550,550,550,550,550,1600,550,550,5­50,550,550,1600,550,550,550,550,550,1600­,550,1600,600,500,550,1650,550,550,550,1­600,550,1600,600,1600,550,1600,550,550,5­50,1600,600,1600,550,1600,600,500,550,55­0,550,550,550,500,600,1600,550,550,550,5­00,600,1600,550,1600,600,1600,550,550,55­0,500,600,500,550,550,550,550,550,500,60­0,500,550,550,550,1600,600,1600,550,1600­,550,1650,550,1600,550,};
    
     irsend.sendRaw(raw,100,38);
    

    How do I send the equivalent code from Espruino? (there is no pronto code listed on irdb.tk)

    Thanks
    Navas

  • Hi - are you doing this with a normal Espruino, or Puck.js?

    On normal Espruino it should be as easy as:

    var pulseTimes = [4400,4350,550,1600,600,500,550,1650,550­,1600,550,550,550,550,550,1600,550,550,5­50,550,550,1600,550,550,550,550,550,1600­,550,1600,600,500,550,1650,550,550,550,1­600,550,1600,600,1600,550,1600,550,550,5­50,1600,600,1600,550,1600,600,500,550,55­0,550,550,550,500,600,1600,550,550,550,5­00,600,1600,550,1600,600,1600,550,550,55­0,500,600,500,550,550,550,550,550,500,60­0,500,550,550,550,1600,600,1600,550,1600­,550,1650,550,1600,550].map(function(x) {return x/1000;});
    
    analogWrite(IR_ANODE,0.9,{freq:38000});
    digitalPulse(IR_CATHODE, 1, pulseTimes);
    digitalPulse(IR_CATHODE, 1, 0);
    digitalRead(IR_ANODE);
    

    So all I did is divide the times by 1000 to get them in milliseconds rather than microseconds.

  • Hi Gordon,

    Thanks for responding. Actually the AirCon. has a longer IR Codes, It has 199 bits. So far I only found appropriate code for OFF :(

    Is there any way I can decode longer IR signals, I am always getting memory out of error using Espruino using official decoded method (like the instructions on Youtube)

    Thanks
    Navas

  • Also, I finally figured out the code using espruino. It works with Puck.JS, but ot doesn't work on my Pico, Any ideas?

    var on = [4.41455841064,4.36687469482,0.570297241­21,1.61373615264,0.56827068328,0.5521774­2919,0.54073333740,1.62029266357,0.56457­519531,1.61266326904,0.56934356689,0.553­13110351,0.54073333740,0.55301189422,0.5­4085254669,1.61361694335,0.56552886962,0­.55694580078,0.53882598876,0.55599212646­,0.53977966308,1.61743164062,0.567436218­26,0.55408477783,0.54073333740,0.5531311­0351,0.53977966308,1.61361694335,0.56743­621826,1.61075592041,0.56934356689,0.554­08477783,0.54061412811,1.61945819854,0.5­6743621826,1.62029266357,0.56743621826,0­.55313110351,0.54073333740,1.61647796630­,0.56743621826,1.61552429199,0.566482543­94,1.61170959472,0.57029724121,1.6404390­3350,0.54156780242,1.64020061492,0.54180­622100,1.61361694335,0.56934356689,0.556­11133575,0.54061412811,1.61266326904,0.5­6838989257,0.55408477783,0.53977966308,0­.55313110351,0.54073333740,0.55325031280­,0.53966045379,0.55408477783,0.539779663­08,0.55408477783,0.53977966308,0.5550384­5214,0.53977966308,0.55599212646,0.53977­966308,1.61457061767,0.56648254394,1.613­49773406,0.56755542755,0.55408477783,0.5­3977966308,0.55408477783,0.53882598876,0­.55408477783,0.53977966308,0.55313110351­,0.53977966308,0.55599212646,0.539779663­08,1.61647796630,0.56648254394,0.5542039­8712,0.53966045379,0.55313110351,0.53966­045379,1.61373615264,0.56743621826,1.614­57061767,0.56648254394,1.61647796630,0.5­6552886962,1.64127349853,0.53977966308,1­.61647796630,0.57792663574,5.18798828125­,4.41646575927,4.36210632324,0.571250915­52,1.64031982421,0.54168701171,0.5521774­2919,0.54168701171,1.61743164062,0.56648­254394,1.61445140838,0.56755542755,0.554­08477783,0.53977966308,0.55313110351,0.5­4073333740,1.61457061767,0.56648254394,0­.55599212646,0.53977966308,0.55503845214­,0.54073333740,1.64413452148,0.540733337­40,0.55313110351,0.54061412811,0.5532503­1280,0.53977966308,1.61457061767,0.56648­254394,1.61552429199,0.56648254394,0.553­13110351,0.54073333740,1.61838531494,0.5­6838989257,1.62124633789,0.56648254394,0­.55408477783,0.53882598876,1.64508819580­,0.54073333740,1.61266326904,0.568389892­57,1.61552429199,0.56648254394,1.6126632­6904,0.56838989257,1.61361694335,0.56838­989257,1.61743164062,0.56552886962,0.556­94580078,0.54073333740,1.61552429199,0.5­6457519531,0.55408477783,0.53977966308,0­.55313110351,0.54073333740,0.55408477783­,0.53882598876,0.55408477783,0.539779663­08,0.55313110351,0.53977966308,0.5559921­2646,0.53977966308,0.55503845214,0.54073­333740,1.61552429199,0.56552886962,1.613­61694335,0.56648254394,0.55503845214,0.5­4073333740,0.55313110351,0.53977966308,0­.55408477783,0.53977966308,0.55313110351­,0.53977966308,0.55599212646,0.540733337­40,1.61457061767,0.56827068328,0.5532503­1280,0.54073333740,0.52928924560,0.56457­519531,1.61361694335,0.56743621826,1.613­61694335,0.56838989257,1.61278247833,0.5­6922435760,1.61361694335,0.56743621826,1­.61743164062,0.57792663574];
    
    var off = [4.44984436035,4.37164306640,0.573158264­16,1.61933898925,0.56934356689,0.5559921­2646,0.54168701171,1.62410736083,0.56743­621826,1.61933898925,0.56934356689,0.555­03845214,0.54168701171,0.55503845214,0.5­4168701171,1.61743164062,0.57029724121,0­.55789947509,0.54073333740,0.55789947509­,0.54073333740,1.62220001220,0.567436218­26,0.55599212646,0.54073333740,0.5550384­5214,0.54168701171,1.61743164062,0.56743­621826,1.62029266357,0.56648254394,0.555­03845214,0.54073333740,1.62410736083,0.5­6838989257,0.55694580078,0.54073333740,1­.61564350128,0.57017803192,1.62029266357­,0.56552886962,1.61838531494,0.568389892­57,1.61933898925,0.56648254394,0.5550384­5214,0.54061412811,1.62231922149,0.56743­621826,1.64699554443,0.54073333740,1.624­10736083,0.56934356689,0.55408477783,0.5­4073333740,0.55503845214,0.54073333740,0­.55503845214,0.54061412811,0.55515766143­,0.54073333740,1.61743164062,0.568389892­57,0.55503845214,0.54073333740,0.5569458­0078,0.54073333740,1.62315368652,0.56934­356689,1.61647796630,0.56838989257,1.644­13452148,0.54275989532,0.55491924285,0.5­4073333740,0.55408477783,0.54073333740,0­.55408477783,0.54073333740,0.55503845214­,0.54073333740,0.55694580078,0.540733337­40,0.55694580078,0.54061412811,0.5542039­8712,0.54168701171,0.55503845214,0.54073­333740,1.62029266357,0.56838989257,1.617­43164062,0.56838989257,1.61933898925,0.5­6648254394,1.61743164062,0.56838989257,1­.61838531494,0.58078765869,5.22613525390­,4.41932678222,4.37355041503,0.571250915­52,1.61647796630,0.56838989257,0.5559921­2646,0.54073333740,1.64794921875,0.54168­701171,1.61838531494,0.56648254394,0.555­03845214,0.54168701171,0.55503845214,0.5­3977966308,1.61933898925,0.56743621826,0­.55599212646,0.54168701171,0.55694580078­,0.54073333740,1.62208080291,0.568509101­86,0.55408477783,0.54168701171,0.5540847­7783,0.54073333740,1.61838531494,0.56743­621826,1.61743164062,0.56838989257,0.555­03845214,0.54073333740,1.64890289306,0.5­4264068603,0.55694580078,0.54073333740,1­.61743164062,0.56743621826,1.61743164062­,0.56838989257,1.61743164062,0.568389892­57,1.61933898925,0.56743621826,0.5550384­5214,0.54073333740,1.62220001220,0.56838­989257,1.61838531494,0.56934356689,1.623­15368652,0.56934356689,0.55503845214,0.5­4156780242,0.55420398712,0.54073333740,0­.55503845214,0.54168701171,0.55408477783­,0.54073333740,1.62029266357,0.566482543­94,0.55420398712,0.54156780242,0.5570650­1007,0.54061412811,1.62506103515,0.56743­621826,1.61838531494,0.56648254394,1.617­43164062,0.56934356689,0.55515766143,0.5­4061412811,0.55503845214,0.54073333740,0­.53119659423,0.56457519531,0.53024291992­,0.56457519531,0.53310394287,0.564575195­31,0.53215026855,0.56552886962,0.5550384­5214,0.53977966308,0.55503845214,0.53977­966308,1.62315368652,0.56743621826,1.619­33898925,0.56636333465,1.61743164062,0.5­6850910186,1.61743164062,0.56934356689,1­.62029266357,0.57983398437];
    
    
    function ac(cmd){
      digitalWrite(LED1,1);
      analogWrite(A5,0.9,{freq:38000});
      digitalPulse(A6, 1, cmd);
      digitalPulse(A6, 1, 0);
      digitalRead(A5);
      digitalWrite(LED1,0);
    }
    
  • It is working on the official Espruino Pico. Still trying to figure out on ESP8266.

    Thanks
    Navas

  • ESP8266 won't work I'm afraid - it can't generate the 38kHz oscillation needed at the moment with its software PWM.

    If you want to save some memory, you can do:

    var off = new Float32Array([4.44984436035,4.3716430664­0 .... ]);
    

    It'll put the data into a typed array, which will be much more memory-efficient.

  • Thanks @Gordon.

    I ended up using arduino for the IR part. It's so unfortunate that esp8266 on espruino sucks at pwm. Hope it won't be any problem on ESP32.

    Thanks
    Navas

  • Or you could use Espruino WiFi, which would work perfectly :)

  • Yup!, that's what I did for one of my AC. And for another one, I ended up using Arduino.

    My budget is tight, so I can't afford to have multiple espruino Wifi :(

    I heard there is a way to use IRQ and make it work on esp8266. Is there any work in progress?

    I miss RGB Control (not the neo pixel) and IR stuffs since it lacks PWM support. Those are the two things I use mostly.

    Thanks
    Navas

  • I heard there is a way to use IRQ and make it work on esp8266. Is there any work in progress?

    Not as far as I know. I'm trying to use the patreon page to get some funds to look into ESP8266 a bit more, so I guess at some point that might happen.

    However I think at some point WiFi takes priority over everything, so it might never be reliable.

    since it lacks PWM support

    Soft PWM does work ok. It seems to be ok-ish for ~100Hz or so, which might work for your lighting?

  • Here you go buddy.

    http://take.ms/3Gd1X

    Thanks for letting me know the patreon page.

    And for RGB, controlling individual pins with each 100Hz works? I tried with one and seems like worked with OK, but haven't tried with all 3 pins.

  • Thanks! That's great!

    Yes, 3x 100Hz should work ok - it might glitch very occasionally, but it's usable.

    The way it's implemented, 3x 100Hz has about the same load as 1x 300Hz - so it should be fine. If you need more PWM you could always try lowering the frequency.

  • ok, thanks @Gordon. I will give it a try.

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

Help on sending IR Codes

Posted by Avatar for navas @navas

Actions