IR Library for getting HEX for universal remotes
Posted: Sun Jul 07, 2024 6:06 am
I am currently using an ESP32-DevKitC-32E with ESP-IDF v5.2.2 in Visual Studio Code. My setup includes a TSMP98000 photodetector circuit and an IR LED driver circuit. I aim to capture HEX codes from button presses on a Universal Remote (K-1028E) or a SONY TV xbr-55x900e remote.
I have implemented the NEC remote infrared RMT example (ir_nec_transceiver) and receive NEC frames as shown below:
However, I need to obtain precise HEX values (e.g., 0x41F5BBD1) similar to those provided by the Arduino library. Here is the Arduino code I am referring to:
Could anyone assist me in achieving similar functionality with the ESP-IDF setup? Thank you.
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();
}
}