Control de aire acondicionado con esp8266

Hola, muchas gracias de ante mano.
Estoy tratando de controlar un aire acondicionado Surrey que utiliza un control remoto universal, viendo otro post antiguo vi un codigo para recibir y lo que obtengo en el puerto serie es :

Timestamp : 000119.935
Library   : v2.6.5

Encoding  : UNKNOWN
Code      : 5A24EFD8 (46 bits)
Raw Timing[91]:
   +  8984, -  4362,    +   614, -   566,    +   616, -   566,    +   616, -  1604, 
   +   616, -   566,    +   616, -  1604,    +   614, -   568,    +   616, -   566, 
   +   616, -   564,    +   616, -   566,    +   616, -  1604,    +   614, -   566, 
   +   614, -  1604,    +   616, -  1602,    +   616, -   566,    +   616, -  1604, 
   +   614, -   566,    +   616, -   566,    +   616, -   566,    +   614, -   566, 
   +   640, -   542,    +   616, -   564,    +   616, -   566,    +   616, -   566, 
   +   614, -   566,    +   616, -   566,    +   614, -   566,    +   640, -   542, 
   +   614, -   566,    +   616, -   568,    +   614, -   566,    +   616, -   566, 
   +   640, -   540,    +   614, -   568,    +   614, -   566,    +   614, -   566, 
   +   616, -   566,    +   616, -   564,    +   616, -   566,    +   614, -   566, 
   +   636, -   546,    +   616, -   566,    +   616, -  1604,    +   638, -  1582, 
   +   616, -   566,    +   616

uint16_t rawData[91] = {8984, 4362,  614, 566,  616, 566,  616, 1604,  616, 566,  616, 1604,  614, 568,  616, 566,  616, 564,  616, 566,  616, 1604,  614, 566,  614, 1604,  616, 1602,  616, 566,  616, 1604,  614, 566,  616, 566,  616, 566,  614, 566,  640, 542,  616, 564,  616, 566,  616, 566,  614, 566,  616, 566,  614, 566,  640, 542,  614, 566,  616, 568,  614, 566,  616, 566,  640, 540,  614, 568,  614, 566,  614, 566,  616, 566,  616, 564,  616, 566,  614, 566,  636, 546,  616, 566,  616, 1604,  638, 1582,  616, 566,  616};  // UNKNOWN 5A24EFD8

cuando quiero enviar , el programa me compila pero el aire no enciende. queria saber si ven algo que este haciendo mal. pego el codigo de envio:

#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>

const uint16_t kIrLed = 4;  

IRsend irsend(kIrLed);

uint16_t rawData[91] = {8984, 4362,  614, 566,  616, 566,  616, 1604,  616, 566,  616,
 1604,  614, 568,  616, 566,  616, 564,  616, 566,  616, 1604,  614, 566,  614, 1604,
 616, 1602,  616, 566,  616, 1604,  614, 566,  616, 566,  616, 566,  614, 566,  640,
 542,  616, 564,  616, 566,  616, 566,  614, 566,  616, 566,  614, 566,  640, 542,
 614, 566,  616, 568,  614, 566,  616, 566,  640, 540,  614, 568,  614, 566,  614,
 566,  616, 566,  616, 564,  616, 566,  614, 566,  636, 546,  616, 566,  616, 1604,
 638, 1582,  616, 566,  616};  // UNKNOWN 5A24EFD8

void setup() {
  irsend.begin();
  Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
}
void loop() {
  Serial.println("a rawData capture from IRrecvDumpV2");
  irsend.sendRaw(rawData, 91, 38);
  delay(2000);
}

Que son los + y - del primer código?

Puedes poner el código con el que lees el comando?
También haz una referencia a las librerías usando etiquetas por favor.

