<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WebThings &#8211; 醬是創客</title>
	<atom:link href="https://www.chosemaker.com/topic/webthings/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.chosemaker.com</link>
	<description>醬是創客</description>
	<lastBuildDate>Sat, 03 Apr 2021 02:42:43 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.6.8</generator>

<image>
	<url>https://www.chosemaker.com/wp-content/uploads/2020/07/cropped-favicon-1-32x32.jpg</url>
	<title>WebThings &#8211; 醬是創客</title>
	<link>https://www.chosemaker.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>[WebThings教學#7] WebThings做出IoT物聯網平台，紀錄Log數值與查看曲線圖</title>
		<link>https://www.chosemaker.com/topic/webthings/webthings-7/</link>
		
		<dc:creator><![CDATA[pyclifecom]]></dc:creator>
		<pubDate>Fri, 16 Oct 2020 03:14:53 +0000</pubDate>
				<category><![CDATA[WebThings]]></category>
		<category><![CDATA[實作主題分類]]></category>
		<category><![CDATA[樹莓派]]></category>
		<category><![CDATA[開發板分類]]></category>
		<guid isPermaLink="false">https://www.chosemaker.com/?p=485</guid>

					<description><![CDATA[<p>醬是創客的WebThings教學主題第7篇，以WebThings Gateway搭配Raspberr &#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://www.chosemaker.com/topic/webthings/webthings-7/">[WebThings教學#7] WebThings做出IoT物聯網平台，紀錄Log數值與查看曲線圖</a> 最早出現於 <a rel="nofollow" href="https://www.chosemaker.com">醬是創客</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>醬是創客的WebThings教學主題第7篇，以WebThings Gateway搭配Raspberry Pi樹莓派來實作教學，本篇教學將著重紀錄Log數值與查看曲線圖，有了連續數值後，我們可以方便查詢過去的歷史紀錄，並知道設備狀況</p>



<p>本篇文章基於WebThings教學#1~5，請先閱讀完並設定好你的ESP32與樹莓派後再開始進入此篇，首先請先確認儀表板的圖示如下</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" width="779" height="479" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-1.jpg" alt="" class="wp-image-478" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-1.jpg 779w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-1-300x184.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-1-768x472.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-1-508x312.jpg 508w" sizes="(max-width: 779px) 100vw, 779px" /></figure></div>



<p>到選單的紀錄，並點選右下角來加入紀錄的profile</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="786" height="477" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-1.jpg" alt="" class="wp-image-486" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-1.jpg 786w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-1-300x182.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-1-768x466.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-1-508x308.jpg 508w" sizes="(max-width: 786px) 100vw, 786px" /></figure></div>



<p>要記錄chosemaker Tempe and Hum的溫度，並指保留7天數據，由於Webthings是將資料放於sqlite3資料庫，這部分需請自行評估IO rate部分計算可以容納多少設備同時寫入</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="785" height="396" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-2.jpg" alt="" class="wp-image-487" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-2.jpg 785w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-2-300x151.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-2-768x387.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-2-508x256.jpg 508w" sizes="(max-width: 785px) 100vw, 785px" /></figure></div>



<p>接著點入chosemaker Tempe and Hum，即開始繪圖，可以選分/小時/天來查看連續數職的曲線</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="785" height="471" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-3.jpg" alt="" class="wp-image-488" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-3.jpg 785w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-3-300x180.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-3-768x461.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-7-3-508x305.jpg 508w" sizes="(max-width: 785px) 100vw, 785px" /></figure></div>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-7%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%237%5D%20WebThings%E5%81%9A%E5%87%BAIoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%EF%BC%8C%E7%B4%80%E9%8C%84Log%E6%95%B8%E5%80%BC%E8%88%87%E6%9F%A5%E7%9C%8B%E6%9B%B2%E7%B7%9A%E5%9C%96" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook_messenger" href="https://www.addtoany.com/add_to/facebook_messenger?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-7%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%237%5D%20WebThings%E5%81%9A%E5%87%BAIoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%EF%BC%8C%E7%B4%80%E9%8C%84Log%E6%95%B8%E5%80%BC%E8%88%87%E6%9F%A5%E7%9C%8B%E6%9B%B2%E7%B7%9A%E5%9C%96" title="Facebook Messenger" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_line" href="https://www.addtoany.com/add_to/line?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-7%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%237%5D%20WebThings%E5%81%9A%E5%87%BAIoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%EF%BC%8C%E7%B4%80%E9%8C%84Log%E6%95%B8%E5%80%BC%E8%88%87%E6%9F%A5%E7%9C%8B%E6%9B%B2%E7%B7%9A%E5%9C%96" title="Line" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-7%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%237%5D%20WebThings%E5%81%9A%E5%87%BAIoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%EF%BC%8C%E7%B4%80%E9%8C%84Log%E6%95%B8%E5%80%BC%E8%88%87%E6%9F%A5%E7%9C%8B%E6%9B%B2%E7%B7%9A%E5%9C%96" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-7%2F&#038;title=%5BWebThings%E6%95%99%E5%AD%B8%237%5D%20WebThings%E5%81%9A%E5%87%BAIoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%EF%BC%8C%E7%B4%80%E9%8C%84Log%E6%95%B8%E5%80%BC%E8%88%87%E6%9F%A5%E7%9C%8B%E6%9B%B2%E7%B7%9A%E5%9C%96" data-a2a-url="https://www.chosemaker.com/topic/webthings/webthings-7/" data-a2a-title="[WebThings教學#7] WebThings做出IoT物聯網平台，紀錄Log數值與查看曲線圖"></a></p><p>這篇文章 <a rel="nofollow" href="https://www.chosemaker.com/topic/webthings/webthings-7/">[WebThings教學#7] WebThings做出IoT物聯網平台，紀錄Log數值與查看曲線圖</a> 最早出現於 <a rel="nofollow" href="https://www.chosemaker.com">醬是創客</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[WebThings教學#6] WebThings做出IoT物聯網平台簡易溫溼度與繼電器自動化控制系統實作</title>
		<link>https://www.chosemaker.com/topic/webthings/webthings-6/</link>
		
		<dc:creator><![CDATA[pyclifecom]]></dc:creator>
		<pubDate>Fri, 16 Oct 2020 03:05:40 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[ESP32]]></category>
		<category><![CDATA[WebThings]]></category>
		<category><![CDATA[實作主題分類]]></category>
		<category><![CDATA[樹莓派]]></category>
		<category><![CDATA[程式語言分類]]></category>
		<category><![CDATA[開發板分類]]></category>
		<guid isPermaLink="false">https://www.chosemaker.com/?p=477</guid>

					<description><![CDATA[<p>醬是創客的WebThings教學主題第6篇，以NodeMCU-32S(Arduino語言)與Rasp &#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://www.chosemaker.com/topic/webthings/webthings-6/">[WebThings教學#6] WebThings做出IoT物聯網平台簡易溫溼度與繼電器自動化控制系統實作</a> 最早出現於 <a rel="nofollow" href="https://www.chosemaker.com">醬是創客</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>醬是創客的WebThings教學主題第6篇，以NodeMCU-32S(Arduino語言)與Raspberry Pi樹莓派來實作教學，本篇教學將著重使用ESP32與WebThings做出免費開源IoT物聯網平台連動，並透過平台判斷溫度高低，來控制繼電器開啟、關閉電燈，即可輕鬆達到智慧家庭、智慧農業、智慧工廠等解決方案，更重要的事情是可以透過IoT平台做到控制</p>



<p>本篇文章基於WebThings教學#1~5，請先閱讀完並設定好你的ESP32與樹莓派後再開始進入此篇，首先請先確認儀表板的圖示如下</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="779" height="479" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-1.jpg" alt="" class="wp-image-478" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-1.jpg 779w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-1-300x184.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-1-768x472.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-1-508x312.jpg 508w" sizes="(max-width: 779px) 100vw, 779px" /></figure></div>



<p>在左邊的選單點選規則後，並點右下的+</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="789" height="481" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-2.jpg" alt="" class="wp-image-479" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-2.jpg 789w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-2-300x183.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-2-768x468.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-2-508x310.jpg 508w" sizes="(max-width: 789px) 100vw, 789px" /></figure></div>



<p>我們先建立一個profile叫more33，設定當chosemaker Tempe and Hum的溫度大於33度時，chosemaker Lamp的繼電器會開啟電燈，藍底部分可以拖拉設備至中間，中間的左方為輸入區拉入chosemaker Tempe and Hum並設定Temp>33，中間的右方為輸出區拉入chosemaker Lamp並設定開</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="1024" height="468" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-3-1024x468.jpg" alt="" class="wp-image-480" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-3-1024x468.jpg 1024w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-3-300x137.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-3-768x351.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-3-508x232.jpg 508w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-3.jpg 1280w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="1024" height="483" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-4-1024x483.jpg" alt="" class="wp-image-481" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-4-1024x483.jpg 1024w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-4-300x142.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-4-768x362.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-4-508x240.jpg 508w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-4.jpg 1278w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></div>



<p>我們再建立一個profile叫less33，設定當chosemaker Tempe and Hum的溫度小於33度時，chosemaker Lamp的繼電器會關閉電燈，藍底部分可以拖拉設備至中間，中間的左方為輸入區拉入chosemaker Tempe and Hum並設定Temp&lt;33，中間的右方為輸出區拉入chosemaker Lamp並設定關</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="1024" height="470" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-5-1024x470.jpg" alt="" class="wp-image-482" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-5-1024x470.jpg 1024w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-5-300x138.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-5-768x353.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-5-508x233.jpg 508w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-6-5.jpg 1280w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></div>



<p>這時候系統就可以做到自動化控制，以33度C為分隔，過高則開燈，過低則關燈，可以看到下方還有一個Clock的功能，它也可以拖入來設定某段時間才允許觸發條件</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-6%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%236%5D%20WebThings%E5%81%9A%E5%87%BAIoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E7%B0%A1%E6%98%93%E6%BA%AB%E6%BA%BC%E5%BA%A6%E8%88%87%E7%B9%BC%E9%9B%BB%E5%99%A8%E8%87%AA%E5%8B%95%E5%8C%96%E6%8E%A7%E5%88%B6%E7%B3%BB%E7%B5%B1%E5%AF%A6%E4%BD%9C" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook_messenger" href="https://www.addtoany.com/add_to/facebook_messenger?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-6%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%236%5D%20WebThings%E5%81%9A%E5%87%BAIoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E7%B0%A1%E6%98%93%E6%BA%AB%E6%BA%BC%E5%BA%A6%E8%88%87%E7%B9%BC%E9%9B%BB%E5%99%A8%E8%87%AA%E5%8B%95%E5%8C%96%E6%8E%A7%E5%88%B6%E7%B3%BB%E7%B5%B1%E5%AF%A6%E4%BD%9C" title="Facebook Messenger" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_line" href="https://www.addtoany.com/add_to/line?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-6%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%236%5D%20WebThings%E5%81%9A%E5%87%BAIoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E7%B0%A1%E6%98%93%E6%BA%AB%E6%BA%BC%E5%BA%A6%E8%88%87%E7%B9%BC%E9%9B%BB%E5%99%A8%E8%87%AA%E5%8B%95%E5%8C%96%E6%8E%A7%E5%88%B6%E7%B3%BB%E7%B5%B1%E5%AF%A6%E4%BD%9C" title="Line" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-6%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%236%5D%20WebThings%E5%81%9A%E5%87%BAIoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E7%B0%A1%E6%98%93%E6%BA%AB%E6%BA%BC%E5%BA%A6%E8%88%87%E7%B9%BC%E9%9B%BB%E5%99%A8%E8%87%AA%E5%8B%95%E5%8C%96%E6%8E%A7%E5%88%B6%E7%B3%BB%E7%B5%B1%E5%AF%A6%E4%BD%9C" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-6%2F&#038;title=%5BWebThings%E6%95%99%E5%AD%B8%236%5D%20WebThings%E5%81%9A%E5%87%BAIoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E7%B0%A1%E6%98%93%E6%BA%AB%E6%BA%BC%E5%BA%A6%E8%88%87%E7%B9%BC%E9%9B%BB%E5%99%A8%E8%87%AA%E5%8B%95%E5%8C%96%E6%8E%A7%E5%88%B6%E7%B3%BB%E7%B5%B1%E5%AF%A6%E4%BD%9C" data-a2a-url="https://www.chosemaker.com/topic/webthings/webthings-6/" data-a2a-title="[WebThings教學#6] WebThings做出IoT物聯網平台簡易溫溼度與繼電器自動化控制系統實作"></a></p><p>這篇文章 <a rel="nofollow" href="https://www.chosemaker.com/topic/webthings/webthings-6/">[WebThings教學#6] WebThings做出IoT物聯網平台簡易溫溼度與繼電器自動化控制系統實作</a> 最早出現於 <a rel="nofollow" href="https://www.chosemaker.com">醬是創客</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[WebThings教學#5] WebThings IoT物聯網平台連結ESP32 Arduino開發板抓取溫度、濕度</title>
		<link>https://www.chosemaker.com/topic/webthings/webthings-5/</link>
		
		<dc:creator><![CDATA[pyclifecom]]></dc:creator>
		<pubDate>Fri, 16 Oct 2020 02:03:28 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[ESP32]]></category>
		<category><![CDATA[WebThings]]></category>
		<category><![CDATA[實作主題分類]]></category>
		<category><![CDATA[程式語言分類]]></category>
		<category><![CDATA[開發板分類]]></category>
		<guid isPermaLink="false">https://www.chosemaker.com/?p=472</guid>

					<description><![CDATA[<p>醬是創客的WebThings教學主題第5篇，以WebThings搭配Ai-Thinker安信可Nod &#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://www.chosemaker.com/topic/webthings/webthings-5/">[WebThings教學#5] WebThings IoT物聯網平台連結ESP32 Arduino開發板抓取溫度、濕度</a> 最早出現於 <a rel="nofollow" href="https://www.chosemaker.com">醬是創客</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>醬是創客的WebThings教學主題第5篇，以WebThings搭配Ai-Thinker安信可NodeMCU-32S(Arduino語言)來實作教學，本篇教學將著重使用ESP32與Arduino WebThings Framework整合，並透過ESP32抓取TH485 modbus溫濕度感應器拋往WebThings Gateway，達到Client拋送溫度與濕度資訊到Server功能</p>



<p>以下是我們今天的目標</p>



<ul><li>定義溫度與濕度感應器的Types(TemperatureSensor, HumiditySensor)</li><li>了解WebThingAdapter的更新方法</li><li>ThingDevice定義該設備定義(開關、溫度、濕度……等)、描述、名稱、網址ID</li><li>ThingProperty定義多個Sensor屬性(TemperatureProperty,HumidityProperty)</li><li>ThingPropertyValue定義為Sensor數值</li></ul>



<p>設備:<br>樹莓派4B #<a href="https://www.ruten.com.tw/item/show?22051318422459" target="_blank" rel="noreferrer noopener">露天拍賣</a> #<a href="https://shopee.tw/%E6%A8%B9%E8%8E%93%E6%B4%BE4B-%E8%8B%B1%E5%9C%8B%E8%A3%BD%E5%8E%9F%E5%BB%A0%E9%96%8B%E7%99%BC%E6%9D%BF-4G-8G-Raspberry-Pi-4B-AI%E5%BD%B1%E5%83%8F%E8%BE%A8%E8%AD%98-%E6%A9%9F%E5%99%A8%E5%AD%B8%E7%BF%92%E5%B0%88%E7%94%A8-Linux-i.293276804.5269190409" target="_blank" rel="noreferrer noopener">蝦皮購物</a><br>安信可NodeMCU-32S #<a href="https://www.ruten.com.tw/item/show?22030930136256" target="_blank" rel="noreferrer noopener">露天拍賣</a> #<a href="https://shopee.tw/ESP32-S-NodeMCU-32S-WiFi-%E8%97%8D%E8%8A%BDBLE-%E9%99%84Arduino%E6%95%99%E5%AD%B8-%E5%AE%89%E4%BF%A1%E5%8F%AF%E7%89%A9%E8%81%AF%E7%B6%B2IoT-Wi-Fi%E9%96%8B%E7%99%BC%E6%9D%BF-i.293276804.6546028316" target="_blank" rel="noreferrer noopener">蝦皮購物</a><br>TTL485轉換板 #<a href="https://www.ruten.com.tw/item/show?22031984537655" target="_blank" rel="noreferrer noopener">露天拍賣</a> #<a href="https://shopee.tw/TTL-UART%E8%BD%89RS485-%E5%BA%8F%E5%88%97%E5%9F%A0Serial-ESD-TVS%E9%98%B2%E8%AD%B7-%E5%90%AB%E9%9B%BB%E6%BA%90%E7%87%88-TX-RX%E7%87%88-ESP32-Arduino-i.293276804.3446122089" target="_blank" rel="noreferrer noopener">蝦皮購物</a><br>TH485溫溼度板 #<a href="https://www.ruten.com.tw/item/show?22001180296090" target="_blank" rel="noreferrer noopener">露天拍賣</a> #<a href="https://shopee.tw/%E6%BA%AB%E6%BA%BC%E5%BA%A6-%E6%84%9F%E6%B8%AC%E5%99%A8-Modbus-RTU-%E6%BA%AB%E5%BA%A6-%E6%BF%95%E5%BA%A6-Sensor-%E7%8D%A8%E5%AE%B6%E9%80%81C-.NET-WPF%E5%8E%9F%E5%A7%8B%E7%A2%BC-%E4%BA%8C%E6%AC%A1%E9%96%8B%E7%99%BC-TH485-i.293276804.7746385632" target="_blank" rel="noreferrer noopener">蝦皮購物</a></p>



<p>接線方式:<br>NodeMCU-32S(3.3V或5V)—-TTL485轉換板(VCC)<br>NodeMCU-32S(GND)—-TTL485轉換板(GND)<br>NodeMCU-32S(GPIO17設為TX2)–TTL訊號–TTL485轉換板(RXD)<br>NodeMCU-32S(GPIO16設為RX2)–TTL訊號–TTL485轉換板(TXD)<br>TTL485轉換板(A/D+)–線–TH485(A)<br>TTL485轉換板(B/D-)–線–TH485(B)<br>DC 12V(+)–TH485(+)<br>DC 0V(-)–TH485(-)</p>



<p>TH485溫溼度設備Modbus RTU規格:<br>溫度: InputRegisters,0x0001,0.1C<br>濕度: InputRegisters,0x0002,0.1H<br>Buad Rate: 9600,N,8,1<br>Slave ID: 1</p>



<p>Ai-Thinker安信可NodeMCU-32S的腳位圍(資料來源:安信可)</p>



<figure class="wp-block-image"><img loading="lazy" width="868" height="923" src="https://www.chosemaker.com/wp-content/uploads/2020/07/nodemcu_32s_pin.png" alt="" class="wp-image-261" srcset="https://www.chosemaker.com/wp-content/uploads/2020/07/nodemcu_32s_pin.png 868w, https://www.chosemaker.com/wp-content/uploads/2020/07/nodemcu_32s_pin-282x300.png 282w, https://www.chosemaker.com/wp-content/uploads/2020/07/nodemcu_32s_pin-768x817.png 768w, https://www.chosemaker.com/wp-content/uploads/2020/07/nodemcu_32s_pin-329x350.png 329w" sizes="(max-width: 868px) 100vw, 868px" /></figure>



<p>Arduino 範例程式碼如下</p>


<pre class="brush: arduino; title: ; notranslate">
//醬是創客 開發實作的好夥伴
#define LARGE_JSON_BUFFERS 1
#define RXD2 16
#define TXD2 17
#include &lt;WiFi.h&gt;
#include &lt;Thing.h&gt;
#include &lt;WebThingAdapter.h&gt;
#include &lt;ModbusMaster.h&gt;

//SSID/PW
const char *ssid = &quot;iot&quot;;
const char *password = &quot;chosemaker&quot;;
// ModbusMaster object
ModbusMaster node;
uint8_t result;
uint16_t data[2];
//WebThings
WebThingAdapter *adapter;
const char *temphumTypes[] = {&quot;TemperatureSensor&quot;, &quot;HumiditySensor&quot;, nullptr};
ThingDevice temphum(&quot;chosemaker-temp-hum-1&quot;, &quot;&quot;, temphumTypes);
//溫度
ThingProperty sensorTemp(&quot;temp&quot;, &quot;&quot;, NUMBER, &quot;TemperatureProperty&quot;);
ThingPropertyValue tempVal;
//濕度
ThingProperty sensorHumd(&quot;hum&quot;, &quot;&quot;, NUMBER, &quot;HumidityProperty&quot;);
ThingPropertyValue humVal;

void setup()
{
  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
  // Modbus slave ID 1 使用 Serial2
  node.begin(1, Serial2);
  Serial.begin(115200);
  
  WiFi.begin(ssid, password);    
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(&quot;.&quot;);
  }

  Serial.println(&quot;&quot;);
  Serial.print(&quot;Connected to &quot;);
  Serial.println(ssid);
  Serial.print(&quot;IP address: &quot;);
  Serial.println(WiFi.localIP());
  //WebThings  
  adapter = new WebThingAdapter(&quot;temp-hum&quot;, WiFi.localIP());
  temphum.title = &quot;chosemaker Tempe and Hum&quot;;
  temphum.description = &quot;chosemaker's Temperature and Humidity&quot;;
  //溫度
  sensorTemp.title = &quot;Temp&quot;;
  sensorTemp.unit = &quot;degree celsius&quot;;
  sensorTemp.readOnly = &quot;true&quot;;
  temphum.addProperty(&amp;amp;sensorTemp);
  //濕度 
  sensorHumd.title = &quot;Hum&quot;;
  sensorHumd.unit = &quot;percent&quot;;
  sensorHumd.readOnly = &quot;true&quot;;
  temphum.addProperty(&amp;amp;sensorHumd);
  //WebThingAdapter
  adapter-&gt;addDevice(&amp;amp;temphum);
  adapter-&gt;begin();

  Serial.println(&quot;HTTP server started&quot;);
  Serial.print(&quot;http://&quot;);
  Serial.print(WiFi.localIP());
  Serial.print(&quot;/things/&quot;);
  Serial.println(temphum.id);
}
  
void loop()
{
  //WebThingAdapter
  adapter-&gt;update();

  //InputRegister 0x0001~0x0002
  result = node.readInputRegisters(0x0001, 2);   
  if (result == node.ku8MBSuccess)
  {
    //溫度InputRegister 0x0001
    data[0] = node.getResponseBuffer(0);
    tempVal.number = data[0] * 0.1;
    //濕度InputRegister 0x0002
    data[1] = node.getResponseBuffer(1);
    humVal.number = data[1] * 0.1;
  }
  //Set Value
  sensorTemp.setValue(tempVal);
  sensorHumd.setValue(humVal);

  delay(2000);
}
</pre>


<p>Arduino 序列埠監控視窗 輸出如下</p>


<pre class="brush: plain; title: ; notranslate">
..
Connected to iot
IP address: 192.168.2.179
MDNS responder started
HTTP server started
http://192.168.2.179/things/chosemaker-temp-hum-1
</pre>


<p>我們打開登入樹莓派的WebThings Gateway，在儀錶板的右下角點擊”+”並於”輸入web thing網址”輸入http://192.168.2.179/things/chosemaker-temp-hum-1，並儲存</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" width="689" height="336" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-1.jpg" alt="" class="wp-image-450" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-1.jpg 689w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-1-300x146.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-1-508x248.jpg 508w" sizes="(max-width: 689px) 100vw, 689px" /></figure></div>



<p>此時我們也可以連入http://192.168.2.179/things/chosemaker-temp-hum-1 ，可以看到這是一個JSON文件，Server於第一次取得設定檔時會連到Client抓取JSON回去對應欄位</p>


<pre class="brush: plain; title: ; notranslate">
{&quot;id&quot;:&quot;chosemaker-temp-hum-1&quot;,&quot;title&quot;:&quot;chosemaker Tempe and Hum&quot;,&quot;@context&quot;:&quot;https://iot.mozilla.org/schemas&quot;,&quot;description&quot;:&quot;A web chosemaker Temperature and Humidity&quot;,&quot;base&quot;:&quot;http://192.168.2.179/&quot;,&quot;securityDefinitions&quot;:{&quot;nosec_sc&quot;:{&quot;scheme&quot;:&quot;nosec&quot;}},&quot;security&quot;:&quot;nosec_sc&quot;,&quot;@type&quot;:[&quot;TemperatureSensor&quot;,&quot;HumiditySensor&quot;],&quot;links&quot;:[{&quot;rel&quot;:&quot;properties&quot;,&quot;href&quot;:&quot;/things/chosemaker-temp-hum-1/properties&quot;},{&quot;rel&quot;:&quot;actions&quot;,&quot;href&quot;:&quot;/things/chosemaker-temp-hum-1/actions&quot;},{&quot;rel&quot;:&quot;events&quot;,&quot;href&quot;:&quot;/things/chosemaker-temp-hum-1/events&quot;},{&quot;rel&quot;:&quot;alternate&quot;,&quot;href&quot;:&quot;ws://192.168.2.179/things/chosemaker-temp-hum-1&quot;}],&quot;properties&quot;:{&quot;hum&quot;:{&quot;type&quot;:&quot;number&quot;,&quot;readOnly&quot;:true,&quot;unit&quot;:&quot;percent&quot;,&quot;title&quot;:&quot;Hum&quot;,&quot;@type&quot;:&quot;HumidityProperty&quot;,&quot;links&quot;:[{&quot;href&quot;:&quot;/things/chosemaker-temp-hum-1/properties/hum&quot;}]},&quot;temp&quot;:{&quot;type&quot;:&quot;number&quot;,&quot;readOnly&quot;:true,&quot;unit&quot;:&quot;degree celsius&quot;,&quot;title&quot;:&quot;Temp&quot;,&quot;@type&quot;:&quot;TemperatureProperty&quot;,&quot;links&quot;:[{&quot;href&quot;:&quot;/things/chosemaker-temp-hum-1/properties/temp&quot;}]}}}
</pre>


<p>在儀錶板的位置即可以看到加入的chosemaker Tempe and Hum設備，可以點擊該右上角小圖式打開可以看到溫度與濕度，我們預設讓溫度顯示排在最前面</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="788" height="479" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-5-1.jpg" alt="" class="wp-image-473" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-5-1.jpg 788w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-5-1-300x182.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-5-1-768x467.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-5-1-508x309.jpg 508w" sizes="(max-width: 788px) 100vw, 788px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="789" height="479" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-5-2.jpg" alt="" class="wp-image-474" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-5-2.jpg 789w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-5-2-300x182.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-5-2-768x466.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-5-2-508x308.jpg 508w" sizes="(max-width: 789px) 100vw, 789px" /></figure></div>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-5%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%235%5D%20WebThings%20IoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E9%80%A3%E7%B5%90ESP32%20Arduino%E9%96%8B%E7%99%BC%E6%9D%BF%E6%8A%93%E5%8F%96%E6%BA%AB%E5%BA%A6%E3%80%81%E6%BF%95%E5%BA%A6" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook_messenger" href="https://www.addtoany.com/add_to/facebook_messenger?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-5%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%235%5D%20WebThings%20IoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E9%80%A3%E7%B5%90ESP32%20Arduino%E9%96%8B%E7%99%BC%E6%9D%BF%E6%8A%93%E5%8F%96%E6%BA%AB%E5%BA%A6%E3%80%81%E6%BF%95%E5%BA%A6" title="Facebook Messenger" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_line" href="https://www.addtoany.com/add_to/line?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-5%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%235%5D%20WebThings%20IoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E9%80%A3%E7%B5%90ESP32%20Arduino%E9%96%8B%E7%99%BC%E6%9D%BF%E6%8A%93%E5%8F%96%E6%BA%AB%E5%BA%A6%E3%80%81%E6%BF%95%E5%BA%A6" title="Line" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-5%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%235%5D%20WebThings%20IoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E9%80%A3%E7%B5%90ESP32%20Arduino%E9%96%8B%E7%99%BC%E6%9D%BF%E6%8A%93%E5%8F%96%E6%BA%AB%E5%BA%A6%E3%80%81%E6%BF%95%E5%BA%A6" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-5%2F&#038;title=%5BWebThings%E6%95%99%E5%AD%B8%235%5D%20WebThings%20IoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E9%80%A3%E7%B5%90ESP32%20Arduino%E9%96%8B%E7%99%BC%E6%9D%BF%E6%8A%93%E5%8F%96%E6%BA%AB%E5%BA%A6%E3%80%81%E6%BF%95%E5%BA%A6" data-a2a-url="https://www.chosemaker.com/topic/webthings/webthings-5/" data-a2a-title="[WebThings教學#5] WebThings IoT物聯網平台連結ESP32 Arduino開發板抓取溫度、濕度"></a></p><p>這篇文章 <a rel="nofollow" href="https://www.chosemaker.com/topic/webthings/webthings-5/">[WebThings教學#5] WebThings IoT物聯網平台連結ESP32 Arduino開發板抓取溫度、濕度</a> 最早出現於 <a rel="nofollow" href="https://www.chosemaker.com">醬是創客</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[WebThings教學#4] WebThings IoT物聯網平台與ESP32 Arduino連動控制繼電器開啟、關閉電燈</title>
		<link>https://www.chosemaker.com/topic/webthings/webthings-4/</link>
		
		<dc:creator><![CDATA[pyclifecom]]></dc:creator>
		<pubDate>Thu, 15 Oct 2020 02:13:24 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[ESP32]]></category>
		<category><![CDATA[WebThings]]></category>
		<category><![CDATA[實作主題分類]]></category>
		<category><![CDATA[程式語言分類]]></category>
		<category><![CDATA[開發板分類]]></category>
		<guid isPermaLink="false">https://www.chosemaker.com/?p=463</guid>

					<description><![CDATA[<p>醬是創客的WebThings教學主題第4篇，以WebThings搭配Ai-Thinker安信可Nod &#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://www.chosemaker.com/topic/webthings/webthings-4/">[WebThings教學#4] WebThings IoT物聯網平台與ESP32 Arduino連動控制繼電器開啟、關閉電燈</a> 最早出現於 <a rel="nofollow" href="https://www.chosemaker.com">醬是創客</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>醬是創客的WebThings教學主題第4篇，以WebThings搭配Ai-Thinker安信可NodeMCU-32S(Arduino語言)來實作教學，本篇教學將著重使用ESP32與WebThings做出免費開源IoT物聯網平台連動，並透過平台控制繼電器開啟、關閉電燈，達到Server控制Client功能</p>



<p>以下是我們今天的目標</p>



<ul><li>使用WebThingAdapter.h與Thing.h</li><li>了解WebThingAdapter的更新方法</li><li>ThingDevice定義該設備定義(開關、溫度、濕度&#8230;&#8230;等)、描述、名稱、網址ID</li><li>ThingProperty定義多個Sensor屬性</li></ul>



<p>設備:<br>樹莓派4B #<a href="https://www.ruten.com.tw/item/show?22051318422459" target="_blank" rel="noreferrer noopener">露天拍賣</a> #<a href="https://shopee.tw/%E6%A8%B9%E8%8E%93%E6%B4%BE4B-%E8%8B%B1%E5%9C%8B%E8%A3%BD%E5%8E%9F%E5%BB%A0%E9%96%8B%E7%99%BC%E6%9D%BF-4G-8G-Raspberry-Pi-4B-AI%E5%BD%B1%E5%83%8F%E8%BE%A8%E8%AD%98-%E6%A9%9F%E5%99%A8%E5%AD%B8%E7%BF%92%E5%B0%88%E7%94%A8-Linux-i.293276804.5269190409" target="_blank" rel="noreferrer noopener">蝦皮購物</a><br>安信可NodeMCU-32S&nbsp;#<a href="https://www.ruten.com.tw/item/show?22030930136256" target="_blank" rel="noreferrer noopener">露天拍賣</a>&nbsp;#<a href="https://shopee.tw/ESP32-S-NodeMCU-32S-WiFi-%E8%97%8D%E8%8A%BDBLE-%E9%99%84Arduino%E6%95%99%E5%AD%B8-%E5%AE%89%E4%BF%A1%E5%8F%AF%E7%89%A9%E8%81%AF%E7%B6%B2IoT-Wi-Fi%E9%96%8B%E7%99%BC%E6%9D%BF-i.293276804.6546028316" target="_blank" rel="noreferrer noopener">蝦皮購物</a><br>DC5V控制AC110V繼電器&nbsp;#<a href="https://www.ruten.com.tw/item/show?22042646619226" target="_blank" rel="noreferrer noopener">露天拍賣</a>&nbsp;#<a href="https://shopee.tw/DC-5V%E7%B9%BC%E9%9B%BB%E5%99%A8%E6%8E%A7%E5%88%B6AC110V-220V-%E5%8F%AF%E8%87%AA%E9%81%B8%E9%AB%98%E4%BD%8E%E9%9B%BB%E4%BD%8D%E8%A7%B8%E7%99%BC-%E6%9C%89%E9%9B%BB%E6%BA%90-%E8%A8%8A%E8%99%9F%E7%87%88%E8%99%9F-ESP32-Arduino%E7%94%A8-i.293276804.5356886103" target="_blank" rel="noreferrer noopener">蝦皮購物</a><br>110V LED燈</p>



<p>接線方式:<br>NodeMCU-32S(GPIO22)–DO訊號–DC5V控制AC110V繼電器(IN訊號)<br>DC 5V(+)–DC5V控制AC110V繼電器(DC+)<br>DC 0V(-)–DC5V控制AC110V繼電器(DC-)<br>DC5V控制AC110V繼電器(COM)-2.0白扁線-110V市電火線<br>DC5V控制AC110V繼電器(NO)-2.0白扁線-110V LED電燈-110V市電水線<br>DC5V控制AC110V繼電器(H)使用高電位觸發</p>



<p>Ai-Thinker安信可NodeMCU-32S的腳位圍(資料來源:安信可)</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" width="868" height="923" src="https://www.chosemaker.com/wp-content/uploads/2020/07/nodemcu_32s_pin.png" alt="" class="wp-image-261" srcset="https://www.chosemaker.com/wp-content/uploads/2020/07/nodemcu_32s_pin.png 868w, https://www.chosemaker.com/wp-content/uploads/2020/07/nodemcu_32s_pin-282x300.png 282w, https://www.chosemaker.com/wp-content/uploads/2020/07/nodemcu_32s_pin-768x817.png 768w, https://www.chosemaker.com/wp-content/uploads/2020/07/nodemcu_32s_pin-329x350.png 329w" sizes="(max-width: 868px) 100vw, 868px" /></figure></div>



<p>Arduino 範例程式碼如下<br><strong>請注意: WordPress的bug，它把&amp;轉換成HTML的&amp;amp; <br>因此內文中有出現&amp;amp;請自行轉成&amp;</strong></p>


<pre class="brush: arduino; title: ; notranslate">
//醬是創客 開發實作的好夥伴
#define LARGE_JSON_BUFFERS 1
#include &lt;WiFi.h&gt;
#include &lt;Arduino.h&gt;
#include &lt;Thing.h&gt;
#include &lt;WebThingAdapter.h&gt;
//SSID/PW/Pin
const char *ssid = &quot;iot&quot;;
const char *password = &quot;chosemaker&quot;;
const int lampPin = 22;
//WebThings
WebThingAdapter *adapter;
const char *lampTypes[] = {&quot;OnOffSwitch&quot;, nullptr};
ThingDevice lamp(&quot;chosemaker-lamp-1&quot;, &quot;chosemaker Lamp&quot;, lampTypes);
ThingProperty lampOn(&quot;on&quot;, &quot;Whether the lamp is turned on&quot;, BOOLEAN,&quot;OnOffProperty&quot;);
bool lastOn = true;

void setup()
{
  Serial.begin(115200);
  
  pinMode(lampPin, OUTPUT);
  digitalWrite(lampPin, HIGH);
  WiFi.begin(ssid, password);    
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(&quot;.&quot;);
  }

  Serial.println(&quot;&quot;);
  Serial.print(&quot;Connected to &quot;);
  Serial.println(ssid);
  Serial.print(&quot;IP address: &quot;);
  Serial.println(WiFi.localIP());
  
  adapter = new WebThingAdapter(&quot;led-lamp&quot;, WiFi.localIP());
  lamp.description = &quot;IoT chosemaker lamp&quot;;
  lampOn.title = &quot;On/Off&quot;;
  lamp.addProperty(&amp;amp;lampOn);
  adapter-&gt;addDevice(&amp;amp;lamp);
  adapter-&gt;begin();

  Serial.println(&quot;HTTP server started&quot;);
  Serial.print(&quot;http://&quot;);
  Serial.print(WiFi.localIP());
  Serial.print(&quot;/things/&quot;);
  Serial.println(lamp.id);

  // set initial values
  ThingPropertyValue initialOn = {.boolean = true};
  lampOn.setValue(initialOn);
  (void)lampOn.changedValueOrNull();

}
  
void loop()
{
  adapter-&gt;update();
  bool on = lampOn.getValue().boolean;
  if (on) {
    digitalWrite(lampPin, HIGH);    
  } else {
    digitalWrite(lampPin, LOW);
  }

  if (lastOn != on) {
    lastOn = on;
  }
  delay(1000);
}
</pre>


<p>Arduino 序列埠監控視窗 輸出如下</p>


<pre class="brush: plain; title: ; notranslate">
Connected to iot
IP address: 192.168.2.188
MDNS responder started
HTTP server started
http://192.168.2.188/things/chosemaker-lamp-1

</pre>


<p>我們打開登入樹莓派的WebThings Gateway，在儀錶板的右下角點擊&#8221;+&#8221;並於&#8221;輸入web thing網址&#8221;輸入http://192.168.2.188/things/chosemaker-lamp-1，並儲存</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="689" height="336" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-1.jpg" alt="" class="wp-image-450" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-1.jpg 689w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-1-300x146.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-1-508x248.jpg 508w" sizes="(max-width: 689px) 100vw, 689px" /></figure></div>



<p>此時我們也可以連入http://192.168.2.188/things/chosemaker-lamp-1 ，可以看到這是一個JSON文件，Server於第一次取得設定檔時會連到Client抓取JSON回去對應欄位</p>


<pre class="brush: plain; title: ; notranslate">
{&quot;id&quot;:&quot;chosemaker-lamp-1&quot;,&quot;title&quot;:&quot;chosemaker Lamp&quot;,&quot;@context&quot;:&quot;https://iot.mozilla.org/schemas&quot;,&quot;description&quot;:&quot;IoT chosemaker lamp&quot;,&quot;base&quot;:&quot;http://192.168.2.188/&quot;,&quot;securityDefinitions&quot;:{&quot;nosec_sc&quot;:{&quot;scheme&quot;:&quot;nosec&quot;}},&quot;security&quot;:&quot;nosec_sc&quot;,&quot;@type&quot;:[&quot;OnOffSwitch&quot;],&quot;links&quot;:[{&quot;rel&quot;:&quot;properties&quot;,&quot;href&quot;:&quot;/things/chosemaker-lamp-1/properties&quot;},{&quot;rel&quot;:&quot;actions&quot;,&quot;href&quot;:&quot;/things/chosemaker-lamp-1/actions&quot;},{&quot;rel&quot;:&quot;events&quot;,&quot;href&quot;:&quot;/things/chosemaker-lamp-1/events&quot;},{&quot;rel&quot;:&quot;alternate&quot;,&quot;href&quot;:&quot;ws://192.168.2.188/things/chosemaker-lamp-1&quot;}],&quot;properties&quot;:{&quot;on&quot;:{&quot;type&quot;:&quot;boolean&quot;,&quot;title&quot;:&quot;On/Off&quot;,&quot;description&quot;:&quot;Whether the lamp is turned on&quot;,&quot;@type&quot;:&quot;OnOffProperty&quot;,&quot;links&quot;:[{&quot;href&quot;:&quot;/things/chosemaker-lamp-1/properties/on&quot;}]}}}
</pre>


<p>在儀錶板的位置即可以看到加入的chosemaker Lamp設備，可以點擊該圖式打開和關閉電燈開關</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="472" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-4-1-1024x472.jpg" alt="" class="wp-image-466" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-4-1-1024x472.jpg 1024w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-4-1-300x138.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-4-1-768x354.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-4-1-508x234.jpg 508w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-4-1.jpg 1280w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="1024" height="473" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-4-2-1024x473.jpg" alt="" class="wp-image-467" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-4-2-1024x473.jpg 1024w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-4-2-300x138.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-4-2-768x354.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-4-2-508x234.jpg 508w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-4-2.jpg 1272w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></div>



<p></p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-4%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%234%5D%20WebThings%20IoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E8%88%87ESP32%20Arduino%E9%80%A3%E5%8B%95%E6%8E%A7%E5%88%B6%E7%B9%BC%E9%9B%BB%E5%99%A8%E9%96%8B%E5%95%9F%E3%80%81%E9%97%9C%E9%96%89%E9%9B%BB%E7%87%88" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook_messenger" href="https://www.addtoany.com/add_to/facebook_messenger?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-4%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%234%5D%20WebThings%20IoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E8%88%87ESP32%20Arduino%E9%80%A3%E5%8B%95%E6%8E%A7%E5%88%B6%E7%B9%BC%E9%9B%BB%E5%99%A8%E9%96%8B%E5%95%9F%E3%80%81%E9%97%9C%E9%96%89%E9%9B%BB%E7%87%88" title="Facebook Messenger" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_line" href="https://www.addtoany.com/add_to/line?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-4%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%234%5D%20WebThings%20IoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E8%88%87ESP32%20Arduino%E9%80%A3%E5%8B%95%E6%8E%A7%E5%88%B6%E7%B9%BC%E9%9B%BB%E5%99%A8%E9%96%8B%E5%95%9F%E3%80%81%E9%97%9C%E9%96%89%E9%9B%BB%E7%87%88" title="Line" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-4%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%234%5D%20WebThings%20IoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E8%88%87ESP32%20Arduino%E9%80%A3%E5%8B%95%E6%8E%A7%E5%88%B6%E7%B9%BC%E9%9B%BB%E5%99%A8%E9%96%8B%E5%95%9F%E3%80%81%E9%97%9C%E9%96%89%E9%9B%BB%E7%87%88" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-4%2F&#038;title=%5BWebThings%E6%95%99%E5%AD%B8%234%5D%20WebThings%20IoT%E7%89%A9%E8%81%AF%E7%B6%B2%E5%B9%B3%E5%8F%B0%E8%88%87ESP32%20Arduino%E9%80%A3%E5%8B%95%E6%8E%A7%E5%88%B6%E7%B9%BC%E9%9B%BB%E5%99%A8%E9%96%8B%E5%95%9F%E3%80%81%E9%97%9C%E9%96%89%E9%9B%BB%E7%87%88" data-a2a-url="https://www.chosemaker.com/topic/webthings/webthings-4/" data-a2a-title="[WebThings教學#4] WebThings IoT物聯網平台與ESP32 Arduino連動控制繼電器開啟、關閉電燈"></a></p><p>這篇文章 <a rel="nofollow" href="https://www.chosemaker.com/topic/webthings/webthings-4/">[WebThings教學#4] WebThings IoT物聯網平台與ESP32 Arduino連動控制繼電器開啟、關閉電燈</a> 最早出現於 <a rel="nofollow" href="https://www.chosemaker.com">醬是創客</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[WebThings教學#3] WebThings Framework的Arduino Libraries套件安裝與環境設置</title>
		<link>https://www.chosemaker.com/topic/webthings/webthings-3/</link>
		
		<dc:creator><![CDATA[pyclifecom]]></dc:creator>
		<pubDate>Tue, 13 Oct 2020 06:58:25 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[ESP32]]></category>
		<category><![CDATA[WebThings]]></category>
		<category><![CDATA[實作主題分類]]></category>
		<category><![CDATA[程式語言分類]]></category>
		<category><![CDATA[開發板分類]]></category>
		<guid isPermaLink="false">https://www.chosemaker.com/?p=457</guid>

					<description><![CDATA[<p>醬是創客的WebThings教學主題第3篇，以WebThings搭配Ai-Thinker安信可Nod &#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://www.chosemaker.com/topic/webthings/webthings-3/">[WebThings教學#3] WebThings Framework的Arduino Libraries套件安裝與環境設置</a> 最早出現於 <a rel="nofollow" href="https://www.chosemaker.com">醬是創客</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>醬是創客的WebThings教學主題第3篇，以WebThings搭配Ai-Thinker安信可NodeMCU-32S(使用Arduino語言)來實作教學，本篇教學將著重WebThings Framework的Arduino Libraries套件安裝與環境設置，並需要安裝webthing-arduino、ESPAsyncWebServer、AsyncTCP套件</p>



<p>以下是我們今天的目標</p>



<ul><li>安裝套件webthing-arduino</li><li>安裝套件ESPAsyncWebServer</li><li>安裝套件AsyncTCP</li><li>找出電腦的Arduino對應Libraries路徑</li><li>Github下載套件</li></ul>



<p>設備:<br>安信可NodeMCU-32S #<a href="https://www.ruten.com.tw/item/show?22030930136256" target="_blank" rel="noreferrer noopener">露天拍賣</a> #<a href="https://shopee.tw/ESP32-S-NodeMCU-32S-WiFi-%E8%97%8D%E8%8A%BDBLE-%E9%99%84Arduino%E6%95%99%E5%AD%B8-%E5%AE%89%E4%BF%A1%E5%8F%AF%E7%89%A9%E8%81%AF%E7%B6%B2IoT-Wi-Fi%E9%96%8B%E7%99%BC%E6%9D%BF-i.293276804.6546028316" target="_blank" rel="noreferrer noopener">蝦皮購物</a></p>



<p>我們先找出電腦的Arduino對應Libraries路徑，打開 Arduino&gt;&gt;檔案&gt;&gt;偏好設定，在草稿碼簿的位置代表著Libraries與程式碼都在那</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="800" height="485" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-3-1.jpg" alt="" class="wp-image-459" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-3-1.jpg 800w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-3-1-300x182.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-3-1-768x466.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-3-1-508x308.jpg 508w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p>舉例來說草稿碼簿的位置是C:\Users\chosemaker\Documents\Arduino\，Libraries的路徑就會在C:\Users\chosemaker\Documents\Arduino\libraries</p>



<p>webthing-arduino套件請到 https://github.com/WebThingsIO/webthing-arduino/archive/master.zip 下載後並解壓縮至C:\Users\chosemaker\Documents\Arduino\libraries</p>



<p>ESPAsyncWebServer套件請到 https://github.com/me-no-dev/ESPAsyncWebServer/archive/master.zip 下載後並解壓縮至C:\Users\chosemaker\Documents\Arduino\libraries</p>



<p>AsyncTCP套件請到 https://github.com/me-no-dev/AsyncTCP/archive/master.zip 下載後並解壓縮至C:\Users\chosemaker\Documents\Arduino\libraries</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="807" height="373" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-3-2.jpg" alt="" class="wp-image-460" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-3-2.jpg 807w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-3-2-300x139.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-3-2-768x355.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings-3-2-508x235.jpg 508w" sizes="(max-width: 807px) 100vw, 807px" /></figure></div>



<p>將以上套件上入資料夾後，請關閉你的Arduino，並重新打開Arduino即可開始include套件</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-3%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%233%5D%20WebThings%20Framework%E7%9A%84Arduino%20Libraries%E5%A5%97%E4%BB%B6%E5%AE%89%E8%A3%9D%E8%88%87%E7%92%B0%E5%A2%83%E8%A8%AD%E7%BD%AE" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook_messenger" href="https://www.addtoany.com/add_to/facebook_messenger?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-3%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%233%5D%20WebThings%20Framework%E7%9A%84Arduino%20Libraries%E5%A5%97%E4%BB%B6%E5%AE%89%E8%A3%9D%E8%88%87%E7%92%B0%E5%A2%83%E8%A8%AD%E7%BD%AE" title="Facebook Messenger" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_line" href="https://www.addtoany.com/add_to/line?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-3%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%233%5D%20WebThings%20Framework%E7%9A%84Arduino%20Libraries%E5%A5%97%E4%BB%B6%E5%AE%89%E8%A3%9D%E8%88%87%E7%92%B0%E5%A2%83%E8%A8%AD%E7%BD%AE" title="Line" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-3%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%233%5D%20WebThings%20Framework%E7%9A%84Arduino%20Libraries%E5%A5%97%E4%BB%B6%E5%AE%89%E8%A3%9D%E8%88%87%E7%92%B0%E5%A2%83%E8%A8%AD%E7%BD%AE" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-3%2F&#038;title=%5BWebThings%E6%95%99%E5%AD%B8%233%5D%20WebThings%20Framework%E7%9A%84Arduino%20Libraries%E5%A5%97%E4%BB%B6%E5%AE%89%E8%A3%9D%E8%88%87%E7%92%B0%E5%A2%83%E8%A8%AD%E7%BD%AE" data-a2a-url="https://www.chosemaker.com/topic/webthings/webthings-3/" data-a2a-title="[WebThings教學#3] WebThings Framework的Arduino Libraries套件安裝與環境設置"></a></p><p>這篇文章 <a rel="nofollow" href="https://www.chosemaker.com/topic/webthings/webthings-3/">[WebThings教學#3] WebThings Framework的Arduino Libraries套件安裝與環境設置</a> 最早出現於 <a rel="nofollow" href="https://www.chosemaker.com">醬是創客</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[WebThings教學#2] 使用樹莓派當WebThings Gateway 開源物聯網CMS控制器伺服器主機</title>
		<link>https://www.chosemaker.com/topic/webthings/webthings-2/</link>
		
		<dc:creator><![CDATA[pyclifecom]]></dc:creator>
		<pubDate>Tue, 06 Oct 2020 07:47:21 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[WebThings]]></category>
		<category><![CDATA[實作主題分類]]></category>
		<category><![CDATA[樹莓派]]></category>
		<category><![CDATA[程式語言分類]]></category>
		<category><![CDATA[開發板分類]]></category>
		<guid isPermaLink="false">https://www.chosemaker.com/?p=447</guid>

					<description><![CDATA[<p>醬是創客的WebThings教學主題第2篇，以WebThings來實作教學，本篇教學將著重使用樹莓派 &#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://www.chosemaker.com/topic/webthings/webthings-2/">[WebThings教學#2] 使用樹莓派當WebThings Gateway 開源物聯網CMS控制器伺服器主機</a> 最早出現於 <a rel="nofollow" href="https://www.chosemaker.com">醬是創客</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>醬是創客的WebThings教學主題第2篇，以WebThings來實作教學，本篇教學將著重使用樹莓派當WebThings Gateway 開源物聯網CMS控制器伺服器主機與展示WebThings Gateway平台功能(Alarm、Log、Rule)，最常見的智慧家庭也可以透過該平台達到</p>



<p>設備:<br>1 x Raspberry Pi(建議3以上) 樹莓派4B #<a href="https://www.ruten.com.tw/item/show?22051318422459" target="_blank" rel="noreferrer noopener">露天拍賣</a> #<a href="https://shopee.tw/%E6%A8%B9%E8%8E%93%E6%B4%BE4B-%E8%8B%B1%E5%9C%8B%E8%A3%BD%E5%8E%9F%E5%BB%A0%E9%96%8B%E7%99%BC%E6%9D%BF-4G-8G-Raspberry-Pi-4B-AI%E5%BD%B1%E5%83%8F%E8%BE%A8%E8%AD%98-%E6%A9%9F%E5%99%A8%E5%AD%B8%E7%BF%92%E5%B0%88%E7%94%A8-Linux-i.293276804.5269190409" target="_blank" rel="noreferrer noopener">蝦皮購物</a><br>1 x Micro SD(Class 10, 8G以上)</p>



<p>第1步: 下載<a aria-label="undefined (opens in a new tab)" href="https://github.com/WebThingsIO/gateway/releases/download/0.12.0/gateway-0.12.0.img.zip" target="_blank" rel="noreferrer noopener">樹莓派的image檔案</a>，下載後先解壓縮該檔案成.img</p>



<p>第2步: 使用Win32DiskImager或Etcher將.img檔案燒入至Micro SD卡</p>



<p>第3步: 將Micro SD卡放入樹莓派，並開機</p>



<p>第4步: 樹莓派開機後，會自動變成Wi-Fi hotspot，打開你的手機或筆電，搜尋&#8221;WebThings Gateway XXXX&#8221;，XXXX代表樹莓派MAC address尾碼</p>



<p>第5步: 連上樹莓派後，輸入http://192.168.2.1，先設定樹莓派連結到你的Wi-Fi，並設定好帳號密碼等設定</p>



<p>第6步: 從你的無線路由器找出樹莓派的IP即可開始使用</p>



<p>我們來實測WebThings Gateway功能</p>



<p>可以透過URI的方式新增機器，另一端可以搭配Arduino或其他設備用WebThings Framework下去跑</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="689" height="336" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-1.jpg" alt="" class="wp-image-450" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-1.jpg 689w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-1-300x146.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-1-508x248.jpg 508w" sizes="(max-width: 689px) 100vw, 689px" /></figure></div>



<p>Dashboard儀錶板的部分，可以看出各設備的即時狀況，也可以點入再看細節，如溫度濕度</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="800" height="366" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-2.jpg" alt="" class="wp-image-451" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-2.jpg 800w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-2-300x137.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-2-768x351.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-2-508x232.jpg 508w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p>Rule控制部分，以下面的範例來說，當My Lamp的溫度大於33度的時候，My Lamp5的開關會被打開</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="800" height="364" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-3.jpg" alt="" class="wp-image-452" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-3.jpg 800w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-3-300x137.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-3-768x349.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-3-508x231.jpg 508w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p>記錄檔Log，可以記錄設備的連續數值，可以看到Chart的變化，但這個是存在SQLite裡面，記得自行計算IO效能</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="800" height="365" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-4.jpg" alt="" class="wp-image-453" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-4.jpg 800w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-4-300x137.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-4-768x350.jpg 768w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-4-508x232.jpg 508w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>



<p>最好用的莫過是附加元件，有好心人幫忙開發好一些套件，舉例可以送Alarm Notification到Telegram，這樣你就知道何時發生什麼事情</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="626" height="602" src="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-5.jpg" alt="" class="wp-image-454" srcset="https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-5.jpg 626w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-5-300x288.jpg 300w, https://www.chosemaker.com/wp-content/uploads/2020/10/webthings2-5-364x350.jpg 364w" sizes="(max-width: 626px) 100vw, 626px" /></figure></div>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-2%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%232%5D%20%E4%BD%BF%E7%94%A8%E6%A8%B9%E8%8E%93%E6%B4%BE%E7%95%B6WebThings%20Gateway%20%E9%96%8B%E6%BA%90%E7%89%A9%E8%81%AF%E7%B6%B2CMS%E6%8E%A7%E5%88%B6%E5%99%A8%E4%BC%BA%E6%9C%8D%E5%99%A8%E4%B8%BB%E6%A9%9F" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook_messenger" href="https://www.addtoany.com/add_to/facebook_messenger?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-2%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%232%5D%20%E4%BD%BF%E7%94%A8%E6%A8%B9%E8%8E%93%E6%B4%BE%E7%95%B6WebThings%20Gateway%20%E9%96%8B%E6%BA%90%E7%89%A9%E8%81%AF%E7%B6%B2CMS%E6%8E%A7%E5%88%B6%E5%99%A8%E4%BC%BA%E6%9C%8D%E5%99%A8%E4%B8%BB%E6%A9%9F" title="Facebook Messenger" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_line" href="https://www.addtoany.com/add_to/line?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-2%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%232%5D%20%E4%BD%BF%E7%94%A8%E6%A8%B9%E8%8E%93%E6%B4%BE%E7%95%B6WebThings%20Gateway%20%E9%96%8B%E6%BA%90%E7%89%A9%E8%81%AF%E7%B6%B2CMS%E6%8E%A7%E5%88%B6%E5%99%A8%E4%BC%BA%E6%9C%8D%E5%99%A8%E4%B8%BB%E6%A9%9F" title="Line" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-2%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%232%5D%20%E4%BD%BF%E7%94%A8%E6%A8%B9%E8%8E%93%E6%B4%BE%E7%95%B6WebThings%20Gateway%20%E9%96%8B%E6%BA%90%E7%89%A9%E8%81%AF%E7%B6%B2CMS%E6%8E%A7%E5%88%B6%E5%99%A8%E4%BC%BA%E6%9C%8D%E5%99%A8%E4%B8%BB%E6%A9%9F" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-2%2F&#038;title=%5BWebThings%E6%95%99%E5%AD%B8%232%5D%20%E4%BD%BF%E7%94%A8%E6%A8%B9%E8%8E%93%E6%B4%BE%E7%95%B6WebThings%20Gateway%20%E9%96%8B%E6%BA%90%E7%89%A9%E8%81%AF%E7%B6%B2CMS%E6%8E%A7%E5%88%B6%E5%99%A8%E4%BC%BA%E6%9C%8D%E5%99%A8%E4%B8%BB%E6%A9%9F" data-a2a-url="https://www.chosemaker.com/topic/webthings/webthings-2/" data-a2a-title="[WebThings教學#2] 使用樹莓派當WebThings Gateway 開源物聯網CMS控制器伺服器主機"></a></p><p>這篇文章 <a rel="nofollow" href="https://www.chosemaker.com/topic/webthings/webthings-2/">[WebThings教學#2] 使用樹莓派當WebThings Gateway 開源物聯網CMS控制器伺服器主機</a> 最早出現於 <a rel="nofollow" href="https://www.chosemaker.com">醬是創客</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[WebThings教學#1] 開源物聯網IoT平台與設備專案WebThings Gateway與Framework介紹</title>
		<link>https://www.chosemaker.com/topic/webthings/webthings-1/</link>
		
		<dc:creator><![CDATA[pyclifecom]]></dc:creator>
		<pubDate>Wed, 30 Sep 2020 07:32:12 +0000</pubDate>
				<category><![CDATA[WebThings]]></category>
		<category><![CDATA[實作主題分類]]></category>
		<guid isPermaLink="false">https://www.chosemaker.com/?p=444</guid>

					<description><![CDATA[<p>醬是創客的WebThings教學主題第1篇，以WebThings來實作教學，本篇教學將著重介紹Web &#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://www.chosemaker.com/topic/webthings/webthings-1/">[WebThings教學#1] 開源物聯網IoT平台與設備專案WebThings Gateway與Framework介紹</a> 最早出現於 <a rel="nofollow" href="https://www.chosemaker.com">醬是創客</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>醬是創客的WebThings教學主題第1篇，以WebThings來實作教學，本篇教學將著重介紹WebThings Gateway與WebThings Framework，WebThings原先Mozilla專案，2020下半年Mozilla WebThings將更名成為WebThings，新網站將搬到webthings.io。它提供了免費IoT平台、Alarm、Log、Rule和各式程式語言供整合</p>



<p>WebThings Gateway可以當成簡易的平台，可以在樹莓派/Linux/Docker下跑，這個開源平台支援Alarm(EX: 當溫度設備觸發條件以後，可以透過E-mail、通訊App收到notification通知)、Log(紀錄連續時間的設備數值)、Rule(EX: 當溫度設備觸發條件以後，會讓某一台設備的relay動作)、人員管理</p>



<p>WebThings Framework可以當成資料挖掘或控制edge設備，舉例來說我們可以用import Arduino的WebThings Framework lib，並自行寫好對應的程式(可以寫ESP32與relay on/off控制、或透過ESP32抓回modbus溫濕度後拋往Gateway)，並讓WebThings Gateway可以直接連線控制，目前支援Arduino、Node.js、Python、Java、Rust、MicroPython</p>



<p>我們來分析一下技術面</p>



<p>WebThings Gateway是以Node.js來寫的，並搭配sqlite3來儲存Log資料，我想大家也知道sqlite和MySQL和MSSQL的差別，簡單說WebThings Gateway就是定義存放少量設備的連續數值，因為它最主要的目的是拿來用Rule和Notification來控制IoT設備的運作與告警，如果你是用樹莓派來跑WebThings Gateway並開啟Log，就要小心長時間後Micro SD卡容易壞掉。WebThings Gateway會透過網路來控制/管理/推撥WebThings Framework的設備，那如果網路斷線怎麼辦?當然是全部都不會動，所以如何用出好的網路環境，是重要的課題，我想現在網路技術穩定性很高，坊間也有專做商用/工業網路的系統整合商，這應該不難。通常會選擇WebThings的解決方案，就是要為了高CP值省錢，通常不會把軟體/硬體規格搞得非常複雜。如果真的要防ESD、突波、雷擊、放在無塵室或工業環境，這種都會去找研華和Moxa並搭配它們的平台設計</p>



<p>我們來看實際應用</p>



<p>安橋聖科技將WebThings放於有預算限制的小型智慧農業，設備有一台樹莓派(WebThings Gateway)、數台ESP32搭配relay(WebThings Framework的設備)、數台ESP32搭配溫濕度計(WebThings Framework的設備)、網路設備，並透過溫溼度規則來控制風機，通常這些都可以很穩定的運作，但最重要的就是無線網路，無線網路在高濕度和低濕度的表現都會不同，這也是所提到的天氣與網路穩定性會影響是否能正常運作</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-1%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%231%5D%20%E9%96%8B%E6%BA%90%E7%89%A9%E8%81%AF%E7%B6%B2IoT%E5%B9%B3%E5%8F%B0%E8%88%87%E8%A8%AD%E5%82%99%E5%B0%88%E6%A1%88WebThings%20Gateway%E8%88%87Framework%E4%BB%8B%E7%B4%B9" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook_messenger" href="https://www.addtoany.com/add_to/facebook_messenger?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-1%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%231%5D%20%E9%96%8B%E6%BA%90%E7%89%A9%E8%81%AF%E7%B6%B2IoT%E5%B9%B3%E5%8F%B0%E8%88%87%E8%A8%AD%E5%82%99%E5%B0%88%E6%A1%88WebThings%20Gateway%E8%88%87Framework%E4%BB%8B%E7%B4%B9" title="Facebook Messenger" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_line" href="https://www.addtoany.com/add_to/line?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-1%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%231%5D%20%E9%96%8B%E6%BA%90%E7%89%A9%E8%81%AF%E7%B6%B2IoT%E5%B9%B3%E5%8F%B0%E8%88%87%E8%A8%AD%E5%82%99%E5%B0%88%E6%A1%88WebThings%20Gateway%E8%88%87Framework%E4%BB%8B%E7%B4%B9" title="Line" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-1%2F&amp;linkname=%5BWebThings%E6%95%99%E5%AD%B8%231%5D%20%E9%96%8B%E6%BA%90%E7%89%A9%E8%81%AF%E7%B6%B2IoT%E5%B9%B3%E5%8F%B0%E8%88%87%E8%A8%AD%E5%82%99%E5%B0%88%E6%A1%88WebThings%20Gateway%E8%88%87Framework%E4%BB%8B%E7%B4%B9" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.chosemaker.com%2Ftopic%2Fwebthings%2Fwebthings-1%2F&#038;title=%5BWebThings%E6%95%99%E5%AD%B8%231%5D%20%E9%96%8B%E6%BA%90%E7%89%A9%E8%81%AF%E7%B6%B2IoT%E5%B9%B3%E5%8F%B0%E8%88%87%E8%A8%AD%E5%82%99%E5%B0%88%E6%A1%88WebThings%20Gateway%E8%88%87Framework%E4%BB%8B%E7%B4%B9" data-a2a-url="https://www.chosemaker.com/topic/webthings/webthings-1/" data-a2a-title="[WebThings教學#1] 開源物聯網IoT平台與設備專案WebThings Gateway與Framework介紹"></a></p><p>這篇文章 <a rel="nofollow" href="https://www.chosemaker.com/topic/webthings/webthings-1/">[WebThings教學#1] 開源物聯網IoT平台與設備專案WebThings Gateway與Framework介紹</a> 最早出現於 <a rel="nofollow" href="https://www.chosemaker.com">醬是創客</a>。</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
