前提・実現したいこと
LINEからMQTTcloudを経由して、Arduinoにメッセージを送り、家のエアコンを操作するプログラムを作成しています。
Arduino側のプログラムで、IRremoteライブラリを使って、赤外線信号の送信を実装中に以下のエラーメッセージが発生しました。
色々と試しているものの行き詰ってしまい、解決策やアドバイスいただけますでしょうか。
何卒よろしくお願いいたします。
発生している問題・エラーメッセージ
error: request for member 'sendRaw' in 'irsend', which is of non-class type 'IRsend(int)'
irsend.sendRaw(heatonData, sizeof(heatonData)/sizeof(int), khz);
^
aircon-app:92:12: error: request for member 'sendRaw' in 'irsend', which is of non-class type 'IRsend(int)'
irsend.sendRaw(heatoffData, sizeof(heatoffData)/sizeof(int), khz);
^
aircon-app:94:12: error: request for member 'sendRaw' in 'irsend', which is of non-class type 'IRsend(int)'
irsend.sendRaw(defonData, sizeof(defonData)/sizeof(int), khz);
^
aircon-app:96:12: error: request for member 'sendRaw' in 'irsend', which is of non-class type 'IRsend(int)'
irsend.sendRaw(defoffData, sizeof(defoffData)/sizeof(int), khz);
^
aircon-app:98:12: error: request for member 'sendRaw' in 'irsend', which is of non-class type 'IRsend(int)'
irsend.sendRaw(aironData, sizeof(aironData)/sizeof(int), khz);
^
aircon-app💯12: error: request for member 'sendRaw' in 'irsend', which is of non-class type 'IRsend(int)'
irsend.sendRaw(airoffData, sizeof(airoffData)/sizeof(int), khz);
:
省略
:
exit status 1
request for member 'sendRaw' in 'irsend', which is of non-class type 'IRsend(int)'
該当のソースコード
C#
1#include <LiquidCrystal.h> 2#include <WiFiClientSecure.h> 3#include <PubSubClient.h> 4#include <IRremote.h> 5#include "config.h" 6#include "certificate.h" 7WiFiClientSecure wifiClient; 8PubSubClient client(wifiClient); 9 10 11IRsend irsend(const int sendPin = 26); 12 13 14int khz = 38; 15const unsigned int heatonData[100] = {3300,1700, 400,1250, 400,400, 400,450, 400,400, 400,450, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,1250, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,1300, 400,400, 400,1250, 400,1250, 400,1250, 400,1300, 400,1250, 400,1250, 400,400, 400,1300, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,450}; 16const unsigned int heatoffData[100] = {3350,1650, 400,1250, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,450, 400,400, 400,450, 400,400, 400,1250, 400,450, 400,450, 350,450, 400,450, 400,400, 400,450, 400,450, 350,450, 400,400, 400,450, 400,400, 450,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,1250, 400,400, 450,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,450, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 450,1250, 400,1250, 400,400}; 17const unsigned int defonData[100] = {3350,1650, 400,1250, 400,400, 450,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 450,400, 400,1250, 400,450, 400,400, 400,450, 400,400, 400,450, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,450, 400,400, 400,450, 400,1250, 400,400, 400,1250, 400,1300, 400,1250, 400,1250, 400,1250, 400,1250, 400,450, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1300, 400,400}; 18const unsigned int defoffData[100] = {3300,1650, 450,1250, 400,400, 400,450, 400,400, 400,450, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,1250, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 450,1250, 400,400, 400,1250, 400,1250, 400,1250, 450,1250, 400,1250, 400,1250, 400,400, 400,1300, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,450}; 19const unsigned int aironData[100] = {3300,1700, 400,1250, 400,400, 400,450, 400,400, 400,450, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,1250, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,1300, 400,400, 400,1250, 400,1250, 400,1250, 400,1300, 400,1250, 400,1250, 400,400, 400,1250, 450,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,450}; 20const unsigned int airoffData[100] = {3350,1650, 400,1250, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,450, 400,400, 400,1250, 400,450, 400,400, 400,450, 400,400, 400,450, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,400, 400,450, 400,450, 400,400, 400,450, 400,1250, 400,400, 400,1250, 400,1300, 400,1250, 400,1250, 400,1250, 400,1250, 400,450, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 400,1250, 450,1250, 400,400}; 21 22void setup() { 23 Serial.begin(115200); 24 Serial.println(); 25 WiFi.mode(WIFI_STA); 26 client.setCallback(callback); 27 client.setServer(host, port); 28} 29 30void loop() { 31 //Wifi接続 32 if (WiFi.status() != WL_CONNECTED) { 33 Serial.print("connecting to "); 34 Serial.print(ssid); 35 Serial.println("..."); 36 WiFi.begin(ssid, password); 37 38 if (WiFi.waitForConnectResult() != WL_CONNECTED) { 39 //アクセスポイントへの接続に失敗したら5秒間待ってリトライ 40 Serial.println("failed to connect"); 41 delay(5000); 42 return; 43 } else { 44 Serial.print("WiFi connected: "); 45 Serial.println(WiFi.localIP()); 46 } 47 48 wifiClient.setCACert(ca_cert); 49 } 50 51 //CloudMQTTに接続 52 if (!client.connected()) { 53 client.connect(clientID, CloudMQTT_user, CloudMQTT_pass); 54 55 if (client.connected()) { 56 Serial.println("MQTT connected"); 57 58 // トピック名を指定してsubscribe 59 client.subscribe(topic); 60 } else { 61 Serial.print("MQTT connection failed: "); 62 Serial.println(client.state()); 63 delay(5000); 64 } 65 } else { 66 // 既にサーバに接続されていれば通常処理を行う 67 client.loop(); 68 } 69} 70 71// メッセージを受け取ったらシリアルにプリント 72void callback(char* topic, byte* payload, unsigned int length) { 73 74 Serial.print("Message arrived in topic: "); 75 Serial.println(topic); 76 77 Serial.print("Message:"); 78 79 String message; 80 81 for (int i = 0; i < length; i++) { 82 message += (char)payload[i]; 83 } 84 85 Serial.println(message); 86 87 if (message == "heatOn") { 88 irsend.sendRaw(heatonData, sizeof(heatonData)/sizeof(int), khz); 89 } else if (message == "heatOff") { 90 irsend.sendRaw(heatoffData, sizeof(heatoffData)/sizeof(int), khz); 91 }else if (message == "defOn") { 92 irsend.sendRaw(defonData, sizeof(defonData)/sizeof(int), khz); 93 }else if (message == "defOff") { 94 irsend.sendRaw(defoffData, sizeof(defoffData)/sizeof(int), khz); 95 }else if (message == "airOn") { 96 irsend.sendRaw(aironData, sizeof(aironData)/sizeof(int), khz); 97 }else if (message == "airOff") { 98 irsend.sendRaw(airoffData, sizeof(airoffData)/sizeof(int), khz); 99 } 100 Serial.println(); 101 Serial.println("-----------------------"); 102}
環境
IRremoteライブラリのバージョンは2.2.3です。
https://github.com/z3t0/Arduino-IRremote
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/02/02 00:18 編集
2020/02/02 00:40
2020/02/02 06:19
2020/02/02 07:10