Gambar 1. Pulse sinyal IR adalah sinyal on-off dengan frekuensi 38 KHz
Untuk membuat aplikasi Infrared Receiver, anda membutuhkan sensor Infrared sebagaimana yang ditunjukan pada Gambar 2.
Gambar 2. IR Receiver TL 1838
TL 1838 memiliki karakteristik operasi dengan tegangan 2.7 - 5.5 volt, dengan jangkauan penerimaan 10 s/d 15 meter, dengan sudut deteksi mencapai 70 derajat.
Suatu IR Receiver TL1838 memiliki tiga buah pin yaitu Out, GND dan VCC sebagaimana yang ditunjukan pada Gambar 2.
Gambar 3. Jarak deteksi sinyal IR TL1838
Suatu IR Receiver TL1838 memiliki tiga buah pin yaitu Out, GND dan VCC sebagaimana yang ditunjukan pada Gambar 2.
Gambar 3. Pin pada IR Receiver
---------------
IRremote ESP8266 Library
This library enables you to send and receive infra-red signals on an ESP8266 using Arduino framework (https://github.com/esp8266/Arduino)This library is based on Ken Shirriff's work (https://github.com/shirriff/Arduino-IRremote/)
Mark Szabo has updated the IRsend class to work on ESP8266 and Sebastien Warin the receiving & decoding part (IRrecv class).
Seb's notes : I also changed the pulse parameters for Samsung, update the Panasonic and Samsung decoders and remove the SANYO decoders. The IR decoder was successfully tested with Panasonic and Samsung remote controls.
Installation
- Click "Download ZIP"
- Extract the downloaded zip file
- Rename the extracted folder to "IRremoteESP8266"
- Move this folder to your libraries directory (under windows: C:\Users\YOURNAME\Documents\Arduino\libraries)
- Restart your Arduino ide
- Check out the examples
Contributing
If you want to contribute to this project:- Report bugs and errors
- Ask for enhancements
- Create issues and pull requests
- Tell other people about this library
------------------
Langkah-langkah:
1. Hubungkan pin VCC ke 3V3 pada board NodeMCU
2. Hubungkan pin GND ke GND pada board NodeMCU
3. Hubungkan pin OUT ke D5 pada board NodeMCU
4. Download zip file IR Remote ESP8266 Library
5. Pada Sketch, pilih Include Library, pilih Add Zip Libary, dan pilih zip file library pada langkah 4.
6. Lakukan koding berikut ini:
7. Pada menu File, pilih Example, Pilih IRRemoteESP8266, pilih IRrecvDump, dan lakukan perubahan pada koding int RECV_PIN = D5;
/*
* IRremoteESP8266: IRrecvDump - dump details of IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 Sept, 2015
* Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
* LG added by Darryl Smith (based on the JVC protocol)
*/
#include <IRremoteESP8266.h>
int RECV_PIN = D5; //an IR detector demodulator is connected to GPIO pin D5
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void dump(decode_results *results) {
// Dumps out the decode_results structure.
// Call this after IRrecv::decode()
int count = results->rawlen;
if (results->decode_type == UNKNOWN) {
Serial.print("Unknown encoding: ");
}
else if (results->decode_type == NEC) {
Serial.print("Decoded NEC: ");
}
else if (results->decode_type == SONY) {
Serial.print("Decoded SONY: ");
}
else if (results->decode_type == RC5) {
Serial.print("Decoded RC5: ");
}
else if (results->decode_type == RC6) {
Serial.print("Decoded RC6: ");
}
else if (results->decode_type == PANASONIC) {
Serial.print("Decoded PANASONIC - Address: ");
Serial.print(results->panasonicAddress, HEX);
Serial.print(" Value: ");
}
else if (results->decode_type == LG) {
Serial.print("Decoded LG: ");
}
else if (results->decode_type == JVC) {
Serial.print("Decoded JVC: ");
}
else if (results->decode_type == AIWA_RC_T501) {
Serial.print("Decoded AIWA RC T501: ");
}
else if (results->decode_type == WHYNTER) {
Serial.print("Decoded Whynter: ");
}
Serial.print(results->value, HEX);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
Serial.print("Raw (");
Serial.print(count, DEC);
Serial.print("): ");
for (int i = 1; i < count; i++) {
if (i & 1) {
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
}
else {
Serial.write('-');
Serial.print((unsigned long) results->rawbuf[i]*USECPERTICK, DEC);
}
Serial.print(" ");
}
Serial.println();
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
dump(&results);
irrecv.resume(); // Receive the next value
}
}
8. Lakukan Verify dan Upload.
Catatan:
Jika anda mendapatkan error:
fatal error: avr/interrupt.h: No such file or directory
#include <avr/interrupt.h>
^
compilation terminated.
Using library RobotIRremote at version 1.0.2 in folder: C:\Program Files (x86)\Arduino\libraries\RobotIRremote
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
Artinya anda mencoba menggunakan Library IR Remote versi Arduino, silakan download untuk yang versi ESP8266 pada link yang telah diberikan diatas.
Gambar 4. Hasil dengan Remote AC Panasonic
Salam,
Hendra.
Tidak ada komentar:
Posting Komentar