IR transmitter/receiver
IR transmitter/receiver
Is it possible to read IR signal from remote (any commercial remote control unit) using ESP32 and IR receiver, then reproduce that code using ESP32 and IR transmitter? Find many examples using Arduino, but didn't come across Micropython example.
- MostlyHarmless
- Posts: 166
- Joined: Thu Nov 21, 2019 6:25 pm
- Location: Pennsylvania, USA
Re: IR transmitter/receiver
Not saying it is impossible, but with pure Micropython it is going to be difficult to build something that resembles the function of a "Universal Remote". Recording and replaying arbitrary IR signals, that is.
The biggest problem is going to be sampling the signal from your original IR remote through something like an IR transistor at a sufficient rate.
A quick check on my OScope with a trivial loop of
shows
So even a trivial loop like that can only run at about 38 kHz. And it isn't very consistent as the pre-trigger waveform shows.
Assuming that reading a GPIO takes about as long as it takes to toggle it and since we need more code and memory access inside that loop ... our sampling frequency will be severely limited.
Generating signals is a lot easier than analyzing them.
Regards, Jan
Edit: Uploading image to forum for permanent link
The biggest problem is going to be sampling the signal from your original IR remote through something like an IR transistor at a sufficient rate.
A quick check on my OScope with a trivial loop of
Code: Select all
MPY: soft reboot
MicroPython v1.11-586-g1530fda9c on 2019-11-21; ESP32 module with ESP32
Type "help()" for more information.
>>> import machine
>>> led = machine.Pin(2, machine.Pin.OUT)
>>> while True:
... led.on()
... led.off()
...
Assuming that reading a GPIO takes about as long as it takes to toggle it and since we need more code and memory access inside that loop ... our sampling frequency will be severely limited.
Generating signals is a lot easier than analyzing them.
Regards, Jan
Edit: Uploading image to forum for permanent link
Last edited by MostlyHarmless on Mon Dec 02, 2019 12:31 am, edited 1 time in total.
Re: IR transmitter/receiver
Using Viper code you can toggle up to the MHz range. But using an ESP32, the RMT unit is made for interacting with Remotes. So it's the proper driver which is missing. RMT is excellent on generating and detecting pulses or carrier bursts. There is work in progress. See https://github.com/micropython/micropython/pull/5184
And both the Pycom and the loboris fork have it implemented, although only partial. Carrier bursts are not implemenetd yet.
And both the Pycom and the loboris fork have it implemented, although only partial. Carrier bursts are not implemenetd yet.
Re: IR transmitter/receiver
Find many solutions for Arduino, build one receiver on Arduino UNO and it works. Maybe that particular IR signal is easier to handle (think it is called NEC) ? Is there any reason that it is more difficult to implement on ESP32 with Micropython? Is it HW or SW that makes this implementation difficult?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: IR transmitter/receiver
Receiving 38KHz IR signals really needs one of these. This demodulates the 38KHz signal providing a much slower waveform which can readily be handled in code. The chip also does a lot of noise removal.
Note that some remotes use 36KHz requiring a different chip. I think these are fairly uncommon.
Note that some remotes use 36KHz requiring a different chip. I think these are fairly uncommon.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: IR transmitter/receiver
I have used a cheap IR receiver like posted by pythoncoder with a RPi and python written code to capture all my remotes around the house see this video https://www.youtube.com/watch?v=zDErQPXtMyU&t=3s from about half way in you will see me show the different protocols of the different remotes around the house.
Re: IR transmitter/receiver
Saw your video, thanks. Can you please share your github adress with code? Also, did you manage to program transmitter as well?
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: IR transmitter/receiver
Unfortunately I never saved the code to github and it was only on the RPi which later crashed. It is a pity because many others have asked for the code.
It basically went like this. I created a 2D array to hold the timing of offs and ons, then had a loop that waited for the long start bit then stored all the timing of the on's and off's that followed until there was a long break then analyzed the results. If you watch my whole video you should be able to work out what your looking for
And yes I manged to then transmit with the RPi.
It basically went like this. I created a 2D array to hold the timing of offs and ons, then had a loop that waited for the long start bit then stored all the timing of the on's and off's that followed until there was a long break then analyzed the results. If you watch my whole video you should be able to work out what your looking for
And yes I manged to then transmit with the RPi.
Re: IR transmitter/receiver
way above my knowledge level
Re: IR transmitter/receiver
The ESP32 specific RMT driver has now been merged and is in v1.12.
So far it’s TX only, and more features will be added soon.
I’ve got this little 5V UART IR TX+RX module working with ESP32.
https://github.com/mcauser/micropython-ys-irtm
It can listen, capture and replay with a few lines of code.
So far it’s TX only, and more features will be added soon.
I’ve got this little 5V UART IR TX+RX module working with ESP32.
https://github.com/mcauser/micropython-ys-irtm
It can listen, capture and replay with a few lines of code.