You are on page 1of 8

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/315855200

Sending IR codes with WeMosD1 Mini and Blynk

Research · April 2017


DOI: 10.13140/RG.2.2.25231.18086

CITATIONS READS
0 3,268

1 author:

M. Todica
Babeş-Bolyai University
101 PUBLICATIONS   405 CITATIONS   

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

IR and Raman Investigation of Some Poly(acrylic) Acid Gels in Aqueous and Neutralized State View project

Algorithm for preliminary analysis of viscosity behaviour of some aqueous poly(ethylene oxide) gels View project

All content following this page was uploaded by M. Todica on 10 April 2017.

The user has requested enhancement of the downloaded file.


Sending IR codes with WeMosD1 Mini and Blynk
M. Todica

In this work we will show how to send IR codes of some IR TV, audio systems, LED
strip, etc. remote controlc using Blynk application and smartphone via internet. In
addition we will have a feedback of the transmitted order. To do this we used the
WeMosD1 mini board and few external components, one IR LED, one 560 Ohms resistor
and one 2N2222 transistor. Optionally we can use a witness led, lighting when the IR
data string is send. The circuit is shown in the figure 1. The IR led is connected directly
to the collector of the transistor 2N2222 and +3.3V of the board. The emitter of the
transistor is connected directly to the GND and the gate is connected to the digital D2 pin
of the WeMosD1 Mini board trough a 220-560 Ohms resistor. The witness LED is
connected between the same D2 pin and GND trough a 220 Ohms resistor. The work
contains two parts:
Part 1, the Receiver. In this stage we need to decode the codes of the original remote
control of the device that we wish to control with Blynk, for instance the RC of TV,
audio system or LED strip.
Part 2, the Sender. In this part we need to introduce the desired codes of the RC into
Arduino ide and programming the board WeMosD1 Mini.

IR LED
C
2N2222 G

Fig. 1. Connection of the IR led to WeMos D1 Mini

Part 1. The Receiver. To receive and decode the codes of the original remote control we
need to use UNO or Mega Arduino board and an IR sensor, for instance the TSOP38238.
If we use the Mega board we can connect the IR sensor directly to the board, (in order to
avoid the use supplementary wires). The output pin of the sensor is connected directly to
the D25, the GND to the D23 and the V+ to the D21 of the Mega, (Fig. 2). For UNO we
connect the sensor to +5v, GND and D11 pin. We upload the Arduino code to the Mega
board, we open the serial monitor, we place the remote control in the front of the IR
sensor and we push the desired button of the remote control. We will see on the monitor
something like this, (the example reefers to JVC audio system MX-30):

V+
OUT

Fig. 2. Connection of the IR sensor to Mega board

Decoded JVC(6): Value:C584 (16 bits)


Raw samples(36): Gap:56026
Head: m8300 s4200
0:m500 s1650 1:m450 s1600 2:m500 s550 3:m500 s550
4:m500 s550 5:m500 s1600 6:m450 s600 7:m450 s1650
8:m450 s1600 9:m500 s550 10:m500 s550 11:m500 s550
12:m450 s600 13:m450 s1650 14:m450 s550 15:m500 s550
16:m500
Extent=36000
Mark min:450 max:500
Space min:550 max:1650

We retain only the yellow highlighted part.


That means the type of protocol, (for instance JVC), the code, (C584), and the length, (16
bits)
We store these data for all the commands we wish to send, and we introduce into the
sending Arduino ide. The Receiver code is bellow.

///////// The Receiver code.


#include <IRLib.h>

//Create a receiver object to listen on pin D11 for UNO or pin D25 for Mega
//IRrecv My_Receiver(11); //for UNO
IRrecv My_Receiver(25); //for Mega
//Create a decoder object
IRdecode My_Decoder;

/*
The IR sensor's pins are attached to Arduino as so:
Pin 1 to pin D25 of Arduino
Pin 2 to pin D23 of Arduino
Pin 3 to Vcc (+5v of Arduino, or to pin D21 of Arduino Mega)
*/

int masaIR =23; //GND of the sensor

