In this exercise we will connect an IR receiver and IR transceiver. We will send IR signals to drive an IR LED RGB driver.
Typical RGB LED set you buy at a store:
The driver:
First we have to read signals from the IR LED RGB driver's remote to understand what IR signal each key generates.
There are other types of devices that use IR communication:
- TV
- HiFi Amplifier
- DVD
- AC Control
The same technique applies if we wanted to control our TV from our IoT solution. For example our home system could turn the TV on, dim the LED lights, so that you can enjoy your favorite TV show.
Conversely this also allows to read signals from any remote (TV, AC) into our IoT solution.
Specs:
- Input: 4.5V - 6V
- Average current: 5mA
- Frequency: 38kHz
According to the manufacturer specs we need to add 100 Ohm resistor to the Vcc
pin.
Approximate cost: 2.70 PLN. The part comes from here.
Connections:
Out
- outputs the IR signal. This will be connected to ESP GPIO pin.
The IR Receiver is an active part that does signal demodulation.
Specs:
- Wave length: 940nm
220 Ohm resistor was added to limit the current on the IR LED.
Approximate cost: 0.70 PLN. The part comes from here.
Connections:
In
- Connected to ESP GPIO pin and will emit the IR signal pattern.
Lets hook up the hardware.
GIPO | What |
---|---|
2 | IR Receiver (purple wire) |
15 | IR Transceiver (purple wire) |
The IRremoteESP8266 library allows us to send and receive infra-red signals. There are few IR industry standards and the library handles most of them.
The hardware setup and device software is based on previous step (11_MQTT_Exercse
). Copy the code over to 12_IR
folder.
- Handle the IR receiver and output all signals into serial monitor.
- Use the sample
IRrecvDump.ino
from the IR library. - Add
IRInFeatureController
class. - Override the
void Loop()
of theFeatureController
. - Set feature type as
irIn
. - Register on port
8
and use GPIO pin from table above. - Just write the recorded IR code (in hex) and code type (no need to send to web app).
- Handle the IR transceiver:
- Use the sample
IRsendDemo.ino
from the library. - Add
IROutFeatureController
class. - Override the
virtual void Handle(JsonObject& command)
. - Set feature type as
irOut
. - Register on port
9
and use GPIO pin from table above. - Sample command JSON from web-app is below.
{
"type": "irOut",
"port": 9,
"codeType": "NEC",
"codeData": [{
"bits": 32,
"data": 16712445
},
{
"bits": 0,
"data": 4294967295
}]
}
- Run the
06_JSON_2Relay_App
locally to control the RGB LED remote.