---
title: M5stackでスマートウォッチをつくる？
tags: 
author: [kyokucho1989](https://www.docswell.com/user/kyokucho1989)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/2JVM19VNJQ.jpg?width=480
description: IoT縛りの勉強会！ IoTLT vol.62
published: April 16, 20
canonical: https://www.docswell.com/s/kyokucho1989/ZGX1NM-2023-04-23-050520
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/2JVM19VNJQ.jpg)

m5stackで
スマートウォッチをつくる？
IoT縛りの勉強会! IoTLT vol.62 2020/4/16
@kyokucho_1989


# Page. 2

![Page Image](https://bcdn.docswell.com/page/5EGG2ZL5EL.jpg)

自己紹介
・kyokucho1989
・IoTが好き
・M5Stack楽しい
・広島在住
・#人生逆転サロン メンター（IoT）
twitter: @kyokucho_1989
blog: https://matoyomi.hatenablog.com
「マトリョーシカ的日常」
youtube: マトリョーシカ的IoTチャンネル
#IoTLT
@kyokucho_1989


# Page. 3

![Page Image](https://bcdn.docswell.com/page/4JQXPLYLEP.jpg)

自己紹介
プッチ神父回路
（素数だけ数える）
カップラーメン IoT タイマー
（3分経ったらLINEにお知らせ）
#IoTLT
@kyokucho_1989


# Page. 4

![Page Image](https://bcdn.docswell.com/page/K746YDW5E1.jpg)

本題：スマートウォッチをつくろう（？）
#IoTLT
@kyokucho_1989


# Page. 5

![Page Image](https://bcdn.docswell.com/page/LJ1V6ZY2EG.jpg)

スマートウォッチ（一般的な）
通知
#IoTLT
@kyokucho_1989
時計
ロギング


# Page. 6

![Page Image](https://bcdn.docswell.com/page/GJWLW9G2E2.jpg)

スマートじゃないウォッチ的ななにか
通知
時計
ロギング
機能を絞る！
（ハードルをものすっごい下げる！）
#IoTLT
@kyokucho_1989


# Page. 7

![Page Image](https://bcdn.docswell.com/page/4EZM59L4J3.jpg)

どんなシステム？
時刻データ
NTPサーバー
#IoTLT
@kyokucho_1989
M5Stack
サーボモータ


# Page. 8

![Page Image](https://bcdn.docswell.com/page/Y76N9KWG7V.jpg)

コードの一部（抜粋）
#include &lt;M5Stack.h&gt;
#include &lt;WiFi.h&gt;
#include &lt;WiFiClient.h&gt;
#include &quot;time.h&quot;
WiFiClient client;
const char* ssid = “****”;
const char* password = “***”;
const char* ntpServer = &quot;ntp.jst.mfeed.ad.jp&quot;;
const long gmtOffset_sec = 3600L * 9;
const int daylightOffset_sec = 0;
int hh,mm,ss;
#IoTLT
@kyokucho_1989
void printLocalTime(){
struct tm timeinfo;
if(!getLocalTime(&amp;timeinfo)){
Serial.println(&quot;Failed to obtain time&quot;);
return;
}
hh = timeinfo.tm_hour;
mm = timeinfo.tm_min;
ss = timeinfo.tm_sec;
Serial.println(&amp;timeinfo);
}
void setup() {
Serial.begin(115200);
M5.begin(true, false, true);
delay(10);
}
void loop(){
delay(500);
printLocalTime();
}


# Page. 9

![Page Image](https://bcdn.docswell.com/page/G755NPMX74.jpg)

コードの一部（抜粋）
#include &lt;M5Stack.h&gt;
#include &lt;WiFi.h&gt;
#include &lt;WiFiClient.h&gt;
#include &quot;time.h&quot;
WiFiClient client;
const char* ssid = “****”;
!getLocalTime()の後にやらないとss
const
char* password = “***”;
const char* ntpServer = &quot;ntp.jst.mfeed.ad.jp&quot;;
が取得できなかった
const long gmtOffset_sec = 3600L * 9;
const int daylightOffset_sec = 0;
int hh,mm,ss;
ここがわからなかった
#IoTLT
@kyokucho_1989
void printLocalTime(){
struct tm timeinfo;
if(!getLocalTime(&amp;timeinfo)){
Serial.println(&quot;Failed to obtain time&quot;);
return;
}
hh = timeinfo.tm_hour;
mm = timeinfo.tm_min;
ss = timeinfo.tm_sec;
Serial.println(&amp;timeinfo);
}
void setup() {
Serial.begin(115200);
M5.begin(true, false, true);
delay(10);
}
void loop(){
delay(500);
printLocalTime();
}


# Page. 10

![Page Image](https://bcdn.docswell.com/page/9J2N569QER.jpg)

うごかしてみたよ。
#IoTLT
@kyokucho_1989


# Page. 11

![Page Image](https://bcdn.docswell.com/page/DEYPK94YEM.jpg)

ご静聴、ありがとうございました。
#IoTLT
@kyokucho_1989


