Sonoff-Tasmota IRSEND and USE_IR_REMOTE

6,543 views
Skip to first unread message

Nick Barnett

unread,
Feb 20, 2017, 6:45:07 PM2/20/17
to SonoffUsers
I noticed in the release notes from Feb 14th that the IR sender was implemented. I couldn't actually find any documentation on it, so I kind of poked around with it until it worked. I found a sample of formatted json data in xdrv_ir_send, which is pretty much exactly all that you need. You just need to send a json payload to cmnd/sonoff/IRSEND.

[{"id":"14b89ea2.ea4031","type":"inject","z":"7daf55d2.758d4c","name":"","topic":"","payload":"{ \"protocol\": \"SAMSUNG\", \"bits\": 32, \"data\": 551502015}","payloadType":"json","repeat":"","crontab":"","once":false,"x":272.9513702392578,"y":987.513916015625,"wires":[["a3e6d2a1.32e1f"]]},{"id":"a3e6d2a1.32e1f","type":"mqtt out","z":"7daf55d2.758d4c","name":"","topic":"cmnd/sonoff/IRSEND","qos":"2","retain":"","broker":"","x":484.89581298828125,"y":986.4444580078125,"wires":[]}]

Of course, make sure you configure the sonoff device via web interface (or some other way) to tell it you have an IR LED on a certain GPIO... and you need to make sure that USE_IR_REMOTE is defined in user_config.h prior to build.

I'm just super stoked because I have been toiling at writing my own (crummy and unstable) mqtt IR code, and now I don't have to any more :)

Thanks,
Nick

p.s. Other super bonuses in this build... DHT temp data comes on a SENSORS MQTT channel. There is an option to backup and restore individual configurations. That's all I've noticed so far, but any one of these was reason enough to update.

p.p.s.  if this stuff is documented somewhere else, please let me know so I don't waste any more of yours or my time :)

Mike Pippin

unread,
Feb 24, 2017, 12:22:22 AM2/24/17
to SonoffUsers
So we could basically build a generic broadlink rm type device with a sonoff. Man Tasmota just gets more amazing

Nick Barnett

unread,
Feb 24, 2017, 11:08:13 AM2/24/17
to SonoffUsers
I just flashed Tasmota on a cheap ESP-01 I had laying around, hooked up a spare IR LED and 33 ohm resister and I now have a fantastic IR blaster.

David Lang

unread,
Feb 25, 2017, 2:28:01 PM2/25/17
to SonoffUsers

Nick Barnett

unread,
Feb 25, 2017, 3:50:57 PM2/25/17
to SonoffUsers
It's the now...

Nick Barnett

unread,
Feb 25, 2017, 3:51:27 PM2/25/17
to SonoffUsers
D'oh, it's There now, wasn't before

Markus Rohner

unread,
May 11, 2017, 4:11:43 AM5/11/17
to SonoffUsers
How did you configure the IR sender in Tasmota? 

Tasmota wiki suggests: IR Remote - IRremote (8) in group 5
I do not see IR Remote under GPIO14 on the Tasmota Web config page 

Paul Smith

unread,
Sep 18, 2017, 4:02:55 AM9/18/17
to SonoffUsers
Hi Nick,

Thanks for this. I'm a wondering how you get the codes for the remote. I installed IRremoteESP8266 and got this out for one button.

Encoding  : SONY
Code      : 540C (15 bits)
Timing[31]: 
   +  2462, -   520,    +  1268, -   520,    +   674, -   520,    +  1268, -   520, 
   +   672, -   520,    +  1268, -   520,    +   646, -   546,    +   648, -   542, 
   +   672, -   520,    +   674, -   520,    +   674, -   516,    +   652, -   542, 
   +  1268, -   520,    +  1272, -   516,    +   652, -   542,    +   672
uint16_t rawData[31] = {2462, 520,  1268, 520,  674, 520,  1268, 520,  672, 520,  1268, 520,  646, 546,  648, 542,  672, 520,  674, 520,  674, 516,  652, 542,  1268, 520,  1272, 516,  652, 542,  672};  // SONY 540C
uint32_t address = 0x30;
uint32_t command = 0x15;
uint64_t data = 0x540C;

