how to IR remote control via wemos d1 (esp8266) & mqtt & sonoff tasmota


I used wemos d1 and connected like this:


(source: https://github.com/witnessmenow/ESP8266-IR-Remote-Example)

Receiver module is tsop38238


Transistor : 2N3904
(without it , LED is not bright enough to send IR signal)

Led diode is Infrared diode.

I used this library with arduiono : https://github.com/markszabo/IRremoteESP8266

From examples  with this one: IRrecvDumpV2.ino

you can capture IR codes from the remote by pressing the remote button and it will be captured and it generates codes like this:




Timestamp : 000052.297
Encoding  : NEC
Code      : C12FE817 (32 bits)
Library   : v2.5.5

Raw Timing[135]:
   +  9036, -  4466,    +   588, -  1668,    +   598, -  1660,    +   596, -   562, 
   +   564, -   568,    +   570, -   562,    +   564, -   568,    +   572, -   560, 
   +   566, -  1664,    +   590, -   542,    +   596, -   564,    +   564, -  1666, 
   +   590, -   544,    +   594, -  1662,    +   594, -  1662,    +   592, -  1664, 
   +   590, -  1668,    +   598, -  1660,    +   596, -  1660,    +   596, -  1662, 
   +   594, -   540,    +   588, -  1668,    +   596, -   562,    +   566, -   568, 
   +   570, -   562,    +   566, -   566,    +   570, -   562,    +   566, -   566, 
   +   570, -  1660,    +   596, -   536,    +   590, -  1666,    +   598, -  1660, 
   +   596, -  1658,    +   596, - 39136,    +  9030, -  4472,    +   594, -  1662, 
   +   592, -  1664,    +   592, -   540,    +   596, -   562,    +   564, -   568, 
   +   570, -   562,    +   566, -   566,    +   570, -  1660,    +   594, -   538, 
   +   590, -   568,    +   568, -  1662,    +   592, -   540,    +   598, -  1660, 
   +   596, -  1660,    +   594, -  1662,    +   592, -  1666,    +   590, -  1666, 
   +   590, -  1668,    +   596, -  1660,    +   596, -   536,    +   590, -  1666, 
   +   588, -   544,    +   594, -   566,    +   562, -   544,    +   594, -   564, 
   +   562, -   570,    +   566, -   564,    +   562, -  1668,    +   596, -   536, 
   +   592, -  1666,    +   590, -  1666,    +   588, -  1666,    +   590

uint16_t rawData[135] = {9036, 4466,  588, 1668,  598, 1660,  596, 562,  564, 568,  570, 562,  564, 568,  572, 560,  566, 1664,  590, 542,  596, 564,  564, 1666,  590, 544,  594, 1662,  594, 1662,  592, 1664,  590, 1668,  598, 1660,  596, 1660,  596, 1662,  594, 540,  588, 1668,  596, 562,  566, 568,  570, 562,  566, 566,  570, 562,  566, 566,  570, 1660,  596, 536,  590, 1666,  598, 1660,  596, 1658,  596, 39136,  9030, 4472,  594, 1662,  592, 1664,  592, 540,  596, 562,  564, 568,  570, 562,  566, 566,  570, 1660,  594, 538,  590, 568,  568, 1662,  592, 540,  598, 1660,  596, 1660,  594, 1662,  592, 1666,  590, 1666,  590, 1668,  596, 1660,  596, 536,  590, 1666,  588, 544,  594, 566,  562, 544,  594, 564,  562, 570,  566, 564,  562, 1668,  596, 536,  592, 1666,  590, 1666,  588, 1666,  590};  // NEC C12FE817
uint32_t address = 0xF483;
uint32_t command = 0x17;
uint64_t data = 0xC12FE817;

You can use this button's code to send with another example:

IRSendDemo.ino 

with a code like this: irsend.sendNEC(0x00 C12FE817); 

After confirming everything works, I used it with sonoff-tasmota:

https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#how-to-use-commands

Tasmota configuration is like this:



gpio4 equals to D2 on wemos.

gpio14 equals to D5 on wemos

after configuration you can send commands on mqqt like this:

IRsend {"Protocol":"NEC","Bits":32,"Data":0x00C12FE817}

If your mqqt topic is irgate post to 

cmnd/irgate/IRsend with data {"Protocol":"NEC","Bits":32,"Data":0x00C12FE817}

also you can capture the signals via mqttt, when received it will be posted to mqtt automatically






Comments

Popular posts from this blog

how can you enable a windows firewall rule for a dynamic dns name or dns address

Bose speaker hack (companion 5) to turn on/off automatically