Ese es el codigo de el receptor:

 * This code is left only for legacy reasons, and as another simple example of
 * how to use the IRremoteESP8266 library.
 *
 * As of November 2017 it will no longer be updated or supported.
 * You have been warned.
 ***** DEPRECATED - DO NOT USE *****
 *
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.2 Oct 2017
 * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009,
 * 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 <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRrecv.h>
#include <IRutils.h>

// an IR detector/demodulator is connected to GPIO pin 2
uint16_t RECV_PIN = 2;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() {
  Serial.begin(115200);
  irrecv.enableIRIn();  // Start the receiver
}

void dump(decode_results *results) {
  // Dumps out the decode_results structure.
  // Call this after IRrecv::decode()
  uint16_t 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 == RC5X) {
    Serial.print("Decoded RC5X: ");
  } else if (results->decode_type == RC6) {
    Serial.print("Decoded RC6: ");
  } else if (results->decode_type == RCMM) {
    Serial.print("Decoded RCMM: ");
  } else if (results->decode_type == PANASONIC) {
    Serial.print("Decoded PANASONIC - Address: ");
    Serial.print(results->address, 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: ");
  } else if (results->decode_type == NIKAI) {
    Serial.print("Decoded Nikai: ");
  }
  serialPrintUint64(results->value, 16);
  Serial.print(" (");
  Serial.print(results->bits, DEC);
  Serial.println(" bits)");
  Serial.print("Raw (");
  Serial.print(count, DEC);
  Serial.print("): {");

  for (uint16_t i = 1; i < count; i++) {
    if (i % 100 == 0)
      yield();  // Preemptive yield every 100th entry to feed the WDT.
    if (i & 1) {
      Serial.print(results->rawbuf[i] * kRawTick, DEC);
    } else {
      Serial.print(", ");
      Serial.print((uint32_t) results->rawbuf[i] * kRawTick, DEC);
    }
  }
  Serial.println("};");
}

void loop() {
  if (irrecv.decode(&results)) {
    dump(&results);
    Serial.println("DEPRECATED: Please use IRrecvDumpV2.ino instead!");
    irrecv.resume();  // Receive the next value
  }
}

No entiendo lo de las etiquetas de las librerias como se hace. disculpa

No entiendo lo de las etiquetas de las librerias como se hace. disculpa

Leíste las normas?
Todo el tiempo habla de etiquetas que serían como hipervínculos para los enlaces de hecho usas la etiqueta para códigos y lo has hecho correctamente.

Estas recibiendo un código RAW o sea sin protocolo de alguna marca.
la pregunta es: cómo te aseguras que estas emitiendo algun código IR?

hola! Conseguiste solucionar el problema? yo tengo el mismo problema y no consigo resolverlo.

Saludos.

No se contactó nunca mas de modo que no lo sabremos. Qué has hecho tu?

Pues lo conseguí. Tengo un programa para leer los códigos y otro para emitirlos. Ahora me gustaría poder colocar varios emisores para controlar varios aires acondicionados (sala, cocina, cuartos...).

Os dejo el link con mi post con los programas que utilicei. Espero que sirva de ajuda.

https://forum.arduino.cc/index.php?topic=650373.0

Esto es doble posteo porque tienes un hilo abierto como IRremote com varios emisores IR asi que sigue en el otro hilo por favor y deja de consultar aquí.
El dueÑo de este hilo seguirá en su momento y estas consultas puedo moverlas a tu hilo si quieres.
Responde por privado.

Encontre el error y una posible solucion la cual paso a comentar. Probe utilizando una arduino mega con el siguente codigo

#include <IRremote.h>

IRsend irsend;

void setup()
{

}

