IR transmitter/receiver
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: IR transmitter/receiver
I'm baffled by this post. The MicroPython source tree has no pigpio.h. Please could you explain exactly what this post is about?
My IR library can be found here and it contains no such file (being entirely Python code).
My IR library can be found here and it contains no such file (being entirely Python code).
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: IR transmitter/receiver
First time posting! I was looking at the IR python repo posted above. I am curious how the 38khz carrier is being accomplished on the esp32? I just made it work after hours of poking and my solution was differents. What I did was find the esp32_rmt.c file and change the values for tx config, and bingo!
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: IR transmitter/receiver
It is explained in the docs.
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
Technically the RMT peripheral of the ESP32 is designed to create single pulse trains just like the IR transmitter needs.JonRob wrote: ↑Mon Jun 01, 2020 6:35 amFirst time posting! I was looking at the IR python repo posted above. I am curious how the 38khz carrier is being accomplished on the esp32? I just made it work after hours of poking and my solution was differents. What I did was find the esp32_rmt.c file and change the values for tx config, and bingo!
Re: IR transmitter/receiver
Oh, I see, using PWM on another pin and wiring them together in the circuit to make the carrier, Brilliant!
How hard would it be to add a couple arguments to the esp32.RMT() call to set the values? Hard coding works for my needs but I am like a cat, curious about how. Is there a readme that has any clues?
maybe add something here to 'allowed_args[] = ' in ports/esp32/esp32_rmt.c
and use them in the config setup below?
Code: Select all
STATIC mp_obj_t esp32_rmt_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_id, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = -1} },
{ MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_clock_div, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 8} }, // 100ns resolution
};
.
.
.
rmt_config_t config;
config.rmt_mode = RMT_MODE_TX;
config.channel = (rmt_channel_t)self->channel_id;
config.gpio_num = self->pin;
config.mem_block_num = 1;
config.tx_config.loop_en = 0;
config.tx_config.carrier_en = true; <--- extend this variable
config.tx_config.idle_output_en = 1;
config.tx_config.idle_level = 0;
config.tx_config.carrier_duty_percent = 50; <----- and this
config.tx_config.carrier_freq_hz = 38000; <---------and this
config.tx_config.carrier_level = 1;
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: IR transmitter/receiver
I haven't studied the C code. The hardware supports modulation and support in the Python API would be great. I'm sure a tested PR would be welcomed by the maintainers.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: IR transmitter/receiver
Here it is! First pull request also. https://github.com/micropython/micropython/pull/6127/ Tests on the scope passed.pythoncoder wrote: ↑Tue Jun 02, 2020 4:58 amI haven't studied the C code. The hardware supports modulation and support in the Python API would be great. I'm sure a tested PR would be welcomed by the maintainers.
Re: IR transmitter/receiver
Hi,
I read this post because I like to do transceiver for my Air conditioner, it is an older model of Samsung and I read all documentation about this Air conditioner but can't find any info about protocol it used... If anyone knows or deal with SAMSUNG, please let e know the PROTOCOL, or is not necessary to know this? Does the code you provide support all protocols? I am not yet able to connect all the elements so I ask and collect information ...
I read this post because I like to do transceiver for my Air conditioner, it is an older model of Samsung and I read all documentation about this Air conditioner but can't find any info about protocol it used... If anyone knows or deal with SAMSUNG, please let e know the PROTOCOL, or is not necessary to know this? Does the code you provide support all protocols? I am not yet able to connect all the elements so I ask and collect information ...
- MostlyHarmless
- Posts: 166
- Joined: Thu Nov 21, 2019 6:25 pm
- Location: Pennsylvania, USA
Re: IR transmitter/receiver
Sorry to have been absent from the forum for (way too) long. Getting back into things, so checking my posts.jadro wrote: ↑Sun Feb 14, 2021 5:06 pmI read this post because I like to do transceiver for my Air conditioner, it is an older model of Samsung and I read all documentation about this Air conditioner but can't find any info about protocol it used... If anyone knows or deal with SAMSUNG, please let e know the PROTOCOL, or is not necessary to know this? Does the code you provide support all protocols? I am not yet able to connect all the elements so I ask and collect information ...
jadro, after doing a little bit in this direction I slowed down my efforts on the hardware side and tried to understand the protocol side of things. Let me tell you that IR protocols are a complete MESS. Yes, in capital letters. For getting a glimpse of how bad things are, check out this: http://www.hifi-remote.com/johnsfine/DecodeIR.html
Yeah, I was scratching my head about it too for a while, but after you read it for the 4th or 5th time, it starts sinking in.
What I did then was getting a BroadLink RM Mini3 and connected it to NodeRed. NodeRed has a function to "record" the buttons from an existing remote and then get the raw data in a JSON file inside the NodeRed data directory. I then proceeded to write Python scripts that can use those IRP protocol specifications together with that raw data to try and parse the raw data into anything meaningful. That way I would figure out what protocol a specific remote was sending (like Sony12 or Sony15). When you look at the IRP definition for Sony12 below, you see "F:7,D:5" and for Sony15 you see "F:7,D:8" in those strings. Those are actually the number of bits transmitted for the Function and Ddevice. All the other fluff around it defines the carrier frequency, what type of start sequence is sent, what on/off durations mean a 0 or a 1 and so on. Obviously Sony12 uses a total of 12 bits to address the device and function (7 + 5).
I am at the point where I can generate the actual IR codes for the RMmini from the resulting config file. This is the start of that file:
Code: Select all
{
"IRP": {
"Sony12": "{40k,600}<1,-1|2,-1>(4,-1,F:7,D:5,^45m)+",
"Sony15": "{40k,600}<1,-1|2,-1>(4,-1,F:7,D:8,^45m)+",
"Sony20": "{40k,600}<1,-1|2,-1>(4,-1,F:7,D:5,S:8,^45m)+",
"G.I. Cable": "{38.7k,490}<1,-4.5|1,-9>(18,-9,F:8,D:4,C:4,1,-84,(18,-4.5,1,-178)*) {C = -(D + F:4 + F:4:4)}"
},
"Functions": {
"TV_PWRON": ["Sony12", 1, -1, 46, [3]],
"TV_PWROFF": ["Sony12", 1, -1, 47, [3]],
"AMP_PWRON": ["Sony15", 48, -1, 46, [3]],
"AMP_PWROFF": ["Sony15", 48, -1, 47, [3]],
"AMP_PWR": ["Sony15", 48, -1, 21, [3]],
"AMP_MUTE": ["Sony15", 48, -1, 20, [3]],
"AMP_VOL_DOWN": ["Sony15", 48, -1, 19, [3]],
"AMP_VOL_UP": ["Sony15", 48, -1, 18, [3]],
"AMP_SLEEP": ["Sony15", 48, -1, 96, [3]],
"AMP_INPUT_BD": ["Sony20", 16, 40, 22, [3]],
"AMP_INPUT_DVD": ["Sony15", 48, -1, 125, [3]],
"AMP_INPUT_CATV": ["Sony15", 176, -1, 3, [3]],
"AMP_INPUT_TV": ["Sony15", 48, -1, 106, [3]],
"AMP_INPUT_VIDEO": ["Sony15", 48, -1, 34, [3]],
"AMP_INPUT_CD": ["Sony15", 48, -1, 37, [3]],
"AMP_INPUT_DMPORT": ["Sony20", 16, 40, 48, [3]],
"DVR_0": ["G.I. Cable", 0, -1, 0, [1]],
"DVR_1": ["G.I. Cable", 0, -1, 1, [1]],
Anyhow, if there is interest in this I can share my codec scripts via github.
Regards, Jan
- MostlyHarmless
- Posts: 166
- Joined: Thu Nov 21, 2019 6:25 pm
- Location: Pennsylvania, USA
Re: IR transmitter/receiver
On a side note, by try and error I found that a lot of devices have IR functions, that are not available from their original remotes. Like dedicated power on/off signals, where the remote can only send the power toggle signal.
This means that if you can only use a remote "learn & repeat" system in order to teach a generic remote, you can never teach it those special codes. By going through the process of analyzing the protocol and then synthesizing it again, one can do the try and error and find codes, the remote doesn't support.
For home automation you most definitely want to know the codes for ON and OFF, not the one for TOGGLE.
This means that if you can only use a remote "learn & repeat" system in order to teach a generic remote, you can never teach it those special codes. By going through the process of analyzing the protocol and then synthesizing it again, one can do the try and error and find codes, the remote doesn't support.
For home automation you most definitely want to know the codes for ON and OFF, not the one for TOGGLE.