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

ST7031 を Xbeeで使ってみる。

Last updated at Posted at 2025-08-27

LCDを使ってみる

通信規格はi2c

製品情報

ST7031v1.3 .doc

st_sk7031.jpg

出展 : マイコンの実験:XBee3(PyCharm)の実験3

項目設定

以下の項目をXCTU上で変更する。

AP Micropython REPL [4]

PS Disabled [0]
BD 115200 [7]

D1 I2C SCL [6]
P1 I2C SDA [6]

※ : PS は [1] でもよい。

Xbee TH モニタ側 [端子側左から]
外部給電 3v3(1)
D1(DIO1) 19 SCL(3)
P1(PWM1) 7 SDA(4)
GND 10 GND(5)

3V3 は外部給電。Arduino uno を使った。

構成図

3.3Vであることに注意する。

st7031.png

ソースコード

表示テスト

from machine import I2C
from sk_st7032i import ST7032i

print("START I2C TEST")

i2c = I2C(1, freq=100000)  # I2Cのオブジェクトを生成する
lcd = ST7032i(i2c, 30,True)     # I2C接続LCD操作のオブジェクトを生成する

lcd.charout("I2C Test")    # 文字を表示する
lcd.cursor(0, 1) # 文字の表示位置を2行目の1桁目に移動する
lcd.charout("XBee3")

文字の明滅を実装してみる。

from machine import I2C
from sk_st7032i import ST7032i
import utime

print("START I2C TEST")

i2c = I2C(1, freq=100000)  
lcd = ST7032i(i2c, 30,True) 

lcd.charout("I2C Test") 
while True:  
    lcd.cursor(0, 1)          
    lcd.charout("XBee3")
    utime.sleep_ms(500)
    lcd.cursor(0, 1)          
    lcd.charout("        ")
    utime.sleep_ms(500)

文字のスクロール

長文をループ表示するためには、いろいろあるがとりまスクロールをば:

from machine import I2C
from sk_st7032i import ST7032i
import utime

i2c = I2C(1, freq=100000)  
lcd = ST7032i(i2c, 30,True) 

text = "abcdefghijklmnopqrstuvwxyz" 
width = 8
lcd.charout("I2C Test") 
while True:
    for i in range(len(text)):
        window = text[i:i+width]  # n文字取り出す(LCD幅に合わせて調整)
        if len(window) < width:
            # 末尾に来たら先頭から補う
            window += text[:width-len(window)]
        lcd.cursor(0, 1)      
        lcd.charout(window)
        utime.sleep_ms(500)  # スクロール速度

表示可能な規定の文字一覧はここ
にある。

ライブラリ

ライプラリのコードは以下の場所より引用した。

マイコンの実験:XBee3(PyCharm)の実験3

参考

マイコンの実験:XBee3(PyCharm)の実験3

【ST7032i】使うためのデータシート抜粋日本語訳 | くろべこblog

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