void loop() {
  int khz = 38; // 38kHz carrier frequency for the NEC protocol
  unsigned int  rawDataprender[91] = {8800,4500, 500,650, 550,600, 500,1800, 500,650, 500,1750, 550,650, 500,650, 500,650, 500,650, 500,1800, 500,650, 550,600, 500,1750, 550,650, 500,1750, 550,1750, 500,650, 550,1700, 550,600, 550,1750, 500,650, 550,650, 500,1750, 550,1700, 550,650, 500,650, 500,1750, 550,650, 500,1750, 550,600, 500,1800, 500,650, 550,600, 550,1750, 500,1750, 550,600, 500,650, 550,1750, 500,650, 550,600, 550,1750, 500,650, 500,650, 550,650, 500};  // AIWA_RC_T501 FFFFACDB
  unsigned int  rawDataapagar[91] = {8800,4500, 550,600, 500,650, 550,1750, 550,600, 550,650, 500,600, 550,650, 500,650, 500,650, 550,1750, 550,600, 500,650, 500,1800, 500,650, 500,1750, 550,1750, 500,650, 500,1750, 550,650, 500,650, 500,1750, 550,1750, 500,650, 500,650, 550,1750, 500,650, 500,650, 550,600, 500,1800, 500,650, 500,650, 550,1750, 550,1700, 550,600, 500,650, 550,1750, 500,650, 550,650, 500,600, 550,650, 500,650, 500,1800, 500,650, 500,650, 500};  // AIWA_RC_T501 FFFFB37D

  irsend.sendRaw(rawDataprender, 91, khz); //Note the approach used to automatically calculate the size of the array.

  delay(10000); //In this example, the signal will be repeated every 5 seconds, approximately.

    irsend.sendRaw(rawDataapagar, 91, khz); //Note the approach used to automatically calculate the size of the array.

  delay(1000); //In this example, the signal will be repeated every 5 seconds, approximately.
}

Y funciona perfectamente. Cuando paso el codigo a la placa Wemos D1 mini armo el siguiente codigo

#include <IRremoteESP8266.h>  //this might be IRremote.h for you
#include <IRsend.h> //you might not need this

const uint16_t kRecvPin = 4;

IRsend irsend(kRecvPin); // this is pin D2 on my esp

void setup()
{

}

void loop() {
  int khz = 38; // 38kHz carrier frequency for the NEC protocol
  unsigned int  rawDataprender[91] = {8800,4500, 500,650, 550,600, 500,1800, 500,650, 500,1750, 550,650, 500,650, 500,650, 500,650, 500,1800, 500,650, 550,600, 500,1750, 550,650, 500,1750, 550,1750, 500,650, 550,1700, 550,600, 550,1750, 500,650, 550,650, 500,1750, 550,1700, 550,650, 500,650, 500,1750, 550,650, 500,1750, 550,600, 500,1800, 500,650, 550,600, 550,1750, 500,1750, 550,600, 500,650, 550,1750, 500,650, 550,600, 550,1750, 500,650, 500,650, 550,650, 500};  // AIWA_RC_T501 FFFFACDB
  unsigned int  rawDataapagar[91] = {8800,4500, 550,600, 500,650, 550,1750, 550,600, 550,650, 500,600, 550,650, 500,650, 500,650, 550,1750, 550,600, 500,650, 500,1800, 500,650, 500,1750, 550,1750, 500,650, 500,1750, 550,650, 500,650, 500,1750, 550,1750, 500,650, 500,650, 550,1750, 500,650, 500,650, 550,600, 500,1800, 500,650, 500,650, 550,1750, 550,1700, 550,600, 500,650, 550,1750, 500,650, 550,650, 500,600, 550,650, 500,650, 500,1800, 500,650, 500,650, 500};  // AIWA_RC_T501 FFFFB37D
  irsend.sendRaw(rawDataprender, 91, khz); //Note the approach used to automatically calculate the size of the array.

  delay(10000); //In this example, the signal will be repeated every 5 seconds, approximately.

    irsend.sendRaw(rawDataapagar, 91, khz); //Note the approach used to automatically calculate the size of the array.

  delay(1000); //In this example, the signal will be repeated every 5 seconds, approximately.
}

