-
I too couldnt get much range from the IR on the puck
In the end I decided not to use the puck for IR and went with an esp8266 wifi chip and external ir's, i get a few metres range with this
https://create.arduino.cc/projecthub/BuddyC/wifi-ir-blaster-af6bcaYou could perhaps try the same approach as the link and use a transistor and external ir leds with the puck
-
@Gordon on the irdb website once you pick your device there are tabs for Pronto Hex, Hex and Raw codes (which you probably saw) but for some reason not all codes on the site have raw times, my LG tv luckily had the raw times but for a sony TV they were blank so I had to calculate them from the pronto codes.
There seems to be a few Arduino libraries which can send pronto hex codes, perhaps these could be converted for Espruino.
-
Thanks for the video, i will check it out later :)
My next issue is the limited range of the IR led. I'm getting approx 50cm range with the on-board IR led any way of boosting this?
I can get about 2m with an external IR led (taken from a tv remote) which is better but I need it closer to 4m. I was going to try a transistor unless you have any better suggestions? -
This something I have done recently, check out the thread
http://forum.espruino.com/conversations/297428/#comment13372893The code below should get you started, you need to set the raw timings in the times array, this is the time in milliseconds the IR led will pulse on and off for. The timings can be worked out from the hex codes or try this website to find your device http://irdb.tk/
Also if you want to convert hex to raw times this thread helped me http://www.remotecentral.com/cgi-bin/mboard/everything_else/thread.cgi?325
Also note that the in built IR doesn't have much range, maybe 50cm at most.
var times = []; // on button press setWatch(function(e) { Puck.IR(times); }, BTN, { repeat: true, edge: 'rising', debounce: 50 });
-
I can confirm the new firmware fixes the issue :)
The puck can now replay the IR pulses perfectly
Code below if anyone is interested
pinMode(D1,"input_pullup"); var times = []; var currentWatch; function startWatching() { currentWatch = 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 = []; } }, D1, {repeat:true}); } startWatching(); function stopWatching() { clearWatch(currentWatch); currentWatch = null; } setWatch(function(e) { stopWatching(); Puck.IR(times); console.log(times); startWatching(); }, BTN, { repeat: true, edge: 'rising', debounce: 50 });
Thanks for your help.
-
+1 for Tasker - I did something similar with the amazon dash buttons
http://daniel-stone.uk/2016/09/27/amazon-dash-with-tasker.htmlYou'd have to work out how to get the puck to post some sort of notification to your phone, or maybe Tasker can listen for bluetooth messages..
-
Thanks for the replies.
After my initial post I tried something similar to what @allObjects is suggesting:
pinMode(D1,"input_pullup"); var rawtimes = []; var calculatedTimes = []; function onPulseOn(e) { rawtimes.push(getTime()); } function onPulseOff(e) { rawtimes.push(getTime()); } setWatch(onPulseOff, D1, { repeat:true, edge:"rising" }); setWatch(onPulseOn, D1, { repeat:true, edge:"falling" }); setWatch(function(e) { // if we have timings if (rawtimes.length > 0) { calculatedTimes = []; var lasttime = 0; rawtimes.forEach(function(rawTime) { if(lasttime != 0) { var newTime = 1000 * (rawTime - lasttime); calculatedTimes.push(parseFloat(newTime.toFixed(3))); } lasttime = rawTime; }); } //send to IR Puck.IR(calculatedTimes); console.log(calculatedTimes); calculatedTimes = []; }, BTN, { repeat: true, edge: 'rising', debounce: 50 });
This gets me close to what I'm expecting but still does not perform the function when replayed via the puck ir. I believe the tolerance for IR signals is +-10% which some of my recorded times fall out of.
Here's the a snippet my new recorded times:
[ 8.972, 4.547, 0.61, 0.763, 0.61, 0.763, 0.579, 1.19, 0.61, ...Correct working times are:
[ 9.024 ,4.512 ,0.564 ,0.564 ,0.564 ,0.564 ,0.564 ,1.692, 0.564, ...So the pattern seems to be there. I wonder if it's due to the reading at 32kHz?
I'll try @allObjects code out tonight see if I get any closer.
Also @Gordon is it correct that with the code below e.time and e.lastTime are rounded to 3 decimal places or is this a bug/limitation?
setWatch(function(e) { var pulseLen = (e.time - e.lastTime);
I look forward to your video on this :)
-
I'm trying to get the IR timings from a Remote and play them back using Puck.IR
I got the correct times from a website and they work using Puck.IR but I cannot get the correct timings using times recorded from a connected IR Receiver, I have a few different IR receivers and they all give more or less the same result - firmware was 1.89 and also tested with the new beta 1.89.35
I've been using the examples given on the site, 1 issue i've noticed is when using this snippet
pinMode(D1,"input_pullup"); var times =[]; var currentWatch; function startWatching() { currentWatch = setWatch(function(e) { var pulseLen = (e.time - e.lastTime); if (pulseLen < 1000) { times.push(pulseLen); } else { times = []; } }, D1, {repeat:true}); } startWatching(); function stopWatching() { clearWatch(currentWatch); currentWatch = null; }
The times given back are to max 3 decimal places e.g. [ 0.009, 0.004, 0.001, 0, 0.001, 0.001, 0, 0.002, 0, ... Is this expected behavior from e.time and e.lastTime? It's not really accurate enough for this.
I set up my own timers using the onPulseOn and OnPulseOff examples (https://www.espruino.com/Infrared+Remote+Control) and get better accuracy, however these still do not work when played back and are quite a bit different to the ones i got off the website
Website times (ms): 9.024 ,4.512 ,0.564 ,0.564 ,0.564 ,0.564 ,0.564 ,1.692 ,0.564
Puck recorded times (ms): 8.9993, 4.57763671875, 0.9765625, 1.06811523437, 0.94604492187, 1.0986328125, 0.91552734375, 1.12915039062, 0.91552734375
Any help would be appreciated
I did this so long ago i can't remember what i did, sorry not very helpful i know.
Looking through my emails i did purchase these IR Led's from ebay so maybe worth a try
https://www.ebay.co.uk/itm/SFH485-SFH-485-880nM-40-degree-IR-LEDs-Qty-5-NEW-Osram-parts/112424821596