void setup()
{
Serial.begin(9600);
My_Receiver.enableIRIn(); // Start the receiver
pinMode(masaIR, OUTPUT);
digitalWrite(masaIR, LOW); //set the GND pin of the sensor to the ground

void loop() {
//Continuously look for results.
if (My_Receiver.GetResults(&My_Decoder)) {
My_Decoder.decode(); //Decode the data
My_Decoder.DumpResults(); //Show the results on serial monitor
My_Receiver.resume(); //Restart the receiver
}
}

/////////End of receiving code

Part 2, the Sender. In this part we will program the board WeMosD1 Mini to send the
IR codes. Firs of all we need to set our Arduino ide to recognize and communicate with
the WeMosD1 Mini board. We used the version Arduino 1.6.8. To do this please refers to
our previous works Controlling by smartphone via internet two relays with Blynk and
ESP 8266-01, DOI: 10.13140/RG.2.2.31986.91847
We need also to use the library IRremoteESP8266-master from github.com site.
Upload the code bellow:

///The Sender code for WeMosD1 Mini


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <IRremoteESP8266.h>

char auth[] = "dd15495460224bd6aa70d424cfb37eea";


//delete this and introduce yours char auth
char ssid[] = "introduce your SSID";
char pass[] = "introduce the password of your router";

IRsend irsend(4); // IR led is connected to pin D2 on WeMosD1 Mini

int vol=90;// initial position of the gauge widget

void setup() {
Serial.begin(9600);
delay(5000);
Blynk.begin(auth, ssid, pass);

irsend.begin();
}

void loop()
{
Blynk.run();

}
//////////////////////
BLYNK_WRITE(V13)
//read the status of button attached to virtual button V13
{
if (param.asInt() == 1){
for (int i = 0; i < 4; i++)
{

irsend.send(JVC,0xC5F8, 16);//Vol –
//please delete and replace with your code
//if sthe staus of the widget button is HIGH,
//the WeMosD1 Mini will send 4 times the above code
}

//Blynk.virtualWrite(12, 0xC5F8);
vol=vol-10;
//Blynk.virtualWrite(5, "Vol-");
Blynk.virtualWrite(5, vol);
//if the code sent by smartphone is received by the WeMosD1 Mini board,
//the board will send back the text "Vol-" on widget gauge V5.
//That ensure the software feedback.
}
}

/////////////////////
BLYNK_WRITE(V11)

{
if (param.asInt() == 1){
for (int i = 0; i < 4; i++)
{

irsend.send(JVC,0xC578, 16); //Vol +


}
//Blynk.virtualWrite(12, 0xC578);
vol=vol+10;
//Blynk.virtualWrite(5, "Vol+");
Blynk.virtualWrite(5, vol);
//displays the vol+ on widget gauge V5

}
}

/////////////////////////////

BLYNK_WRITE(V3)

{
if (param.asInt() == 1){
for (int i = 0; i < 4; i++)
{

irsend.send(JVC,0xC544, 16); //touch 2 for JVC


irsend.send(NEC,0xF7C03F, 32);//touch ON for led strip
}
//Blynk.virtualWrite(12, 0xC544);
Blynk.virtualWrite(12, " touch 2 ON");
//displays the text " touch 2 ON" on virtual V12

}
}

BLYNK_WRITE(V1)

{
if (param.asInt() == 1){

for (int i = 0; i < 4; i++)


{
irsend.send(JVC,0xC5C4, 16); // touch 3
irsend.send(NEC,0xF740BF, 32);// touch OFF led strip
}
//Blynk.virtualWrite(12, 0xC5C4);
Blynk.virtualWrite(12, " touch 3 OFF");
//delay(40);
}
}

BLYNK_WRITE(V0)

if (param.asInt() == 1){

for (int i = 0; i < 4; i++)


{

irsend.send(JVC,0xC584, 16); // touch 1


irsend.send(NEC,0xF720DF, 32);// touch RED led strip
}
//Blynk.virtualWrite(12, 0xC584); //displays the code
Blynk.virtualWrite(12, " touch 1 RED"); // displays the number of the touch
//delay(40);
}
}

BLYNK_WRITE(V8)

if (param.asInt() == 1){
for (int i = 0; i < 4; i++)
{

irsend.send(JVC,0xC524, 16); //touch 4


irsend.send(NEC,0xF7A05F, 32); //touch GREEN led strip
}
//Blynk.virtualWrite(12, 0xC524);
Blynk.virtualWrite(12, "touch4 GREEN");
//delay(40);
}
}

/// End of the sending code


View publication stats

We introduced here two codes, for JVC audio system, and NEC for led strip. When a
button is pushed ON, the two codes are sent simultaneously to the two systems. If both
are in ON state, both will react accordingly to the sent command. If only one of them is
ON, only that system will react. In this way it is possible to control two different systems
without changing the code uploaded to the WeMosD1 Mini.

Blynk settings.
On the smartphone, we set the Blynk as follows:
The board: Arduino UNO WI Fi ESP8288

We added button widget as follows:


V0 corresponding to touch 1 of remote control and state OFF for Led Stip
V1 corresponding to touch 3 of remote control and state RED for Led Stip
V3 corresponding to touch 2 of remote control and state ON for Led Stip

V8 corresponding to touch 4 of remote control and state GREEN for Led Stip

V11 corresponding to touch Vol + of remote control and


V13 corresponding to touch Vol - of remote control

We added value display widget on virtual V12 for feedback, (software feedback). It will
display the name of the touch activated.
We added gauge widget on virtual V5 for volume feedback, (software feedback). The
angle of the gauge will increase or decrease as the Buttons Vol+ or Vol – are activated.
The displays V12 and V5 will shows messages only if the transmitted code from the
smartphone is received by the board WeMosD1 Mini. If the board is offline or in OFF
state, these displays will not react.
Once the code uploaded to the board, this one will work independently from the
computer. Place the board in the area of work of the WI FI router, point the IR led
towards the device that will be remotely controlled and power the board using mini USB
cable. The board will connect automatically to the router and will wait the order
transmitted from the smartphone. That’s all.

Observation. If the system doesn’t work it is possible the libraries are not updated.
It is possible to use for sender the board WeMOsD1 R2 with the same code ide, but the
IR transmitter led will be connected to pin D4 instead D2.

Acknowledgment.
For this project we used many examples from internet which were modified according to
ours goal.

You might also like