y lo unico que cambia ademas de la libreria que logicamente tiene que cambiar porque no es compatible sino, es el const uint16_t por unsigned int.
Alguien tendra una idea. el mensaje de error al compilar es no known conversion for argument 1 from 'unsigned int [91]' to 'uint16_t* {aka short unsigned int*}' y cuando cambio a uint16_t compila bien pero el aire acondicionado no hace nada

IRremote para AVR es una cosa y IRremoteESP8266 es basicamente otra cosa porque los Timers son diferentes.

Asi que debes asegurarte de usar el pin adecuado en el Wemos.

Controlalo con un osciloscopio a ver si ves la diferencia entre al Avr y el Esp

No tengo la suerte de tener un osciloscopio, pero lo que hice fue, conectar el receptor infrarrojo en el Arduino uno y el emisor infrarrojo en el senos y los códigos que me da son diferentes al del control remoto, pero los que estoy enviando son los mismos . Para mi tiene que ver qué no me deja enviar unsigned int

Esta librería IRremoteESP8266 de donde la obtengo, del gestor de librerías?
Si no es así coloca el enlace para poder probar tu código. Se debe probar con lo mismo que usas en tu caso o no repetiremos el problema.

Te paso el link de la librería http://downloads.arduino.cc/libraries/github.com/markszabo/IRremoteESP8266-2.7.1.zip

También se me ocurre que puede que como en la wemos se utiliza el gpio4 o D2 y en la Arduino mega un puerto ya definido por la librería, pueda llegar a ser el error

Listo ahora compilo tu código y veo que ocurre con la compilación.

Luego edito y respondo en este mismo hilo.

Primero tomé el ejemplo nodemcuV2.ino y este fue el resultado

Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"

DATA: [==== ] 43.2% (used 35400 bytes from 81920 bytes)

PROGRAM: [= ] 6.3% (used 265602 bytes from 4194304 bytes)

======================== [SUCCESS] Took 28.15 seconds ========================

Environment Status Duration


megaatmega2560 IGNORED

nodemcuv2 SUCCESS 00:00:28.152

========================= 1 succeeded in 00:00:28.152 =========================

[12/09/19 08:47:52]

Obviamente es una librería para Platformio o eso creo.
Compilada con Nodemcu 1.0 no da problemas.

Ahora la tuya.

Cambia estas lineas y no deberías tener problemas

uint16_t khz 					= 38; // 38kHz carrier frequency for the NEC protocol
  uint16_t rawDataprender[91] 	= {8800,4500, 500,650, 550,600, 500,1800, 500,650, 500,1750, 550,650, 500,650, 500,650, 500,650, 500,1800, 500,650, 550,600, 500,1750, 550,650, 500,1750, 550,1750, 500,650, 550,1700, 550,600, 550,1750, 500,650, 550,650, 500,1750, 550,1700, 550,650, 500,650, 500,1750, 550,650, 500,1750, 550,600, 500,1800, 500,650, 550,600, 550,1750, 500,1750, 550,600, 500,650, 550,1750, 500,650, 550,600, 550,1750, 500,650, 500,650, 550,650, 500};  	// AIWA_RC_T501 FFFFACDB
  uint16_t rawDataapagar[91] 	= {8800,4500, 550,600, 500,650, 550,1750, 550,600, 550,650, 500,600, 550,650, 500,650, 500,650, 550,1750, 550,600, 500,650, 500,1800, 500,650, 500,1750, 550,1750, 500,650, 500,1750, 550,650, 500,650, 500,1750, 550,1750, 500,650, 500,650, 550,1750, 500,650, 500,650, 550,600, 500,1800, 500,650, 500,650, 550,1750, 550,1700, 550,600, 500,650, 550,1750, 500,650, 550,650, 500,600, 550,650, 500,650, 500,1800, 500,650, 500,650, 500};  		// AIWA_RC_T501 FFFFB37D
  irsend.sendRaw(rawDataprender, 91, khz); //Note the approach used to automatically calculate the size of the array.

