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?

今年、MicroPython用に買ったボードシリーズ。

M5Stack NanoC6

2024年3月22日 スイッチサイエンスで購入

IMG_1625.JPG

IMG_1626.JPG

待ちに待った ESP32-C6 でしたが、買った時点では MicroPython がまだ正式サポートされておらず、v1.24.0 まで待たないといけないのでした。

ファームウェアダウンロード

M5Stack NanoC6には専用のファームウェアが提供されている。以下から最新安定版の v1.24.1 をダウンロード。

ファームウェアのインストール

ファームウェアインストールには Raspberry Pi 5 で esptool.py を利用。

$ esptool.py --chip esp32c6 --port /dev/ttyACM0 erase_flash
esptool.py v4.8.1
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-C6FH4 (QFN32) (revision v0.1)
Features: WiFi 6, BT 5, IEEE802.15.4
Crystal is 40MHz
MAC: 40:4c:ca:ff:fe:5b:1f:4c
BASE MAC: 40:4c:ca:5b:1f:4c
MAC_EXT: ff:fe
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 18.6s
Hard resetting via RTS pin...
$ esptool.py --chip esp32c6 --port /dev/ttyACM0 --baud 460800 write_flash -z 0x0 M5STACK_NANOC6-20241129-v1.24.1.bin 
esptool.py v4.8.1
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-C6FH4 (QFN32) (revision v0.1)
Features: WiFi 6, BT 5, IEEE802.15.4
Crystal is 40MHz
MAC: 40:4c:ca:ff:fe:5b:1f:4c
BASE MAC: 40:4c:ca:5b:1f:4c
MAC_EXT: ff:fe
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x001defff...
Compressed 1958000 bytes to 1199243...
Wrote 1958000 bytes (1199243 compressed) at 0x00000000 in 15.8 seconds (effective 990.1 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

起動テスト

mpremote で REPL に入れるかチェック。

$ mpremote
Connected to MicroPython at /dev/ttyACM0
Use Ctrl-] or Ctrl-x to exit this shell

>>> (Ctrl-Dでソフトウェアリブート)
MPY: soft reboot
MicroPython v1.24.1 on 2024-11-29; M5Stack NanoC6 with ESP32C6
Type "help()" for more information.
>>> 

簡単プログラミング

内蔵の RGB-LED (NeoPixel) を色を変えながら光らせてみる。

NanoC6 で使えるピンには予めPinオブジェクトが定義されている。

Pinオブジェクト GPIO 備考
Pin.board.G1 GPIO1 Groveインタフェースに出ているピン①
Pin.board.G2 GPIO2 Groveインタフェースに出ているピン②
Pin.board.IR_LED GPIO3 IR
Pin.board.LED_BLUE GPIO7 青色のLED
Pin.board.BUTTON GPIO9 ボタン
Pin.board.NEOPIXEL_POWER GPIO19 NeoPixel の有効化/無効化
Pin.board.NEOPIXEL GPIO20 RGB LED (NeoPixel)

NanoC6 の初期デモのようなものを作ってみる。

led_sample.py

from time import sleep_ms
from machine import Pin
from neopixel import NeoPixel

Pin.board.NEOPIXEL_POWER.on()
np = NeoPixel(Pin.board.NEOPIXEL, 1)
while True:
    for c in range(8):
        r = ((c & 0b100) >> 2) * 128
        g = ((c & 0b010) >> 1) * 128
        b = (c & 0b001) * 16
        np[0] = (r, g, b)
        np.write()
        if Pin.board.LED_BLUE.value():
            Pin.board.LED_BLUE.off()
        else:
            Pin.board.LED_BLUE.on()
	sleep_ms(500)

mpremote を使って、MicroPythonのファイルシステムにコピー。

mpremote cp led_sample.py :main.py

led_sample.gif

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?