I want to upload/pubish RAW IR Code to MQTT server received through my ESP8266. I have received the following RAW IR code from the Television using the IR receiver sensor:
RAW IR CODE = {
4650,4250, 700,1550, 650,1550, 700,1550, 650,450,
650,500, 600,500, 600,500, 600,550, 550,1700, 550,
1650, 600,1650, 550,550, 600,500, 600,550, 550,550,
600,500, 600,550, 550,1650, 600,550, 550,550, 600,500,
600,550, 550,550, 600,500, 600,1650, 600,500, 600,1650,
550,1700, 550,1650, 600,1650, 550,1650, 600,1650, 600
}
I want to create a new variable with the following structure:
value = RAW IR CODE+";" + "ESP8266-01"(This is the ID of the esp8266)
value = {
4650,4250, 700,1550, 650,1550, 700,1550, 650,450, 650,500,
600,500, 600,500, 600,550, 550,1700, 550,1650, 600,1650, 550,550,
600,500, 600,550, 550,550, 600,500, 600,550, 550,1650, 600,550,
550,550, 600,500, 600,550, 550,550, 600,500, 600,1650, 600,500,
600,1650, 550,1700, 550,1650, 600,1650, 550,1650, 600,1650,
600
}; ESP8266-01
I am unsure: which data type do I need to save the variable value so that it can later be retrieved/subscribed and sent to another IR sender using irsend.sendRaw
, because I want to split the variable "value" into 2 parts after receiving it, the ID and the RAW code. After getting the RAW code, I want to use the irsend.sendRaw
(RAW CODE, length of RAW , 38).
Could someone help me?
My attempts:
At first I tried to save it as a string, so that it can be retrieved and separated for irsend.sendRaw
. However I am unable to compile it.
This is the code which I used to upload:
/*
* IRremoteESP8266: IRServer - MQTT IR server
* An IR LED must be connected to ESP8266 RX port (GPIO-3)
* An IR receiver to GPIO 0
* used library:
* https://github.com/markszabo/IRremoteESP8266
*/
#include <WiFiClient.h>
#include <ESP8266WiFi.h>
#include <IRremoteESP8266.h>
#include <PubSubClient.h>
int RECV_PIN = 0; //an IR detector/demodulator is connected to GPIO pin 0
IRrecv irrecv(RECV_PIN);
decode_results results;
const char* ssid = "MY-SSID";
const char* password = "MY-WIFI-PSK";
const char* topicRaportPrefix = "esp8266/02/info/";
const char* topicSubscribe = "esp8266/02/sender/#";
const char* topicPrefix = "esp8266/02/";
const char* mqtt_server = "10.10.10.10";
const char* mqtt_user = "mqtt_user";
const char* mqtt_pass = "mqtt_pass";
String clientName; // MQTT client name
char message_buff[100];
void dump(decode_results *results) {
const int count = results->rawlen;
Serial.println(c);
c++;
Serial.println("For IR Remote ");
for (int i = 1; i < count; i++) {
if ((i % 2) == 1) {
Serial.print("+");
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
uint16_t raw_ir_code[count] = results->rawbuf[i]*USECPERTICK;
client.publish( "esp8266/02/sender", raw_ir_code);
After doing the changes proposed, I still get an error in compiling:
no matching function for call to 'PubSubClient::publish(const char [18], uint16_t [(int)count])'