1

Alright, I've managed to get LIRC to work on a Pi 3, but not on a zero w running raspbian lite.

I have the infrared codes I want to send (e.g 0x40BF or 0x8877) and I'm wondering if there's another way to send the codes to an IR led using python. I've heard of pigpio, but I'm not quite sure how to approach that.

How can I send the IR codes I have to an infrared LED using python and not using LIRC?

3 Answers 3

2

pigpio will be able to send any infrared code you know how to construct.

pigpio also provides a wrapper to capture and send well behaved codes. By well behaved I mean codes which don't change from press to press and are not a ludicrous number of bits long (some IR codes are a pretty unnecessary hundreds of bits long).

In the first instance try this IR record and playback example.

If that doesn't work an alternative to try is to record the IR code with piscope and play it back with this playback piscope recordings example.

All the above example require that the pigpio daemon is running. It may be started with the following command.

sudo pigpiod

For general documentation see http://abyz.me.uk/rpi/pigpio/index.html

5
  • I used the pigpio example you provided and I was able to successfully record codes (not sure if they were the correct codes, but it had them). When I try to transmit the codes I don't get an error but I also don't get any response. I've tested the circuit with LIRC and I've checked the pin number. Any idea what could be happening?
    – user61421
    Commented Nov 27, 2017 at 3:34
  • To record properly the same code has to be received several times, so it seems like the codes are well-behaved. The obvious thing to go wrong on the transmit side is using the wrong GPIO for output. Do you see the IR LED you are using flash (look through a phone camera).
    – joan
    Commented Nov 27, 2017 at 8:07
  • How many do you mean by several? I've now gone through the recording process for the same buttons 5 times. I've checked the LED with a camera, and it's working.
    – user61421
    Commented Nov 27, 2017 at 15:21
  • I meant that the pigpio record software needs to see the identical code several times in a row before accepting it as valid. That has already happened, otherwise the record software would have given an error. You could use piscope to compare the recorded and transmitted codes and visually check they look the same. The only other consideration is the transmit power. I think I used something like 100mA for the transmitter I built. Does it work if the Pi is really close to the receiving device?
    – joan
    Commented Nov 27, 2017 at 16:08
  • I've managed to get it working on both a pi 3 and a pi zero w. I've noticed there's a marginal delay on the zero and I was wondering if there's a way to speed it up. Is it calculating each waveform before it sends it out? Do you know of any ways I could optimize it for a pi zero?
    – user61421
    Commented Dec 17, 2017 at 18:42
2

I wrote my own (limited) version of Lirc in Python, it can send IR codes and can be controlled via TCP (just like Lirc). I use it with an Android app, to control my amplifier.

You can find the source and instructions on https://github.com/amfasis/lyrc

2
  • github.com/amfasis/lyrc is now gone. Is there a new repository for this code?
    – codechimp
    Commented Jul 26, 2020 at 14:17
  • @codechimp. I made the project private since I didn't use it anymore. Made it public again for you, but please be warned it's not perfect, feel free to look around and adjust + request merges
    – Amfasis
    Commented Jul 26, 2020 at 15:23
1

An alternative i've found for my OrangePi not supporting pigpio is this sendir.c tool based on wiringpi.

First I converted the RAW IR codes with irScrutinizer from the LIRC remotes db.

Then I was able to send some IR commands to my LG TV using it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.