close
今年Maker Faire Taipei前拿到QNAP的新玩意 - QBoat Sunny,一塊和Rasperry Pi差不多長相的開發板,但既然是QNAP出的,自然和NAS脫不了關係,沒錯,它就是一塊單板NAS,本來NAS伺服器該有的功能,它具體而微地都能提供,最大的差異之處在於儲存容量:QBoat Sunny是存在SSD中,自然沒有HDD那麼大容量,但用於Edge Computing是很夠了。

實際測試了一下,覺得QNAP這次該是打中了IoT市場需求的痛點。怎麼說呢?很多人會說:「不過就是壓低成本改用ARM當base,把硬碟改成SSD做的NAS而已啊!」當你講這句話的時候,就自己打嘴巴了!NAS不是PC灌個Windows或Linux當檔案與資料庫伺服器,真正的NAS核心精神,是要整合自身的軟體與硬體雙重資源,讓NAS本身在網路運算與服務上可以顯示出價值!換句話來說,不是看體積大小、執行效率….等,而是可以「適時提供使用者需要的服務功能」才是NAS的價值。

接下來,我們就逐步透過不同的應用呈現,來看QBoat Sunny到底有何長處。第一個就先用WiFi無線感測當作場景,看看能有多省事吧!

基礎架構
d



  • MediaTek LinkIt 7697的部分


可以透過HTTP Request命令DHT11以網頁的方式回傳DHT11的溫溼度讀值,腳位連接的方式:




















DHT11



MediaTek LinkIt 7697



+


5V

-



GND


DO

P3



 

原始程式碼如下;就是透過LWiFi連結Wireless AP router,並且套用DHT11的程式庫,可以編譯完成後以瀏覽器試試看,例如 : http://192.168.1.xxx/temp 看會否傳出溫度的值
















GET參數


功用

/temp



取得攝氏溫度


/humi

取得濕度百分比值



程式碼如下:
<< MonitorNode.ino >>

#include <LWiFi.h>
#include "DHT.h"

#define DHTPIN 3 // what digital pin we’re connected to
#define WARNPIN 13

// Uncomment whatever type you’re using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);

char ssid[] = “LaisanHere”; // your network SSID (name)
char pass[] = “t101419008”; // your network password
int keyIndex = 0; // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(80);

void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print(“Attempting to connect to SSID: “);
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
}
server.begin();
// you’re connected now, so print out the status:
printWifiStatus();

// Activate DHT11
dht.begin();

pinMode(WARNPIN, OUTPUT);
digitalWrite(WARNPIN, LOW);
}
void loop() {
// listen for incoming clients
WiFiClient client = server.available();
if (client) {
Serial.println(“new client”);

String msg;
String param;

// an http request ends with a blank line
if (client.connected()) {
while (client.available()) {
char c = client.read();
msg += String(c);
}
}

Serial.print(msg);

int posi = msg.indexOf(“Referer: “);
if(posi > 0)
{
String sb = msg.substring(posi);
int p = sb.indexOf(“/”);
param = sb.substring(p+2);
p = param.indexOf(“/”);
param = param.substring(p, p+5);
}
else
{
posi = msg.indexOf(“GET”);
param = msg.substring(posi+4, posi+9);
}

Serial.println(param);

// send a standard http response header
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println(“Connection: close”); // the connection will be closed after completion of the response
client.println();

if(param == “/warn”)
{
digitalWrite(WARNPIN, HIGH);
client.println(“WARNING !!”);
}
if(param == “/cler”)
{
digitalWrite(WARNPIN, LOW);
client.println(“CLEAR”);
}
if(param == “/temp”)
{
float t = dht.readTemperature();
client.println(t);
}
if(param == “/humi”)
{
float h = dht.readHumidity();
client.println(h);
}

// close the connection:
client.stop();
Serial.println(“client disonnected”);
}

// give the web browser time to receive the data
delay(100);
}

void printWifiStatus() {
// print the SSID of the network you’re attached to:
Serial.print(“SSID: “);
Serial.println(WiFi.SSID());

// print your WiFi shield’s IP address:
IPAddress ip = WiFi.localIP();
Serial.print(“IP Address: “);
Serial.println(ip);

// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print(“signal strength (RSSI):”);
Serial.print(rssi);
Serial.println(” dBm”);
}



  • QBoat Sunny的部分


透過QIoT Suite Lite之中有內建的Node-red,透過在瀏覽器上呈現的GUI拖曳與設定,就能夠以HTTP Request分別0.5、1分鐘,分別讀取DHT11上的溫度和濕度。

  • 教學描述影片


https://www.facebook.com/QNAPIoT/videos/919521734883909/
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 tttt 的頭像
    tttt

    觀察筆記

    tttt 發表在 痞客邦 留言(0) 人氣()