Using an ESP8266 As a WiFi Enabled Universal Remote

40K659

Intro: Using an ESP8266 As a WiFi Enabled Universal Remote

Hey Everyone!

In this instructable I'm going to show you how to make a WiFi enabled universal remote that you can control with your phone or computer.

I think it's a cool project that can be easily adapted or extended to whatever suits your needs.

Check out the video for a demo and quick run through what's involved in the project.

The code, hardware and circuit diagram are available on github.

STEP 1: Hardware for the Project

The hardware for the project is pretty straight forward, you will need the following parts:

  • Wemos D1 Mini
  • IR LED
  • 2N3904 (Although a 2N2222 might be a better choice)
  • 330 Ohm resistor
  • IR Receiver (TL1838) - Needed for reading codes.
  • A breadboard (everything fits on a mini breadboard)

Rather than connecting the IR LED directly to the pins of the ESP8266, we need to use a transistor as a switch. This is so the IR LED can get enough current.

The rest of the circuitry is pretty straight forward.

STEP 2: Software

The library I'm using for handling the IR sending and receiving is IRremoteESP8266 by MarksZazbo

First thing we need to do is flash the IrRecvDumpV2 example from the library to read the codes, just make sure to update the receive pin to the pin you are using for the IR receiver.

Open the serial console and press the button on the remote that you want to emulate. I recommend pressing the button a few times to ensure you have the right code. Take down the encoding and data for each button press.

Once you have all the codes for the buttons you want to emulate, download the sketch from ESP8266 IR Remote Example github.

The sketch hosts a web server, where the main webpage has various buttons representing the commands for the different remotes. Each button when clicked makes an Ajax call to unique end point that contains the actions behind each button.

Most of the buttons just send single commands, but commands can also be combined together to perform macros. In the example sketch the Chromecast button changes the channel on the TV and changes the sound input my receiver.

Hopefully this project proves useful if you are interested in making a similar project. It still needs some more work, as although my TV and Receiver work very well, commands to my Satellite box only work from short range. I will come back to this project again as I think there is a lot of cool things you could do with something like this.

If you have any questions please let me know.

Thanks a lot,

Brian

5 Comments

Hi there, I'm really struggling with this - I keep getting an error when compiling this on a Windows 10 laptop - I get the following error:-

BasicWebRemote:22: error: 'D2' was not declared in this scope

#define IR_SEND_PIN D2

^

C:\Users\mamvcivm\Documents\Arduino\BasicWebRemote\BasicWebRemote.ino:26:15: note: in expansion of macro 'IR_SEND_PIN'

IRsend irsend(IR_SEND_PIN);

^

exit status 1

'D2' was not declared in this scope

I thought I'd try installing Arduino on a Raspberry Pi and install the library via GIT, however the command cd ~/Arduino/libraries
git clone fails as the folder doesn't exist - if I create it and then import the library and then try to compile BasicWebRemote I get the error: BasiWwebRemote.ino:1:25: fatal error: ESP8266WiFi.h: No such file or directory

compilation terminated.

Can you please help?

Thanks,

Andrew

Hopefully, you got past the issue. Posting anyway for anyone coming behind.

// e.g. D2 on a NodeMCU board.

#define IR_SEND_PIN 4

Also, #include <IRsend.h>

Hello

I have used the IRRecvDumpV2 and these are the code I have

p { margin-bottom: 0.25cm; line-height: 115%; }

Timestamp :
000134.665

Encoding :
PANASONIC

Code :
400401004A4B (48 bits)

Library : v2.4.2

Raw Timing[99]:

+ 3532, - 1788,
+ 416, - 442, + 414, - 1330, + 418, - 442,

+ 414, - 444,
+ 414, - 444, + 414, - 444, + 414, - 444,

+ 414, - 444,
+ 416, - 444, + 416, - 444, + 414, - 444,

+ 414, - 444,
+ 416, - 444, + 416, - 1328, + 416, - 444,

+ 414, - 444,
+ 414, - 446, + 414, - 444, + 414, - 444,

+ 414, - 444,
+ 416, - 444, + 416, - 444, + 414, - 444,

+ 414, - 1334,
+ 414, - 442, + 414, - 444, + 414, - 444,

+ 414, - 446,
+ 414, - 446, + 416, - 444, + 414, - 444,

+ 414, - 444,
+ 414, - 446, + 414, - 1330, + 418, - 442,

+ 416, - 444,
+ 414, - 1330, + 418, - 442, + 414, - 1328,

+ 420, - 442,
+ 414, - 444, + 414, - 1332, + 416, - 444,

+ 414, - 444,
+ 414, - 1332, + 416, - 442, + 416, - 1332,

+ 414, - 1330,
+ 416

uint16_t rawData[99]
= {3532, 1788, 416, 442, 414, 1330, 418, 442, 414, 444, 414,
444, 414, 444, 414, 444, 414, 444, 416, 444, 416, 444, 414,
444, 414, 444, 416, 444, 416, 1328, 416, 444, 414, 444, 414,
446, 414, 444, 414, 444, 414, 444, 416, 444, 416, 444, 414,
444, 414, 1334, 414, 442, 414, 444, 414, 444, 414, 446, 414,
446, 416, 444, 414, 444, 414, 444, 414, 446, 414, 1330, 418,
442, 416, 444, 414, 1330, 418, 442, 414, 1328, 420, 442, 414,
444, 414, 1332, 416, 444, 414, 444, 414, 1332, 416, 442, 416,
1332, 414, 1330, 416}; // PANASONIC 400401004A4B

uint32_t address =
0x4004;

uint32_t command =
0x1004A4B;

uint64_t data =
0x400401004A4B;

Am I only the be concerned with

p { margin-bottom: 0.25cm; line-height: 115%; }

Code :
400401004A4B (48 bits) for me to SEND back the IR command?


Good afternoon.

I have mounted his circuit and worked well only with a samsung TV with another 3 tv but it did not work being the same code that is captured.

The original command sends 2 equal codes.

to add the code of a fujitsu AC command that line must be taken?

thank you very much for your help and the great job

Good instructable :) easy to build.
I had a few problems, but all were because I couldn't get exact same components.

I used a BC547 instead of the 2N3904
and my IR receiver was a 382403A from Jaycar
I finally figured out that the IR receiver needed 5v, and couldn't run the emitter at the same time.
Anyway it works! and now my phone can turn on my AC and TV :)
Thank you very much.

ps. sorry Mamvcivm, I have no idea about your problem.