Go Down

Topic: YAMAHA YSP-4000 IR hex codes and how to store them for an ESP8266-12E (Read 2512 times) previous topic - next topic


Hi all,

Using a service manual for a YAMAHA YSP-4000 and some handy info from the below link, I've been able to come up with the following list of hex codes to control my YSP-4000 sound projector (which I've tentatively put in an array) which was missing a remote. Using an ESP8266-12E, the PubSubClient and IRremoteESP8266 libraries, I've got power, Volume up and down controllable by MQTT, only where I've hardcoded them.

My hope is to pass the short-form name for each function, such as "PWR_TOGGLE" via MQTT, the ESP would find that name in an array, then send the adjacent hex code with the irsend() function, as in my callback function below. I'm not sure whether an array is the wisest way to store the data, since I've got both names and hex codes of different types compiled together.

I imagine that an array of some form would make sense, rather than hardcoding them, even if i had separate arrays for names and the codes, as then i could iterate through the codes to generate a GUI, whether on an LCD screen, or on a webform.

I feel the way i'm doing it currently is clumsy and messy, as I'm only an amateur, but hopefully these codes may be of use to others!


Code: [Select]
String hexCodes[243] = {

Code: [Select]
void callback(char* topic, byte* payload, unsigned int length) {
  int i = 0;
  Serial.print("Message arrived [");
  Serial.print("] ");
  for (int i = 0; i < length; i++) {
    message_buff[i] = payload[i];
  message_buff[i] = '\0';
  String msgString = String(message_buff);

  //rough prototype
  for (int i = 0; i < length; i++) {
    if (msgString == hexCodes[i]) {
      irsend.sendNEC(hexCodes[i+1], 32);

  // Switch on the LED if an 1 was received as first character
  if ((char)payload[0] == '1') {
    digitalWrite(ONBOARDLED_PIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
    // but actually the LED is on; this is because
    // it is acive low on the ESP-01)
  } else if ((char)payload[0] == '0') {
    digitalWrite(ONBOARDLED_PIN, HIGH);  // Turn the LED off by making the voltage HIGH
  } else if ((char)payload[0] == '+') {
                   irsend.sendNEC(0x1EE17887, 32); //or 16 bit?
                   Serial.println("VOL UP");
  } else if ((char)payload[0] == '-') {
                   irsend.sendNEC(0x1EE1F807, 32);
                   Serial.println("VOL DOWN");
  } else if ((char)payload[0] == 'P') {
                   irsend.sendNEC(0x1EE133CC, 32);
                   Serial.println("PWR TOGGLE");



Can Strings or strings be stored in an array alongside "Ox1EE17887" format hex codes, and the hex codes still be pulled out and reformatted efficiently to be sent to the irsend.sendNEC() function?


Assuming you are using the IR Send library from https://www.pjrc.com/teensy/td_libs_IRremote.html then the issue is that the sendNEC function needs a number (0x1EE133CC is the the hex representation of the decimal number 518075340) not a string as you have supplied. 

It may be easier to store the codes as two arrays so you lookup the input string in one and read the result in the other.

Code: [Select]
String cmds[122] = {

unsigned long codes[122] = {

for (int i = 0; i < length; i++) {
    if (msgString == cmds[i]) {
      irsend.sendNEC(codes[i], 32);

Alternatively you could use an array of structs (http://forum.arduino.cc/index.php?topic=43587.0)


Thanks man! I ended up cobbling together something which seems to be working, I'll try to throw the code up when I get a chance. Hope it might help someone.

Go Up