Gracias por tu tiempo, cuando termine de trabajar voy a probar el codigo. Muchas gracias, modifico este hilo cuando tenga resultados.

Quedo perfecto funcionando, muchas gracias. Se puede dar como Solucionado.

Para terminar, adjunto todo mi proyecto , que es el proyecto final de mi carrera de ingenieria en telecomunicaciones en Argentina. Conciste en controlar una puerta de acceso, las luces por rele y el aire acondicionado ademas de verificar temperatura y humedad cada 6 segundos.Esta conectado por MQTT a un servidor el cual escucha topicos y escribe por los mismos y nos permitio hacer la conexion con la aplicacion MQTTDASHBOARD disponible para android.

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
#define DHTPIN D7
#define DHTTYPE DHT11 
DHT dht(DHTPIN, DHTTYPE);
// Connect to the WiFi

const char* ssid = 
const char* password =
//connect to the server MQTT
const char* mqtt_server =
const int mqttPort = 14218;
const char* mqttUser = "xknjnxuo";
const char* mqttPassword = 
unsigned long interval=60000; // the time we need to wait
unsigned long previousMillis=0; // millis() returns an unsigned long.
//Connect to IR
const uint16_t kIrLed = 4;  // ESP8266 GPIO pin to use. Recommended: 4 (D1).
IRsend irsend(kIrLed);  // Set the GPIO to be used to sending the message. 
uint16_t khz           = 38; // 38kHz carrier frequency for the NEC protocol
uint16_t rawDataapagar[91]  = {8800,4500, 550,600, 500,650, 550,1750, 550,600, 550,650, 500,600, 550,650, 500,650, 500,650, 550,1750, 550,600, 500,650, 500,1800, 500,650, 500,1750, 550,1750, 500,650, 500,1750, 550,650, 500,650, 500,1750, 550,1750, 500,650, 500,650, 550,1750, 500,650, 500,650, 550,600, 500,1800, 500,650, 500,650, 550,1750, 550,1700, 550,600, 500,650, 550,1750, 500,650, 550,650, 500,600, 550,650, 500,650, 500,1800, 500,650, 500,650, 500};     // AIWA_RC_T501 FFFFB37D
uint16_t rawDataprender[91] = {8800,4500, 500,650, 550,600, 500,1800, 500,650, 500,1750, 550,650, 500,650, 500,650, 500,650, 500,1800, 500,650, 550,600, 500,1750, 550,650, 500,1750, 550,1750, 500,650, 550,1700, 550,600, 550,1750, 500,650, 550,650, 500,1750, 550,1700, 550,650, 500,650, 500,1750, 550,650, 500,1750, 550,600, 500,1800, 500,650, 550,600, 550,1750, 500,1750, 550,600, 500,650, 550,1750, 500,650, 550,600, 550,1750, 500,650, 500,650, 550,650, 500};    // AIWA_RC_T501 FFFFACDB
uint16_t  rawDatabajar[91]  = {8800,4550, 500,650, 500,650, 550,1750, 500,650, 500,1750, 500,650, 550,650, 500,650, 500,650, 550,1700, 550,650, 500,1750, 550,650, 500,650, 500,1750, 550,1700, 550,650, 500,650, 500,650, 550,650, 500,600, 550,650, 500,650, 500,650, 550,650, 500,600, 550,650, 500,650, 500,650, 550,650, 500,600, 550,650, 500,650, 500,650, 550,650, 500,600, 550,650, 500,650, 500,650, 550,650, 500,1750, 500,1750, 500,650, 550,1750, 500};  // AIWA_RC_T501 FFFFFFF9
uint16_t  rawDatasubir[91]  = {8750,4550, 500,650, 500,650, 500,1800, 500,650, 500,1750, 550,600, 550,650, 500,650, 500,650, 500,1800, 500,600, 550,1750, 500,650, 550,1750, 500,650, 500,650, 550,600, 550,650, 500,650, 500,650, 500,650, 550,600, 550,650, 500,650, 500,650, 500,650, 550,600, 550,600, 550,650, 500,650, 500,650, 550,600, 500,650, 550,650, 500,650, 500,650, 550,600, 500,650, 550,650, 500,650, 500,1800, 500,1750, 550,600, 500,650, 550};  // AIWA_RC_T501 FFFFFFF9

