Vuk Vasić
Vuk Vasić

Reputation: 1418

PI4j Raspberry Pi Infrared receiver

I have connected a Infrared receiver to Rasberry Pi like this: enter image description here

And i have tried the example from URL: http://pi4j.com/example/listener.html to get information from the GPIO 18 but it outputs nothing into terminal.

Is there any way i can get info from infrared receiver in Java with Pi4j.

I know that the Python script exists but i want to learn if there is possibility to read sensors data from Java.

UPDATE 1:

GPIO port 18 is port 1 in Pi4j now i get the output with states LOW HIGH how can i now decode the signal so i can use it for transmitter.

Upvotes: 1

Views: 2378

Answers (2)

Perumal Ramasamy
Perumal Ramasamy

Reputation: 495

Try using jlirc. It uses lirc package on linux. Install lirc package on your raspberry pi and have it running.

Upvotes: 0

joanlofe
joanlofe

Reputation: 3637

If you are able to read HIGH and LOW from the sensor, to decode the signal you need to time the lapses between those states, to be able to recognize different signals. Of course, that can be done in Java, for instance using System.nanoTime() for precise timing.

There is a good tutorial on how to do this in Adafruit, in particular read from this section on. It is not in Java (it is for Arduino), but the idea can be easily adapted to use Pi4J.

Upvotes: 1

Related Questions