I have implemented the NEC remote infrared RMT example (ir_nec_transceiver) and receive NEC frames as shown below:
Code: Select all
NEC frame start---
{1:3},{0:688}
{1:31},{0:172}
{1:7949},{0:7349}
{1:3},{0:75}
{1:10},{0:166}
{1:8377},{0:0}
---NEC frame end: Unknown NEC frame
NEC frame start---
{1:3},{0:1054}
{1:678},{0:474}
{1:3},{0:87}
{1:266},{0:268}
{1:144},{0:171}
{1:32},{0:298}
{1:2095},{0:167}
{1:0},{0:167}
---NEC frame end: Unknown NEC frame
Code: Select all
#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRrecv.h>
#include <IRsend.h>
#include <IRutils.h>
// Define the GPIO pins for the IR receiver and transmitter
const uint16_t kRecvPin = 13;
const uint16_t kSendPin = 16;
// Create IR receiver and transmitter objects
IRrecv irrecv(kRecvPin);
IRsend irsend(kSendPin);
// Create a decode_results object to store received IR signals
decode_results results;
void setup() {
Serial.begin(115200); // Initialize serial communication
irrecv.enableIRIn(); // Start the IR receiver
irsend.begin(); // Initialize the IR sender
Serial.println("IR Receiver and Transmitter initialized");
}
void loop() {
if (irrecv.decode(&results)) {
// Convert received IR signal to a human-readable format
String hexValue = resultToHexidecimal(&results);
Serial.print("Received IR signal: ");
Serial.println(hexValue);
// Send the received IR signal using the identified protocol
irsend.sendRaw((const uint16_t*)results.rawbuf, results.rawlen, 38);
// Resume the IR receiver to receive the next signal
irrecv.resume();
}
}