Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can J5 handle reading IR raw data from remote control devices? #1580

Closed
communque opened this issue May 28, 2019 · 3 comments
Closed

Can J5 handle reading IR raw data from remote control devices? #1580

communque opened this issue May 28, 2019 · 3 comments

Comments

@communque
Copy link

communque commented May 28, 2019

Trying to capture codes from IR signals from remote control units for a VCR, TV, etc.
New to this. Trying to learn what's possible.

Currently testing with the following:
- ESP8266
- IR sensor powered by 3.3VDC from ESP, output connected to ESP's analog input (also testing digital)
- Code:

	var J5 = require("johnny-five");
	var {EtherPortClient}=require("etherport-client");
	var thisBoard, thisSensor, thisTime, priorTime, thisIp;
	thisIp="ip.address.of.ESP";
	
	thisBoard=new J5.Board({
		port: new EtherPortClient({
			host: thisIp,
			port: 3030
		}),
		repl: false
	});

	thisBoard.on("ready", function(){
		thisSensor=new J5.Sensor({
			pin:"A0"
		});
		priorTime=new Date().getTime();
		thisSensor.on("change", function(){
			thisTime=new Date().getTime();
			console.log(thisTime-priorTime, this.value);
			priorTime=thisTime;
		});
	});

The approach I'm using seems to be incapable of accurately capturing the signals. The thisSensor.on("change" etc. does register that the remotes are transmitting, but not the raw data. Is it that J5, being JS operates at max speed of 1 ms? while the IR signals are coded at µs? Or the setup / coding approach, etc?

A few of the J5 git pages here, here, and here begin to address the issue, but I haven't nailed it yet.

Thanks for any advice & insight

@communque
Copy link
Author

Following up...

Using the code below in the hopes of following the IR sensor on a tighter schedule.
The results are inconsistent,
Each click of a button the remote control device triggers a response, but...
1 - Clicking the same button repeatedly gives different responses each time
2 - Clicking different buttons doesn't give identifiably different responses.
(Perhaps the data stream rate, which I presume is 1ms and ??can't be reduced to nano- or even µsecs??)

Example results (Cleaned up)

Button Press# Analog Dur µSec
TV Power Button 1 1024 18.84
TV Power Button 1 8  
       
TV Power Button 2 1024 23.50
TV Power Button 2 6 93.52
TV Power Button 2 1024 18.16
TV Power Button 2 7  
       
TV Power Button 3 1024 17.41
TV Power Button 3 8  
       
TV Power Button 6 1024 23.51
TV Power Button 6 7  
       
TV Power Button 7 1024 15.37
TV Power Button 7 7 170.82
TV Power Button 7 1024 20.36
TV Power Button 7 9  
       
TV Power Button 8 1024 16.88
TV Power Button 8 7  

Code used to capture the data...

var Fs = require("fs");
var Cp = require("child_process");
var J5 = require("johnny-five");
var {EtherPortClient}=require("etherport-client");
var thisBoard, thisIp;
thisIp="ip.address.of.ESP";

thisBoard=new J5.Board({
	port: new EtherPortClient({
		host: thisIp,
		port: 3030
	}),
	repl: false
});

thisBoard.on("ready", function(){
	var thisSensor, thisTime, thisValue;
	thisSensor=new J5.Sensor({
		emitter: 13,
		pin: "A0",
		freq: 1
	  });
	thisSensor.on("data", function() {
		console.log(new Date().getTime(), this.value);
	});
});

@dtex
Copy link
Collaborator

dtex commented May 31, 2019

I recommend checking out this issue: #434

A "receiver" class that support IR is definitely on our wish list.

@dtex
Copy link
Collaborator

dtex commented Aug 14, 2019

This issue has been added to the wishlist.

@dtex dtex closed this as completed Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants