2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ブレッドボードで遊ぶつもりが、AtomVMにtelnetしていた件について

2
Last updated at Posted at 2026-09-11
Page 1 of 14

今日やるはずだったこと

AtomVMを始めたはいいが、そもそも

ブレッドボードの配線、よくわからん

なので、

  • XIAO ESP32-C5
  • ブレッドボード
  • AtomVM

を使って遊んでみることにしました。


環境やバージョン

  • Seeed XIAO ESP32-C5
  • AtomVM v0.7.0-alpha.1
  • Elixir 1.18.3 (compiled with Erlang/OTP 27)

AtomVMを入れる

ESP32-C5にAtomVMを書き込んで起動。

Type [C-a] [C-h] to see available commands
Terminal ready
    ###########################################################

       ###    ########  #######  ##     ## ##     ## ##     ## 
      ## ##      ##    ##     ## ###   ### ##     ## ###   ### 
     ##   ##     ##    ##     ## #### #### ##     ## #### #### 
    ##     ##    ##    ##     ## ## ### ## ##     ## ## ### ## 
    #########    ##    ##     ## ##     ##  ##   ##  ##     ## 
    ##     ##    ##    ##     ## ##     ##   ## ##   ##     ## 
    ##     ##    ##     #######  ##     ##    ###    ##     ## 

    ###########################################################

I (667) AtomVM: Starting AtomVM revision 0.7.0-alpha.1+git.078004b
I (677) sys: Loaded BEAM partition boot.avm at address 0x1d0000 (size=524288 bytes)
I (697) network_driver: Initialized network interface
I (697) network_driver: Created default event loop
I (707) AtomVM: Found startup beam esp32init.beam
I (707) AtomVM: Starting esp32init.beam...
---
AtomVM init.
I (747) sys: Loaded BEAM partition main.avm at address 0x250000 (size=1048576 bytes)
Failed app start: invalid_avm.
Starting network...
I (777) network_driver: AP ssid: AtomVM-ESP32
I (777) network_driver: AP authmode: 4
I (777) network_driver: AP ssid_hidden: 0
I (777) network_driver: AP max_connection: 4

無事に起動した。

……ん?

network_driver?


知らないWi-Fiがいる

起動ログを見ていると、

AtomVM-ESP32

というWi-Fi関連の表示が。

なんぞこれ?


ソースコードを見てみる

AtomVMのソースコードを探してみると、

というファイルを発見。

-define(DEFAULT_AP_SSID, <<"AtomVM-ESP32">>).
-define(DEFAULT_AP_PSK, <<"esp32default">>).

-define(DEFAULT_CONSOLE_PORT, 2323).
-define(DEFAULT_WEB_SERVER_PORT, 8080).

ネットワークらしきものを設定している!


ESP32 Dev Mode

ネットワーク設定がない場合は、

SSID: AtomVM-ESP32
PSK:  esp32default

でアクセスポイントとして起動。

PCからWi-Fiアクセスポイント AtomVM-ESP32 に接続。
起動ログに表示されたIPアドレスの8080番ポートへブラウザからアクセスする。
※IPはAtomVMの起動ログに表示される

さらにネットワーク設定を保存すると……

esp:nvs_set_binary(atomvm, sta_ssid, ...)
esp:nvs_set_binary(atomvm, sta_psk, ...)

ESP32のNVSにSSID / PSKを保存できる。


家のWi-Fiにつないでみる

SSID / PSKを設定すると、

PC
 │
 ▼
家のWi-Fi
 │
 ▼
XIAO ESP32-C5
 │
 └─ AtomVM

XIAOがSTAとして家のWi-Fiに参加。

起動ログには、

…
I (8177) network_driver: IP_EVENT_STA_GOT_IP: 192.168.10.126
Acquired IP address: 192.168.10.126 Netmask: 255.255.255.0 Gateway: 192.168.10.1
Web server listening on port 8080
ALISP console listening on port 2323
Waiting to accept shell connection...

IPアドレスが!


2323番ポートとは?

ソースコードには、

-define(DEFAULT_CONSOLE_PORT, 2323).

さらに、

gen_tcp:listen(Port, [])

でTCPポートをListenしている。

そしてログには、

ALISP console listening on port 2323
Waiting to accept shell connection...

コンソールがいる。


telnetしてみる

PCから、

telnet 192.168.x.x 2323

接続すると…

$ telnet 192.168.10.126 2323
Trying 192.168.10.126...
Connected to 192.168.10.126.
Escape character is '^]'.
AtomVM LISP REPL

arepl(0)>

入れた!


中では何が動いてる?

接続をacceptすると、

arepl:start() が呼ばれている。
つまりESP32 Dev Modeでは、TCP 2323番ポート経由でAtomVM上のALISP REPL(AREPL)を操作できる。


せっかくなので

REPLからGPIOを操作する。
XIAO ESP32-C5のD0はGPIO1なので、今回はGPIO1を出力として使用。

arepl(0)> (progn (setq g (gpio:start)) 123)
123
arepl(1)> (gpio:set_direction g 1 (quote output))
ok
arepl(2)> (progn (gpio:set_level g 1 1) (timer:sleep 1000) (gpio:set_level g 1 0) (timer:sleep 1000) (gpio:set_level g 1 1) (timer:sleep 1000) (gpio:set_level g 1 0) (timer:sleep 1000) (gpio:set_level g 1 1) (timer:sleep 1000) (gpio:set_level g 1 0) (timer:sleep 1000) (gpio:set_level g 1 1) (timer:sleep 1000) (gpio:set_level g 1 0) (timer:sleep 1000) (gpio:set_level g 1 1) (timer:sleep 1000) (gpio:set_level g 1 0))
ok

Lチカできた!

VID_20260907_173400256 (1).gif


当初の目標

最初:

ブレッドボード
      ↓
    AtomVM
      ↓
     Lチカ

実際:

AtomVMを起動
      ↓
「このWi-Fi何?」
      ↓
ソースコードを読む
      ↓
ESP32 Dev Mode発見
      ↓
家のWi-Fiにつなぐ
      ↓
telnet :2323
      ↓
AREPL
      ↓
Wi-Fi越しLチカ

ところで

ブレッドボードは?

┐(´д`)┌ヤレヤレ

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?