Wemos Infrared receiver example

In this example we look at how to connect an IR Reciever. Generally, they require Vcc(5v) but I found this to work well with 3v3, GND and there is a data out which you connect to your Arduino. Here is a typical IR showing the pinout.

ir-example

Many electronic shops online stock breakouts for these but of course these are pretty useless without a remote control, you can use a standard remote but you can also purchase one like this for less than $1
1pcs/lot 38khz MCU learning board IR remote control Infrared decoder for protocol remote control For arduino .MP3 .MP4

Layout

wemos-and-ir_bb

Code

You’ll need the IR Remote library, you can get this from

https://github.com/markszabo/IRremoteESP8266

Download and import or copy into your Arduino -> Library folder. As usual this library will be doing most of the work making it easier for ourselves.

 

#include <IRremoteESP8266.h>
 
int RECV_PIN = D4; //an IR detector connected to D4
 
IRrecv irrecv(RECV_PIN);
 
decode_results results;
 
void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}
 
void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  delay(100);
}

Testing

I opened the serial monitor and pressed the keys on my remote control here is what was displayed

FF6897
FF30CF
3D9AE3F7
FF7A85
FF10EF
FF38C7
FF5AA5
FF42BD
FF4AB5
FF52AD
FFE01F
FFA857

As you can see with a bit of programming we can take these values and put them to use.

 

Links

Mini 38KHz Infrared Receiver Sensor Module for Arduino RPi STM32 FZ1577

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*