View: 9814|Reply: 5

OrangePiOne LIRC over GPIO

[Copy link]

2

threads

4

posts

86

credits

Registered member

Rank: 2

credits
86
Published in 2016-7-30 05:43:01 | Show all floors |Read mode
Anyone did that? Generally Arbian works great for my purposes (vivarium controller), wifi, gpio, hw RTC timer, etc, work like a charm(after little search). I have spare IR receiver and I would like more use it. I tried to change the pin in scripts.bin on PD14 (hw 12). But it did not work(i would be too easy). I was following few threads on this forum(for example http://www.orangepi.org/orangepi ... &extra=page%3D5). but nothiong make the trick. Should i know something more? There is RPi(lirc_rpi, option gpio_in_pin=x) module for gpio use but i cant find one for H3.

10

threads

218

posts

2040

credits

Gold member

Rank: 6Rank: 6

credits
2040
Published in 2016-7-30 07:34:56 | Show all floors
Edited by nopnop2002 at 2016-7-30 08:24

There is How to use IR with gpio.(without LIRC)

http://feijoa.jp/laboratory/raspberrypi/infrared/

This is a Japanese page, but I think you can probably understand.
If you use Google Chrome, it's translated into your national word.

I tried my OPI-ONE.(OPI-ONE doesn't have IR receiver)

It's work fine my OPI-ONE.
TV power on/off.
TV channel change.
TV volume up/down.

I have only a remote control of the NEC format.
It may not work by the other formats.

If you don't understand Japanese of this page, please ask an author or me using very very easy English.




2

threads

4

posts

86

credits

Registered member

Rank: 2

credits
86
 Author| Published in 2016-7-30 08:23:52 | Show all floors
I found this link earlier, and the program runs in my setup. Saves some data. But as far as i understand it makes only copy of IR signal, not interpret it. And I need OPi to be controlled from IR pilot. Not to controll tv.

10

threads

218

posts

2040

credits

Gold member

Rank: 6Rank: 6

credits
2040
Published in 2016-7-30 08:32:29 | Show all floors
Edited by nopnop2002 at 2016-7-30 08:58
Mritke replied at 2016-7-30 08:23
I found this link earlier, and the program runs in my setup. Saves some data. But as far as i unders ...

I tried the following shell.
It couldn't be compared correctly.

#!/bin/bash
sudo ./scanir tmp.ir
files="./*.ir"
for filepath in $files; do
  echo $filepath
  cmp tmp.ir $filepath
done

How is lirc comparing the IR pattern?

10

threads

218

posts

2040

credits

Gold member

Rank: 6Rank: 6

credits
2040
Published in 2016-8-2 21:51:01 | Show all floors
Edited by nopnop2002 at 2016-8-3 21:19
Mritke replied at 2016-7-30 08:23
I found this link earlier, and the program runs in my setup. Saves some data. But as far as i unders ...

I could control using external IR receiver by combining with ATtiny.
My RPI-ONE (This have No IR) can control using a remote control.

1. A sketch is written in ATtiny85.
The sketch is as follows.
ATtiny85 sends a received infrared code using UART.
This can distinguish only the NEC format.
Original is here.
http://www.technoblogy.com/show?V6F
  1. /* ATtiny85 IR Remote Control Receiver

  2.     David Johnson-Davies - www.technoblogy.com - 3rd April 2015
  3.     ATtiny85 @ 1 MHz (internal oscillator; BOD disabled)
  4.    
  5.     CC BY 4.0
  6.     Licensed under a Creative Commons Attribution 4.0 International license:
  7.     http://creativecommons.org/licenses/by/4.0/

  8.     http://www.technoblogy.com/show?V6F
  9.    
  10. */
  11. #include <SoftwareSerial.h>

  12. #define rxPin 0    // PB0
  13. #define txPin 1    // PB1

  14. SoftwareSerial mySerial(rxPin, txPin); // RX, TX

  15. volatile int NextBit;
  16. volatile unsigned long RecdData;

  17. // Demo routine
  18. void ReceivedCode(boolean Repeat) {
  19. //  char buff[64];
  20. //  sprintf(buff,"%d,%x",Repeat,RecdData);
  21. //  mySerial.println(buff);
  22.   mySerial.print(Repeat);
  23.   mySerial.print(",");
  24.   mySerial.println(RecdData,HEX);
  25. }


  26. // Interrupt service routine - called on every falling edge of PB2
  27. ISR(INT0_vect) {
  28.   int Time = TCNT0;
  29.   int Overflow = TIFR & 1<<TOV0;
  30.   // Keep looking for AGC pulse and gap
  31.   if (NextBit == 32) {
  32.     if ((Time >= 194) && (Time <= 228) && (Overflow == 0)) {
  33.       RecdData = 0; NextBit = 0;
  34.     } else if ((Time >= 159) && (Time <= 193) && (Overflow == 0)) ReceivedCode(1);
  35.   // Data bit
  36.   } else {
  37.     if ((Time > 44) || (Overflow != 0)) NextBit = 32; // Invalid - restart
  38.     else {
  39.       if (Time > 26) RecdData = RecdData | ((unsigned long) 1<<NextBit);
  40.       if (NextBit == 31) ReceivedCode(0);
  41.       NextBit++;
  42.     }
  43.   }
  44.   TCNT0 = 0;                  // Clear counter
  45.   TIFR = TIFR | 1<<TOV0;      // Clear overflow
  46.   GIFR = GIFR | 1<<INTF0;     // Clear INT0 flag
  47. }

  48. // Setup **********************************************

  49. void setup() {
  50.   // Set up Timer/Counter0 (assumes 1MHz clock)
  51.   TCCR0A = 0;                 // No compare matches
  52.   TCCR0B = 3<<CS00;           // Prescaler /64
  53.   // Set up INT0 interrupt on PB2
  54.   MCUCR = MCUCR | 2<<ISC00;   // Interrupt on falling edge
  55.   GIMSK = GIMSK | 1<<INT0;    // Enable INT0
  56.   NextBit = 32;               // Wait for AGC start pulse

  57.   mySerial.begin(4800);
  58.   mySerial.println("IR demo start");
  59. }

  60. void loop()
Copy code

2.Wiring ATtiny85 and RPI-ONE.
A wiring diagram is this.
It don't have a part image of OPI, so I substituted a part image of RPI.
If someone have a part image of OPI, please share.
http://nopnop2002.webcrow.jp/OrangePiONE/OrangePiOne-2.html

**ATtiny operate 5V.
**So you need level shift.
**When ATtiny operate 3.3V,It can't receive IR.

3.Download sirw and sirexec.
Source code of sirw is this.
http://nopnop2002.webcrow.jp/OrangePiONE/ir/sirw.c

Source code of sirexec is this.
http://nopnop2002.webcrow.jp/OrangePiONE/ir/sirexec.c

$cc -o sirw sirw.c -lwiringPi
$cc -o sirexec sirexec.c -lwiringPi

4. Execute sirw.
$sudo ./sirw

When you push any remote,sirw indicates a remote control code.
When you'd like to use ttyS2 or ttyS3:
$sudo ./sirw /dev/ttyS2
$sudo ./sirw /dev/ttyS3

5. You take notes of an IR code.
The first 1 character is indicator whether repeat or not.
1,E619FF00:This is repeat code
0,E619FF00:This is not repeat code
E619FF00 is IR code.

6.Stop sirw.
Create config file in $HOME.
Everything is good for the file name.

Example:
#ok
EA15FF00,uname -a
#menu
BC43FF00,ls /boot

When receive EA15FF00,[uname -a] is executed.
When receive EA15FF00,[ls /boot] is executed.

7. Execute sirexec.
$sudo ./sirexec /dev/ttyS1 $HOME/config debug
When you'd like to use ttyS2 or ttyS3:
$sudo ./sirexec /dev/ttyS2 $HOME/config debug
$sudo ./sirexec /dev/ttyS3 $HOME/config debug

When you push remote, sirexec execute a command.
**Last argument "debug" is for test.
**When including in your /etc/rc.local, please remove the last argument "debug".













7

threads

38

posts

181

credits

Registered member

Rank: 2

credits
181
Published in 2018-2-18 23:40:38 | Show all floors
I have not been able to use LIRC on Orange/Armbian. It failed on many levels. The whole story is explained here:
https://forum.armbian.com/topic/ ... s-on-orangepi-zero/

The problem varies with the exact version of distribution you use. I am using µUbuntu 5.35 with kernel 4; and IR is now handled via the cir overlay; the cir driver has gone away.

My solution is explained here, for reception and emission:
http://www.orangepi.org/orangepi ... amp;extra=#pid22197
the whole work is done in bash and C; emission is done by my C code on PA6. I don't need any external chip; I can wire the IR receiver and emission diode directly on my opi0; my method does not require Atmel or anything like this. My solution is specific to my use case (I have hardcoded the 400us timing everywhere), but this can be tuned by editing the sources.

If you read about "lirc_rpi" driver on rpi forums, just run away; this is Raspbian specific.
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list