4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

M5StickC内臓RTCをNTPで時間合わせして表示

Last updated at Posted at 2021-12-01

1.はじめに

M5StickC内臓RTCをNTPで時間合わせして表示する方法の覚書

UIFlowはVer.1.8.7
NTPで時刻を取得して、"YYYY-MM-DD"と"HH: mm:SS"として表示する方法の覚書

2.UIFlowコード

NTPtoRTC.png
NTPで時間を取得して、RTCに設定後に時刻表示。
NTPにある日付と時刻の表示機能がRTCにはついていないため、「コードを実行」でそれぞれコマンド実行。

日付表示部分のコード

label0.setText(str(rtc.now()[0]) +"-"+ str(rtc.now()[1])+"-"+str(rtc.now()[2]))

時間表示部分のコード

label1.setText(str(rtc.now()[3]) +":"+ str(rtc.now()[4])+":"+str(rtc.now()[5]))
4
3
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
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?