1
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?

RaspberryPi5でtoio.pyをつかってみた

1
Last updated at Posted at 2025-12-13

結論

  • bookworm & Python 3.11.2にて動作確認
  • 普通に使える
    • 謎のパッケージを入れて...みたいなこともなく、簡単に動く

環境

  • RaspberryPi 5 8GB
  • Bookworm
  • Python 3.11.2

やったこと

こちらの記事をRaspberryPi 5で実施した。
なのでほぼコピペです。

一応コマンドの流れは下記

念のため、仮想環境を用意

python -m venv toio
source toio/bin/activate

pipでインストールする

.pyまで必要なので注意

pip install toio.py

プログラムはnanoなどのエディタで作成した。ファイル名はtoio_check.pyにした。

コードはnpaka様のものをそのまま流用

toio_check.py
import asyncio
from toio import *

async def hello():
    async with ToioCoreCube() as cube:
        # 回転
        await cube.api.motor.motor_control(30, -30)
        await asyncio.sleep(2)

        # 停止
        await cube.api.motor.motor_control(0, 0)

    return 0

if __name__ == "__main__":
    asyncio.run(hello())

実行

Toioコアキューブに電源を入れ、RaspberryPiの近くに置く。

以下コマンドを実行

python toio_check.py

Toioコアキューブが回るよ!

toio.pyのすごいなーポイント

  • async with ToioCoreCube()で近くにあるtoioコアキューブと勝手に接続してくれる
    • 展示会イベントやもくもく会では注意せねば!
    • 一応Scanner的な機能もある
  • 本家GitHubの日本語READMEを見るだけでもある程度どのような動作ができるのか、流し読みでも理解できて、やさしい

まとめ

  • とりあえずPythonでToioコアキューブ動かす!というのはササッとできるぞ!
  • RaspberryPiのいい感じのハードウェアリソースと組み合わせたら多分楽しいぞ!
1
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
1
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?