質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.47%
Arduino

Arduinoは、AVRマイコン、単純なI/O(入出力)ポートを備えた基板、C言語を元としたArduinoのプログラム言語と、それを実装した統合開発環境から構成されたシステムです。

Q&A

解決済

1回答

4820閲覧

ボードESP32 Dev Moduleに対するコンパイル時にエラーが発生しました

robotKR

総合スコア32

Arduino

Arduinoは、AVRマイコン、単純なI/O(入出力)ポートを備えた基板、C言語を元としたArduinoのプログラム言語と、それを実装した統合開発環境から構成されたシステムです。

0グッド

0クリップ

投稿2021/04/25 12:27

困っていること

Arduino IDE (Windows10 PC)にて,ESP32に書き込むプログラムのコンパイルをしています.

このプログラムをコンパイルするとエラーが出てきてしまいます。
原因が分からず困っています。

Arduino:1.8.13 (Windows 10), ボード:"ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"

エラーメッセージ

C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp: In member function 'unsigned char fauxmoESP::addDevice(const char*)': C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:345:80: error: format '%X' expects argument of type 'unsigned int', but argument 5 has type 'long unsigned int' [-Werror=format=] snprintf_P(uuid, sizeof(uuid), PSTR("%02X%06X46584D\0"), device_id, chip_id); // DEV_ID + CHIPID + "FXM" ^ C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:345:80: error: embedded '\0' in format [-Werror=format-contains-nul] C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:345:80: error: format '%X' expects argument of type 'unsigned int', but argument 5 has type 'long unsigned int' [-Werror=format=] C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:345:80: error: embedded '\0' in format [-Werror=format-contains-nul] C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:350:46: error: format '%X' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Werror=format=] sprintf(serial, "221703K0%06X\0", chip_id); // "221703K0" + CHIPID ^ C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:350:46: error: embedded '\0' in format [-Werror=format-contains-nul] C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:350:46: error: format '%X' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Werror=format=] C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:350:46: error: embedded '\0' in format [-Werror=format-contains-nul] C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp: In member function 'bool fauxmoESP::renameDevice(unsigned char, const char*)': C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:370:11: warning: comparison is always true due to limited range of data type [-Wtype-limits] if (0 <= id && id <= _devices.size()) { ^ C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp: In member function 'char* fauxmoESP::getDeviceName(unsigned char, char*, size_t)': C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:380:11: warning: comparison is always true due to limited range of data type [-Wtype-limits] if (0 <= id && id <= _devices.size()) { ^ C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp: In member function 'void fauxmoESP::setState(unsigned char, bool)': C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:387:11: warning: comparison is always true due to limited range of data type [-Wtype-limits] if (0 <= id && id <= _devices.size()) { ^ cc1plus.exe: some warnings being treated as errors 「WiFi.h」に対して複数のライブラリが見つかりました 使用済:C:\Users\kaika\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\WiFi 未使用:D:\Program Files (x86)\Arduino\libraries\WiFi 次のフォルダのライブラリWiFiバージョン1.0を使用中:C:\Users\kaika\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\WiFi 次のフォルダのライブラリxoseperez-fauxmoesp-985880034f3aバージョン2.4.4を使用中:C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a 次のフォルダのライブラリAsyncTCP-masterバージョン1.1.1を使用中:C:\Arduino sketch\Arduino\libraries\AsyncTCP-master exit status 1 ボードESP32 Dev Moduleに対するコンパイル時にエラーが発生しました。

プログラム

C++

1#include <Arduino.h> 2#include <WiFi.h> 3#include "fauxmoESP.h" 4#define SERIAL_BAUDRATE 115200 5#define LED 2 6 7fauxmoESP fauxmo; 8 9char ssid[] = ""; 10char password[] = ""; 11 12// ----------------------------------------------------------------------------- 13// Wifi 14// ----------------------------------------------------------------------------- 15 16void wifiSetup() { 17 18 // Set WIFI module to STA mode 19 WiFi.mode(WIFI_STA); 20 21 // Connect 22 Serial.printf("[WIFI] Connecting to %s ",ssid); 23 WiFi.begin(ssid, password); 24 25 // Wait 26 while (WiFi.status() != WL_CONNECTED) { 27 Serial.print("."); 28 delay(100); 29 } 30 Serial.println(); 31 32 // Connected! 33 Serial.printf("[WIFI] STATION Mode, SSID: %s, IP address: %s\n", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str()); 34 35} 36 37void setup() { 38 39 // Init serial port and clean garbage 40 Serial.begin(SERIAL_BAUDRATE); 41 Serial.println(); 42 Serial.println(); 43 44 // Wifi 45 wifiSetup(); 46 47 // LED 48 pinMode(LED, OUTPUT); 49 digitalWrite(LED, HIGH); 50 51 // You have to call enable(true) once you have a WiFi connection 52 // You can enable or disable the library at any moment 53 // Disabling it will prevent the devices from being discovered and switched 54 fauxmo.enable(true); 55 56 // Add virtual devices 57 fauxmo.addDevice("照明"); 58 59 // fauxmoESP 2.0.0 has changed the callback signature to add the device_id, 60 // this way it's easier to match devices to action without having to compare strings. 61 fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state) { 62 Serial.printf("[MAIN] Device #%d (%s) state: %s\n", device_id, device_name, state ? "ON" : "OFF"); 63 digitalWrite(LED, state); 64 }); 65 66 // Callback to retrieve current state (for GetBinaryState queries) 67 fauxmo.onGetState([](unsigned char device_id, const char * device_name) { 68 return digitalRead(LED); 69 }); 70 71} 72 73void loop() { 74 75 // Since fauxmoESP 2.0 the library uses the "compatibility" mode by 76 // default, this means that it uses WiFiUdp class instead of AsyncUDP. 77 // The later requires the Arduino Core for ESP8266 staging version 78 // whilst the former works fine with current stable 2.3.0 version. 79 // But, since it's not "async" anymore we have to manually poll for UDP 80 // packets 81 fauxmo.handle(); 82 83 static unsigned long last = millis(); 84 if (millis() - last > 5000) { 85 last = millis(); 86 Serial.printf("[MAIN] Free heap: %d bytes\n", ESP.getFreeHeap()); 87 } 88 89}

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

error: format '%X' expects argument of type 'unsigned int', but argument 5 has type 'long unsigned int' [-Werror=format=]

google翻訳
エラー:フォーマット '%X'はタイプ 'unsigned int'の引数を期待していますが、引数5のタイプは 'long unsigned int'です

ということです。
まずはこれをどうにかしましょう

投稿2021/04/25 22:20

y_waiwai

総合スコア87784

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.47%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問