WiFiClient espClient;
PubSubClient client(espClient);


void callback(char* topic, byte* payload, unsigned int length) {
 Serial.print("Message arrived [");
 Serial.print(topic);
 Serial.print("]");
 for (int i=0;i<length;i++) {
  char receivedChar = (char)payload[i];
  Serial.print(receivedChar);
  if (strcmp(topic, "Luces") == 0){
  if (receivedChar == '0' )
   { digitalWrite(D5, LOW);  }
  if (receivedChar == '1')
   { digitalWrite(D5, HIGH); }
  }
  if (strcmp(topic, "Puerta") == 0){
  if (receivedChar == '0' )
   { digitalWrite(D4, LOW);  }
  if (receivedChar == '1')
   { digitalWrite(D4, HIGH); }
  }
  if (strcmp(topic, "Aire") == 0){
  if (receivedChar == '0' )
   {irsend.sendRaw(rawDataapagar, 91, khz);
   Serial.print("Apagando Aire");
   }
  if (receivedChar == '1')
   {irsend.sendRaw(rawDataprender, 91, khz);
   Serial.print("Enciendo Aire");
   }
   if (receivedChar == '2' )
   {irsend.sendRaw(rawDatasubir, 91, khz);
   Serial.print("Subir 1 grado aire");
   }
  if (receivedChar == '3')
   {irsend.sendRaw(rawDatabajar, 91, khz);
   Serial.print("Bajar 1 grado aire");
   }
  }
  Serial.println();
  }
  }
 
 
void reconnect() {
 // Loop until we're reconnected
 while (!client.connected()) {
 Serial.print("Attempting MQTT connection...");
 if (client.connect("ESP8266 Client",mqttUser,mqttPassword)) {
  Serial.println("connected");
  client.subscribe("Luces");
  client.subscribe("Temperatura");
  client.subscribe("Puerta");
  client.subscribe("Aire");
 } else {
  Serial.print("failed, rc=");
  Serial.print(client.state());
  Serial.println(" try again in 5 seconds");
  delay(5000);
  }
 }
}
 
void setup()
{  
 irsend.begin();
 Serial.begin(9600);
 client.setServer(mqtt_server, mqttPort);
 client.setCallback(callback);
 setup_wifi();
 dht.begin();
 pinMode(D5,OUTPUT);
 pinMode(D4,OUTPUT);
}

void setup_wifi() {

  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}
 
void loop()
{ unsigned long currentMillis = millis();
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  char result[8];

  if ((unsigned long)(currentMillis - previousMillis) >= interval) {
          int sensorValue = 0;
          int sensorPin = A0;
          String Temp ="";
          sensorValue = analogRead(sensorPin); 
          if (isnan(h) || isnan(t)) 
          {
          Serial.println("Failed to read from DHT sensor!");
          return;
          }
           Serial.println(sensorValue, DEC);
           Serial.print("Temperatura: ");
           Serial.print(t);
           Serial.print("Humedad: ");
           Serial.print(h);
           if (sensorValue >= 800){
           client.publish("Luces","1");
            }
           if (sensorValue <= 800){
           client.publish("Luces","0");
           }
         client.publish("Temperatura",dtostrf(t, 6, 2, result)); 
   previousMillis = millis();
 }    
           if (!client.connected()) {
           reconnect();
           }
  
 client.loop();
}

Saludos y muchas gracias por la ayuda.