LAOMAO infrared diode LED IR emission and receiver
Infrared (IR) emission(Tx) and Demodulating PCM Detector receiver(Rx) for Infrared Data Communications.
IR FOR REMOTE CONTROL
Used to transmit IR digital information by pulsing the TX IR LED using an 38KHz carrier.
Note other variants are 30KHz, 32.75KHz , 36.7KHz , 36KHz , 40KHz and 56KHz carrier frequencies, very handy if you need more that one IR system in operation in the same area or a bi-directional link.
You can use a 555 timer IC to produce the 38KHz carrier for the IR LED(Tx) use a 220-470 ohm resistor to limit the current to the IR LED. I recommend using a frequency counter to set this up (Arduino frequency counter library or for ESP32) I wrote some simple code that should work on most micros running Arduino That gives a rough frequency counter for the 555 circuit below
#include <FS.h>
const byte freqIn = D4; // Input pin for test frequency signal (use any IO pin)
bool levelState; // storage for level state (high or low) of measured input
long freqVal = 0; // Frequency Counter
// Timing using Millis
uint32_t previousMillis = 0;
int samplingTime = 1000; // default sampling rate is 1 second
int startDelay = 2; // delay to make sure it starts on at the beginning of a millis update
void setup() {
pinMode(freqIn, INPUT_PULLUP); // Input pin used for Frequency measurement
pinMode(D3, INPUT_PULLUP); // Test Input pin for 1838B receiver output (use any IO pin)
pinMode(D5, OUTPUT); // Optional output pin follows Input pin drive an LED
Serial.begin(115200);
Serial.println(); Serial.println("Digital Frequency measurement on pin D4");
}
void loop() {
bool levelIn; // veriable for current input level (Low or High)
previousMillis = millis(); // store current millis count
while (millis() < previousMillis + startDelay) { // wait for millis sync delay
}
levelState = digitalRead(freqIn); // initialise current input state
// frequency count loop
while (millis() < previousMillis + startDelay + samplingTime) { // loop for sampling time
levelIn = digitalRead(freqIn); // Get current input value (Low or High)
if (levelIn!=levelState){ // check for change of input state
levelState=levelIn; // store current new state (Low or High)
if (levelIn) freqVal++; // count low to high transitions
}
digitalWrite(D5,digitalRead(D3)); // get D3 input and send to D5 ouput used for 1838B output
// optional code Serial.print(" Rx Val = "); Serial.println(digitalRead(D3));
}
Serial.print(freqVal); Serial.println(" Hz");
freqVal=0; // reset counter for next Frequency measurement
}
38 kHz Generator
Simple TEST Code
Or use an interrupt on a micro computer such as a ESP32 or Arduino etc works well. Libraries here (External)
Note this code may be helpful (External link)
The epoxy package contains a special IR filter.
This includes a Photo detector and pre-amplifier in one package and an Internal filter for Pulse Code Modulation (PCM)
Property:
Voltage: 2.7 ~ 5.5V
Frequency: 38KHz
Receiver angle: ± 45 °
Operate Distance: 18 ~ 20m
Total length approx. 30mm
Vcc = 0 to +6.0 V
IR detector(Rx) Internal Block diagram
IR LED + IR receiver 1838B circuit
I recommend using a maximum data modulating pulses of around 4 KHz using a 50/50 duty cycle is recommended, but not a problem if slower data frequency's are used.
Using a 47uF-220uF Electrolytic capacitor and a 0.01-0.1uF ceramic capacitor across the supply will help reduce noise.
Also a 47 ohm resistor between Vcc and +5V used with around a 22k ohm pullup between +5V and Vout can be added to reduce noise if needed.
Notes
All these values are approximate so use what you have within reason)
The Arduino and ESP32 have a 100k ohm pull up include - use the pinMode INPUT_PULLUP
For a very good write up I recommend this https://www.circuitbasics.com/arduino-ir-remote-receiver-tutorial/