Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(STARWARS編)
2020/12/28:
初版
board3 Ascii STARWARS v2
board3 Ascii STARWARS v2
概要
Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(STARWARS編)
本記事は「
Wio-TerminalでWiFiで使う(その2: STARTWARS,WEB_ACCESS)
」
のStarwarsのスケッチを複数ボード対応とwio-terminalのファームウェア・バージョンアップに対応したものである。
wio-terminalのファームウェアのバージョンアップで以下の不具合も解消している。
(描画速度も大幅な改善が見られる)
一部、以下のようなATコマンドのレスポンス・ヘッダーが表示されることがある。 wifi関係のライブラリにバグがあるようだ。
+IPD,4,988,94.142.241.111,23:__|_____|___________|__|____________|_||____
+IPD,4,1460,94.142.241.111,23:
+IPD,4,1460,94.142.241.111,23: |(I/ /][][\| {}/ {} \[][][]
wio-terminalのファームウェアのアップデート方法については以下を参照のこと:
wio-terminalのファームウェア・アップデートについて(v2)(linux版)
デモ・スケッチ
src/wifi_starwars.ino
// select board
////#define WIO_TERMINAL
////#define ESP8266
////#define ESP32
////#define M5ATOM
//------------------
#ifdef M5ATOM
#include "M5Atom.h"
#define ESP32
#endif
#ifdef WIO_TERMINAL
//#include <AtWiFi.h>
#include <rpcWiFi.h>
#endif
#ifdef ESP8266
#include <ESP8266WiFi.h>
#endif
#ifdef ESP32
#include <WiFi.h>
#endif
const char* ssid = "your_ssid";
const char* passwd = "yours_passwd";
// Use WiFiClient class to create TCP connections
WiFiClient client;
void setup() {
Serial.begin(115200);
while(!Serial); // Wait for Serial to be ready
delay(1000);
// Set WiFi to station mode and disconnect from an AP if it was previously connected
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(2000);
WiFi.begin(ssid, passwd);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("Connecting to WiFi..");
}
Serial.println("Connected to the WiFi network");
Serial.print("IP Address: ");
Serial.println (WiFi.localIP()); // prints out the device's IP address
// set url for telnet
const char* host = "towel.blinkenlights.nl";
const uint16_t port = 23;
Serial.print("Connecting to ");
Serial.println(host);
while (!client.connect(host, port)) {
Serial.println("Connection failed.");
Serial.println("Waiting 5 seconds before retrying...");
delay(5000);
}
}
void loop() {
while (!client.available()) {
delay(1); //delay 1 msec
}
// no buffering for ASCII Art Animation
while (client.available()) {
char c = client.read();
Serial.write(c);
}
/***********
if (client.available() > 0) {
String line = client.readString(); // Read from the server response
Serial.print(line);
}
************/
}
wio-terminalのファームウェアのバージョン・アップにともない
以下のようにヘッダーが変更になっている:
//#include <AtWiFi.h>
#include <rpcWiFi.h>
以下の#defineでボードを切り換えているがボードの種類を設定すると、 システムで設定されている定義が有効になるので特にソースを変更する必要はない。
#define WIO_TERMINAL
#define ESP8266
#define ESP32
#define M5ATOM
以下については、自分の環境に合わせて変更すること:
const char ssid[] = "yours_ssid";
const char passwd[] = "yours_passwd";
書き込み後に「picocom /dev/ttyACM0 -b115200」または「picocom /dev/ttyUSB0 -b115200」で通信ソフトを起動すると以下のような出力が表示される:
(M5Atomの場合、実行時にリセット・ボタンを押す必要があるようだ)
$ picocom /dev/ttyACM0 -b115200
#以下のようなAsciiArtのアニメが実行される:
........... @@@@@ @@@@@ ...........
.......... @ @ @ @ ..........
........ @@@ @ @ ..........
....... @@ @ @ .........
...... @@@@@@@ @@@@@ th ........
..... ----------------------- .......
.... C E N T U R Y .......
... ----------------------- .....
.. @@@@@ @@@@@ @ @ @@@@@ ...
== @ @ @ @ @ ==
__||__ @ @@@@ @ @ __||__
| | @ @ @ @ @ | |
_________|______|_____ @ @@@@@ @ @ @ _____|______|_________
platformio.ini
platformio.iniは、ボードに合わせて以下を使用する:
wio-terminalの場合:
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:seeed_wio_terminal]
platform = atmelsam
board = seeed_wio_terminal
framework = arduino
build_flags = -DWIO_TERMINAL
upload_protocol = sam-ba
monitor_speed = 115200
lib_ldf_mode = deep+
lib_deps =
https://github.com/Seeed-Studio/Seeed_Arduino_mbedtls/archive/dev.zip
https://github.com/Seeed-Studio/Seeed_Arduino_rpcUnified/archive/master.zip
https://github.com/Seeed-Studio/Seeed_Arduino_rpcBLE/archive/master.zip
https://github.com/Seeed-Studio/Seeed_Arduino_rpcWiFi/archive/master.zip
https://github.com/Seeed-Studio/Seeed_Arduino_FreeRTOS/archive/master.zip
https://github.com/Seeed-Studio/Seeed_Arduino_FS/archive/master.zip
https://github.com/Seeed-Studio/Seeed_Arduino_SFUD/archive/master.zip
#
https://github.com/Seeed-Studio/Seeed_Arduino_LCD/archive/master.zip
M5Atomの場合:
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:esp32dev]
platform = espressif32
#board = esp32dev
board = m5stick-c
framework = arduino
monitor_speed = 115200
lib_ldf_mode = deep+
lib_deps =
# use M5Atom lib
3113
# use "FastLED"
126
ESP32の場合:
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
build_flags = -DESP32
monitor_speed = 115200
lib_ldf_mode = deep+
ESP8266の場合:
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:huzzah]
platform = espressif8266
#board = huzzah
board = esp_wroom_02
framework = arduino
monitor_speed = 115200
lib_ldf_mode = deep+
wio-terminalのファームウェアを切り替えたときの注意
古いファームウェアのライブラリを動かした後は、古いライブラリがキャッシュで残っていると ビルド・エラーになるので以下を実行すること:
cd project_directory
rm -r .pio/libdeps/seeed_wio_terminal/*
rm -r .pio/build/seeed_wio_terminal/*
参考情報
以上
| 固定リンク
« Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(MQTT編) | トップページ | MicroPython(F767ZI)でStartwars(AsciiArt)を動かす »
「PlatformIO」カテゴリの記事
- NuEVI/NuRADのビルド(2022.08.18)
- Wio_ExtFlashLoad(WriteSampleMenu.ino)スケッチをplatformioでビルドする(2022.02.03)
- uncannyeyesスケッチをplatformioでビルドする(2022.01.31)
- LovyanGFX-Display ライブラリを使用したスケッチをplatformioでビルドする(2022.01.30)
- Wio-Terminal/M5Core2のWiFiAnallyzer(2022.01.24)
「Arduino」カテゴリの記事
- platformioのために新しいユーザーを設定する(2022.02.06)
- MAKER_PI_RP2040でI2Cを使う(Arduino編)(2022.01.09)
- M5Stamp-PICO Arduino Install(2021.12.12)
- M5Stamp-C3 Arduino Install(2021.12.12)
- Arduino-CLIのインストール(2021.05.19)
「Wio Terminal」カテゴリの記事
- Wio_ExtFlashLoad(WriteSampleMenu.ino)スケッチをplatformioでビルドする(2022.02.03)
- Wio-TerminalでMQTTを動かす(2022.01.20)
- wio-terminalでGROVEを使う(2022.01.17)
- nixieクロックにNTPクライアントの機能を追加する(V2)(2021.02.18)
- Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(STARWARS編)(2020.12.28)
「ESP-WROOM-02」カテゴリの記事
- Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(STARWARS編)(2020.12.28)
- Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(MQTT編)(2020.12.27)
- Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(REST-API編)(2020.12.27)
- Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(OSC編)(2020.12.26)
- XIAOにWiFiモジュールを接続する(STARWARS)(2020.08.15)
「M5Atom」カテゴリの記事
- 「M5Stack用回転角ユニット」を動かす(2022.01.01)
- M5Atomを開発ツールPlatformIOで使う(v2)(M5Atom/Arduino版)(2021.01.10)
- python3/micro:bit-micropython/CircuitPython用エディタ(mu-editor)をインストールする(v2,microbit-v2対応)(linux版)(2020.12.31)
- Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(STARWARS編)(2020.12.28)
- Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(MQTT編)(2020.12.27)
「ESP32」カテゴリの記事
- Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(STARWARS編)(2020.12.28)
- Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(MQTT編)(2020.12.27)
- Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(REST-API編)(2020.12.27)
- Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(OSC編)(2020.12.26)
- M5Atomを開発ツールPlatformIOで使う(Windows10版)(2020.10.09)
この記事へのコメントは終了しました。
コメント