Page 1 of 2

Receive and transmit IR remote codes

Posted: Thu Feb 27, 2020 10:25 am
by pythoncoder
I have released this repo which supports infra red remote controls. Protocols supported are NEC, Sony, and two Philips options. A receiver and "blaster" driver are provided. Both are nonblocking. They are not reliant on uasyncio but are compatible with it. The transmitter is Pyboard specific.

A transmitter demo implements a 2-button remote with auto-repeat.

Re: Receive and transmit IR remote codes

Posted: Sun Mar 08, 2020 10:51 pm
by Marius
pythoncoder wrote:
Thu Feb 27, 2020 10:25 am
I have released this repo which supports infra red remote controls. Protocols supported are NEC, Sony, and two Philips options. A receiver and "blaster" driver are provided. Both are nonblocking. They are not reliant on uasyncio but are compatible with it. The transmitter is Pyboard specific.

A transmitter demo implements a 2-button remote with auto-repeat.
Thanks for the work! :D I will def check it out.

Re: Receive and transmit IR remote codes

Posted: Mon Mar 09, 2020 7:17 am
by pythoncoder
This is a work in progress. The code on GitHub works, but I'm improving it with the following objectives:
  1. Receiver and Transmitter will be Python packages to reduce RAM use.
  2. Transmitter will work on ESP32 in addition to Pyboards.
ESP8266 is incapable of a nonblocking transmit owing to the limitations of its PWM.

Re: Receive and transmit IR remote codes

Posted: Wed Mar 11, 2020 12:13 pm
by pythoncoder
This has now been updated. The API has changed since the initial release but should now be stable. All drivers are nonblocking. The transmitter now fully supports ESP32.

The ESP32 transmitter uses a PWM object to generate the carrier. Modulation is provided by the RMT class which offers precision timing. A simple hardware gate physically performs the OOK modulation and drives the IR LED.

Re: Receive and transmit IR remote codes

Posted: Wed Mar 11, 2020 2:33 pm
by kevinkk525
This sounds so awesome I want to try it :D But I don't really have a use-case for it :? I don't really use any devices with IR..
Unless it can control RF433Mhz power sockets one day :lol: then I have lots of use-cases.

Re: Receive and transmit IR remote codes

Posted: Thu Mar 12, 2020 8:30 am
by pythoncoder
The applications I have in mind are bridges between IR remotes and WiFi, or IR to UART bridges. With a WiFi bridge a few devices could control an IR controlled box in one room using its remote elsewhere. Or control a Sonoff-type WiFi mains socket.

My original interest in the Sonoff was to make the receiver part of this bridge. I fitted the chip in the box and wrote the code to do MQTT publications on receipt of IR. It worked but the original Sonoff hardware proved so poor that I abandoned it. The new one does work well enough to do this job and I think I could fit the chip in the box, but I suspect an ESP32 (or even better a Pyboard D) running off a USB wall-wart might be a better solution now.

Another use case for the receiver would be for projects controlled by an IR remote. My completed projects use touchscreens but I have ideas for things which would benefit from remote control.

As for 433MHz it's getting on for a decade since I played with that (using Arduino). What do you have in mind? A WiFi/MQTT to 433MHz transmitter bridge? Or a simple IR rx with 433MHz tx? I doubt either would be hard: I'm sure the RF protocols will be published somewhere. Failing that, there's always an rx and a scope...

Re: Receive and transmit IR remote codes

Posted: Thu Mar 12, 2020 7:19 pm
by kevinkk525
You are right, I wasn't thinking far enough.. It's not only about controlling an IR device. I could use an IR remote to control everything in my house connected by mqtt, which is pretty cool actually.
Have to think about that some more.. I have a project in a different building where lights are going to be controlled over mqtt (using Sonoff 4CH Pro and Sonoff T0EU3C switches). An IR remote could be pretty nice addition here.


As for 433MHz there are libraries for RPIs in C++ but my C++ is a bit rusty.. However I expect the esp8266 to be incapable of getting the timings right. An esp32 using RMT would probably have no problem. But can't put any time into that right now.
Just thought about it as I control the lights in my room using 433MHz power sockets and I still have 8 more lying around :D They are a lot cheaper than Sonoff Wifi Power Sockets (and I have those since a few years now...).

Re: Receive and transmit IR remote codes

Posted: Fri Mar 13, 2020 6:41 am
by wr300000
Hi Peter,
I've got TSOP4838 38kHze receiver on my breadboard wit ESP32-PSRAM including copy ir_rx directory application already to test your ir_rx driver but unfortunately, upip could not find this package. see below message.

>>> upip.install('pystone_lowmem')
Installing to: /lib/
Installing pystone_lowmem 3.4.2.post4 from https://micropython.org/pi/pystone_lowm ... st4.tar.gz <--- confirm that upip and internet is working well
>>> upip.install('ir_rx')
Installing to: /lib/
Error installing 'ir_rx': Package not found, packages may be partially installed <--- I don't have any frozen ir_rx modules
>>>

How can I install your ir_rx driver package ?

Re: Receive and transmit IR remote codes

Posted: Fri Mar 13, 2020 6:50 am
by pythoncoder
This has prompted a few ideas. To relate just one of them: I use 433MHz remote controlled sockets in several locations around the house. The remotes have lousy range. I wonder if a 433MHz transmitter module with a decent antenna and groundplane, centrally located, could control all the sockets around the house? From what I've read the modulation is OOK, as per IR remotes but with different protocols. It does sound like it might be easy to try.

The ESP32 RMT class is magic :D

Re: Receive and transmit IR remote codes

Posted: Fri Mar 13, 2020 6:54 am
by pythoncoder
wr300000 wrote:
Fri Mar 13, 2020 6:41 am
...
How can I install your ir_rx driver package ?
The package is only on GitHub, not on PyPi, so upip cannot install it. You need to clone the repository to your PC and copy the directory to your device as per the docs.

Code: Select all

git clone https://github.com/peterhinch/micropython_ir
will copy my repo to the current directory on your PC. Then use rshell (or other utility) to copy it to your hardware.