or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
DashBoard
dataflow diagram
Sensor收到資料後透過DA送進IoTtalk Server。
由ODF的DA將資料拉下來寫入mysql。
當資料寫入mysql後,dashboard會定期去mysql取資料顯示在Dashboard上。
經由config動作:Dashboard知道要去詢問mysql內的哪些DB以顯示資料,DA知道要去讀取哪些ODF以將資料存入mysql。
Sensor設定與連接包含兩個步驟:
environment
適用ubuntu 16.04 or ubuntu 18.04
可輸入指令:
cat /etc/os-release
查看系統資訊reference 1 2
sudo apt-get -y install python3-pip
sudo apt-get install mysql-server
sudo pip3 install PyMySQL
sudo apt-get install git-core
sudo apt-get install tmux
先選定兩台VM:
mysql
mysql_secure_installation
操作參考
mysql -u root -p
status
編碼應該要如上圖:四個都是utf8
sudo vim /etc/mysql/my.cnf
[mysqld]
init_connect = 'SET collation_connection = utf8_bin'
init_connect = 'SET NAMES utf8'
character-set-server = utf8
collation-server = utf8_bin
:wq
sudo service mysql restart
mysql -u root -p
status
CREATE USER 'user_name'@'%' IDENTIFIED BY 'user_password';
設定new user的user_name(e.g dashboard),允許連線的IP( %:代表允許任一IP連線)和user_password
GRANT ALL PRIVILEGES ON *.* TO 'user_name'@'%';
flush privileges;
說明:
ALL PRIVILEGES
: allow the user to read, edit, execute and perform all tasks across all the databases and tables.*.*
:The asterisks in this command refer to the database and table that they can access.(* represents that all databases and tables are available)
flush privileges;
:刷新權限以更新權限設定create database db_name;
建立給dashboard使用的database,設定db_name (e.g dashboard)
dashboard
git clone https://gitlab.com/IoTtalk/FarmDashboard.git
cd FarmDashboard
sudo pip3 install -r requirements.txt
requirements.txt內容如下:
vim config.py
修改第8行和第14行如下:
DB_CONFIG = 'mysql+pymysql://user_name:user_password@localhost:3306/db_name?charset=utf8'
填入在mysql步驟中新增的user_name,user_password和db_name
CSM_HOST = 'iottalk_server IP'
填入已安裝iottalk_server的VM IP
(e.g
CSM_HOST= '140.113.199.213'
)看情況修改,可以修改預設的帳號以及密碼。
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
<註>倘若您的Ubuntu版本為14.04,請至/etc/mysql/my.cnf修改
sudo vim /etc/mysql/my.cnf
註解第43行:bind 127.0.0.1
因為127.0.0.1 意指 Localhost,也就是本機
用戶端,倘若設了127.0.0.1,就永遠都找不到AD,故須將其註解掉。
vim app.py
press Shift+g: 跳至最後一行
修改第818行如以下:
app.run('0', port=7788, debug=config.DEBUG, threaded=True)
python3 db.py init
因為只會新加入資料,並不會抹除舊的資料,所以執行一次以上會發生錯誤
tmux a
press Ctrl+B 1或Ctrl+B 2切換tmux查看dashboard連接狀況
開啟瀏覽器:輸入網址dashboard VM IP:7788查看dashboard
(e.g http://140.113.199.223:7788/)
看到以上畫面,代表dashboard安裝設定完成
iottalk server
(二擇一)
1.1 重啟後檢查screen有無錯誤訊息
sudo reboot
screen -r
1.2 開啟htop檢查儲存空間是否足夠,如果不足,screen可能會產生錯誤訊息如下:
OSError: [Errno 28] No space left on device
處理流程:
cd iottalk_...
rm -rf log/*
sudo journalctl --vacuum-size=1M
sudo apt autoremove -f
sudo apt clean
sudo apt autoclean
參考連結
如果在IoTtalk Server IP:9999/list_all(e.g: http://140.113.199.213:9999/list_all)上可以看到資料,則代表資料已經到IoTtalk Server上的IDF module。
sensors(IDF/ODF)
IDF
(e.g http://140.113.199.213:7788/dfm)
(e.g
vim iottalk_server_1.0/da/Map/FetchData/FetchData_OrchidHouse/DAI.py
)3.1 modify line 5 : 將server url由map.iottalk.tw改成IoTtalk server IP (e.g http://140.113.199.213:9999)
3.2 update line 9 : add IDF_name
3.3 update line 14 : add corresponding UUID
3.4 update line 19 : add variable to store the result of fetchdata.py
3.5 update line 27 : add DAN.push(…) to send data with HTTP
ODF(使用dashboard的GUI新增ODF)
(e.g http://140.113.199.223:7788/)
4.1 點擊Sensor查看Sensors列表
4.2 點擊add按鈕進入Sensor Management介面
4.3 輸入對應的sensor內容
(e.g)
5.1 click Field to look through Fields list
5.2 push the
add
button to enter Field Management interface5.3 fill in corresponding field contents
(e.g)
+
button besides sensors to add corresponding sensors to the field(e.g http://140.113.199.213:7788/connection)
6.1 根據project選擇對應IDF和ODF
6.2 將IDF與ODF連線(注意:一個project內不能出現超過30個join否則會出現internal server error)
6.3 選擇對應device_name
(check the result with iottalk server IP/list_all)
(e.g http://140.113.199.213:9999/list_all)
可參考video進行操作
Q&A
Q1:如果執行tmux a查看dashboard狀況時,出現如上圖中的錯誤訊息時,該如何處理?
A1:處理流程如下:
1.1. 跳出tmux: press Ctrl+B D
1.2. 安裝虛擬環境venv:
virtualenv venv
1.3. 激活虛擬環境:
source venv/bin/activate
因為進入venv後等同於進入一個新環境,故須重新安裝相關檔案。
sudo pip install -r requirements.txt
bash startup.sh
tmux a
press Ctrl+B 1或2切換tmux查看dashboard連接狀況
6.1.
sudo reboot
6.2. 重複步驟3~5
Q2:如果執行tmux a查看dashboard狀況時,出現如上圖中的錯誤訊息時,該如何處理?
A2:這是因為iottalk server沒有對應的DM,所產生的錯誤訊息。
處理流程如下:
Reference