Using the 0x540C in the demo IRsend it works.

Everything I've tried on the sonoff doesn't switch on the device.

In the wiki is says "data is the data frame as 32 bit unsigned integer."

So i tried converting the numbers to integers but it still doesn't work.

Can you please point me in the right direction.

Regards

Paul

Mike Roberts

unread,
Nov 1, 2017, 10:24:00 AM11/1/17
to SonoffUsers
I got this working to turn an LG TV on/off.  I found that the number had to be in integer form.  I tried 0x....  but this did not work.  The payload was:  {"Protocol": "NEC","Bits": 32,"Data": 551489775}
Also note that the number included a 16 bit pre-data.
Mike


On Monday, 20 February 2017 23:45:07 UTC, Nick Barnett wrote:

Jonathan Roberts

unread,
Dec 29, 2017, 3:57:02 PM12/29/17
to SonoffUsers
@ Paul Smith

Not sure if you got this working.  Unfortunately for me LIRC site was basically useless.  No data for any new devices etc...  You are 100% on the right path.  In the output you posted the "DATA" you need to convert for TASMOTA is the very last line "uint64_t data = 0x540C".

Simply take that code 540C (drop the 0x) to this website. Choose the unsigned int tab.  At the very bottom in the hexadecimal field type 540C then press ENTER on your keyboard.  This creates the binary equivalent, The next step get the proper unsigned 32bit integer TASMOTA needs.  Press the "Convert to Decimal" button, it should be blue.  This will spit out number, use that number as the TASMOTA "DATA" entry in IRSEND.

I have tested this with the Sony UBP-x800 UHD blu-ray player.  here is the Power Button command from the TASMOTA Web Console...
irsend {"PROTOCOL":"SONY","BITS":20,"DATA":"691015"}

Hope this helps others.


On Monday, February 20, 2017 at 6:45:07 PM UTC-5, Nick Barnett wrote:

Paul Fisher

unread,
Jan 6, 2018, 12:16:13 AM1/6/18
to SonoffUsers
Hi,

I'm new to this forum, my first post any guidance appreciated.

I've just started with the sonoff / tasmota / POW / D1 Mini. I'm having alot of success so far and it really is an excellent community. It's also my first exposure to the ESP8266 which is an incredible device.

I'm trying to do HVAC/AirConditioner control and I can see the libraries for IRSend and USE IR_HVAC includes. This appears to be limited to Mitsubishi and Toshiba commands.

I've spent alot of time researching, the control signals for HVAC devices are alot more complex. The most extensive library I can find that has been complied for the ESP8266  is this one 


It includes options for BitBang, 38Khz Carrier created with the ESP or IR Blaster boards using external 555 38Khz carrier IR boards.

It's the Panasonic commands I'm using but the list is extensive for this library.

 I have made a simple sketch and have been able to get all of the controls to work on a D1 mini.

I'm interested to do a pull request and integrate this library into tasmota or work with whom ever has integrated the IR_Send / IR_HVAC libraries already.

Thanks
Paul

Rafał Trzewikowski

unread,
Jan 17, 2018, 6:14:30 PM1/17/18
to SonoffUsers
@
Mike Roberts

I also have LG TV, made the IR sender as in 
https://github.com/altelch/SonoffIR and I cant control the TV with it. 2 questions: 1. which HW are you using? 2. How do you get the Data exactly (and LG values for it)? 
Thanks!
Rafal

Ron L

unread,
Jan 4, 2019, 9:33:18 PM1/4/19
to SonoffUsers
Rafial, I realize the last post was nearly a year ago, but did you ever find success?  I just recently waded in to the Tasmota IR control and while no expert, did learn quite a bit.  Best of all, I now have IR control of an LG TV, a DirecTV box and another off-brand TV.  It is amazing what these ESP devices flashed with Tasmota can do.  If you still have issues, let us know, I am sure there are folks out here that can help you.
Reply all
Reply to author
Forward
0 new messages