Arduino 資料一覧

SOCINNO「IoT電子工作 スマートリモコン製作キット」をUbuntu 18.04で使う場合の追加作業

2019/07/07更新

対応バージョン: Arduino IDE 1.8.9 + Ubuntu 18.04

株式会社SOCINNOが提供する「IoT電子工作 スマートリモコン製作キット」は基礎からWi-Fi利用、クラウド接続まで順を追って丁寧に解説されている秀逸な教材である。

このキットをArduino IDE 1.8.9 + Ubuntu 18.04環境で使う際にいくつか追加で作業する必要があったので補足する。

以下、同キット向けのIoT電子工作ガイドの章立てに沿って説明する。

2-1 電子部品利用 > LED点滅

スケッチコンパイルエラー

スケッチコンパイル時に以下のようなエラーが発生する場合。

:
Pyserial is not installed for /usr/bin/python. Check the README for installation instructions.Traceback (most recent call last):

  File "/home/neo/.arduino15/packages/esp32/tools/esptool_py/2.6.1/esptool.py", line 37, in <module>
    import serial

ImportError: No module named serial
exit status 1
Error compiling for board ESP32 Dev Module.

python-serialパッケージをインストールすればエラーが発生しなくなる。

$ sudo apt install python-serial

2-3 電子部品利用 > 温湿度センサ

スケッチコンパイルエラー

スケッチコンパイル時に以下のようなエラーが発生する場合。

:
In file included from /home/ard/Arduino/libraries/DHT_sensor_library/DHT_U.cpp:22:0:
/home/ard/Arduino/libraries/DHT_sensor_library/DHT_U.h:25:29: fatal error: Adafruit_Sensor.h: No such file or directory
 #include <Adafruit_Sensor.h>

                             ^
compilation terminated.
Using library DHT_sensor_library at version 1.3.4 in folder: /home/ard/Arduino/libraries/DHT_sensor_library 
exit status 1
Error compiling for board ESP32 Dev Module.

ライブラリマネージャから「Adafruit Unified Sensor」をインストールすればエラーが発生しなくなる。

3-2 Wi-Fi利用 > Webサーバ機能

スケッチコンパイルエラー

スケッチコンパイル時に以下のようなエラーが発生する場合。

:
Multiple libraries were found for "WiFi.h"
Blink:2:31: error: ESPAsyncWebServer.h: No such file or directory
compilation terminated.
 Used: /home/ard/.arduino15/packages/esp32/hardware/esp32/1.0.2/libraries/WiFi
 Not used: /home/ard/opt/arduino-1.8.9/libraries/WiFi
exit status 1
ESPAsyncWebServer.h: No such file or directory

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

以下の2つをダウンロードして[Sketch] > [Include Library] > [Add .ZIP Library...]でそれぞれインストールすればエラーが発生しなくなる。

DHCPサーバ利用

IPアドレス情報をDHCPサーバから動的に受け取る場合は以下のIPアドレス設定は不要。(以降の章も同様)

IPAddress ip(192, 168, 1, 123);     // IPアドレス(本機が利用するIP)
IPAddress gateway(192, 168, 1, 1);  // デフォルトゲートウェイ
IPAddress subnet(255, 255, 255, 0); // サブネットマスク
:
void setup() {
:
  WiFi.config( ip, gateway, subnet );
:

4-2 データ利用 > SPIFFSによるファイル操作

SPIFFSマウントエラー

プログラム実行時に以下のようなエラーが発生する場合。

E (36) SPIFFS: mount failed, -10025

SPIFFS.hだけでなくFS.hもincludeすればエラーが発生しなくなる。

#include <FS.h> <--- 追加
#include <SPIFFS.h>

それ以降

上記の対応を経て、無事リモコンが動作した。

リモコン設定(ON/OFF信号記録)
リモコン操作(ON/OFF信号発信)

関連記事