jyneda
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # DashBoard ## dataflow diagram ![](https://i.imgur.com/AU8Oqrf.jpg) Sensor收到資料後透過DA送進IoTtalk Server。 由ODF的DA將資料拉下來寫入mysql。 當資料寫入mysql後,dashboard會定期去mysql取資料顯示在Dashboard上。 經由config動作:Dashboard知道要去詢問mysql內的哪些DB以顯示資料,DA知道要去讀取哪些ODF以將資料存入mysql。 Sensor設定與連接包含兩個步驟: 1. 在Dashboard上做sensor的設定。(有哪些sensor要讀取) 2. 在IoTtalk Server上建立對應的ODF module。 ## environment 適用**ubuntu 16.04** or **ubuntu 18.04** 可輸入指令:`cat /etc/os-release`查看系統資訊 * ubuntu server reference [1](https://magiclen.org/ubuntu-server-18-04/) [2](https://tutorials.ubuntu.com/tutorial/tutorial-install-ubuntu-server#0) * pip3 `sudo apt-get -y install python3-pip` * mysql-server(check install status) `sudo apt-get install mysql-server` * password setting:輸入自訂密碼(8位以上) (e.g userpassword) * pymysql `sudo pip3 install PyMySQL` * git `sudo apt-get install git-core` * tmux `sudo apt-get install tmux` 先選定兩台VM: * VM1用途:IoTtalk server * VM2用途:dashboard+mysql * 先請資訊中心明樺先生開啟VM2的7788port ## mysql * mysql security setting `mysql_secure_installation` [操作參考](https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04#step-2-install-mysql) * login mysql(以root使用者登入) `mysql -u root -p` * check characterset status `status` ![](https://i.imgur.com/4P5Dobl.png) 編碼應該要如上圖:四個都是utf8 * Server characterset不是utf8的處理流程: 1. 先按Ctrl+D登出MySQL 2. 編輯 /etc/mysql/my.cnf `sudo vim /etc/mysql/my.cnf` 3. 按 i 進入insert mode 4. 加入設定:複製下列程式碼,於my.cnf貼上 `[mysqld]` `init_connect = 'SET collation_connection = utf8_bin'` `init_connect = 'SET NAMES utf8'` `character-set-server = utf8` `collation-server = utf8_bin` 5. 按ESC退出insert mode 6. 存檔 `:wq` 7. 重啟mysql以更新設定 `sudo service mysql restart` 8. login mysql(以root使用者登入) `mysql -u root -p` 9. check characterset status `status` * create new user for dashboard `CREATE USER 'user_name'@'%' IDENTIFIED BY 'user_password';` 設定new user的user_name(e.g dashboard),允許連線的IP( %:代表允許任一IP連線)和user_password * create privileges for new user `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 for dashboard `create database db_name;` 建立給dashboard使用的database,設定db_name (e.g dashboard) ## dashboard * install dashboard * get FarmDashboard by using git clone `git clone https://gitlab.com/IoTtalk/FarmDashboard.git` * connect dashboard to mysql * install requirements.txt by pip3(安裝所需Python Packages) `cd FarmDashboard` `sudo pip3 install -r requirements.txt` requirements.txt內容如下: * sqlalchemy * requests * flask * python-dateutil * pymysql * alembic==1.0.5 * modify [config.py](https://github.com/IoTtalk/FarmDashboard/blob/master/config.py) `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'`) * modify [db_init.json](https://github.com/IoTtalk/FarmDashboard/blob/master/db_init.json) 看情況修改,可以修改預設的帳號以及密碼。 * modify /etc/mysql/mysql.conf.d/mysqld.cnf `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,故須將其註解掉。 * 修改[app.py](https://github.com/IoTtalk/FarmDashboard/blob/master/app.py),這裡假設的 port=7788,如果要在其他的port使用,請自行更改。(如果沒有修改,就是預設port 5000) `vim app.py` press Shift+g: 跳至最後一行 修改第818行如以下: `app.run('0', port=7788, debug=config.DEBUG, threaded=True)` * 新增dashboard 資料至mysql `python3 db.py init` 因為只會新加入資料,並不會抹除舊的資料,所以執行一次以上會發生錯誤 * check dashboard installation status * `tmux a` press Ctrl+B 1或Ctrl+B 2切換tmux查看dashboard連接狀況 * 網頁檢查: 開啟瀏覽器:輸入網址dashboard VM IP:7788查看dashboard (e.g http://140.113.199.223:7788/) ![](https://i.imgur.com/eDsM0Vc.png) 看到以上畫面,代表dashboard安裝設定完成 ## iottalk server (二擇一) 1. 使用已安裝iottalk server的VM 1.1 重啟後檢查screen有無錯誤訊息 `sudo reboot` `screen -r` 1.2 開啟htop檢查儲存空間是否足夠,如果不足,screen可能會產生錯誤訊息如下: OSError: [Errno 28] No space left on device 處理流程: * 刪除 all log file: 刪除iottalk_...../log/ 下面所有檔案 `cd iottalk_...` `rm -rf log/*` * 限制系統日誌大小,只需要執行一次 `sudo journalctl --vacuum-size=1M` * `sudo apt autoremove -f` * `sudo apt clean` * `sudo apt autoclean` 2. 自行安裝 iottalk server [參考連結](https://iottalk.vip/2/#QKINST) 如果在IoTtalk Server IP:9999/list_all(e.g: http://140.113.199.213:9999/list_all)上可以看到資料,則代表資料已經到IoTtalk Server上的IDF module。 ## sensors(IDF/ODF) * IDF 1. 在iottalk server的GUI上新增對應IDF與ODF (e.g http://140.113.199.213:7788/dfm) 2. 在iottalk server的GUI上新增對應DM 3. 修改iottalk server上的[DAI.py](https://gitlab.com/IoTtalk/iottalk-v1/blob/master/da/Map/FetchData/FetchData_OrchidHouse/DAI.py) (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](https://gitlab.com/IoTtalk/iottalk-v1/blob/master/da/Map/FetchData/FetchData_OrchidHouse/fetchData.py) 3.5 update line 27 : add DAN.push(...) to send data with HTTP * ODF(使用dashboard的GUI新增ODF) 1. 開啟瀏覽器:輸入網址dashboard VM IP:7788查看dashboard (e.g http://140.113.199.223:7788/) 2. 以管理者身分登入(e.g admin) 3. 點擊左方列表內的系統管理按鈕 4. 新增對應sensors 4.1 點擊Sensor查看Sensors列表 4.2 點擊add按鈕進入Sensor Management介面 4.3 輸入對應的sensor內容 (e.g) |name|df_name|alias|unit|icon|color| |-|-|-|-|-|-| |humidity1|Humidity-O1|入口濕度|%|ion-waterdrop|bg-aqua| 4.4 點擊create建立新sensor 5. create fields 5.1 click Field to look through Fields list 5.2 push the `add` button to enter Field Management interface 5.3 fill in corresponding field contents (e.g) |name|alias| |-|-| |floor1|蘭花屋一樓| 5.4 push the `+` button besides sensors to add corresponding sensors to the field 5.5 push the create button to add field to the dashboard 6. 在iottalk server IP:7788/connection內新增project (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 7. open dashboard (e.g http://140.113.199.223:7788/) to see the result (check the result with iottalk server IP/list_all) (e.g http://140.113.199.213:9999/list_all) 可參考[video](https://drive.google.com/drive/u/0/folders/13AyBQ-3m_RuPOW1J2aR1yD0svUKuEFdg)進行操作 ## Q&A ![](https://i.imgur.com/tpofZnO.png) Q1:如果執行tmux a查看dashboard狀況時,出現如上圖中的錯誤訊息時,該如何處理? A1:處理流程如下: 1. 安裝venv 1.1. 跳出tmux: press Ctrl+B D 1.2. 安裝虛擬環境venv: `virtualenv venv` 1.3. 激活虛擬環境: `source venv/bin/activate` 2. 重新安裝requirements.txt 因為進入venv後等同於進入一個新環境,故須重新安裝相關檔案。 `sudo pip install -r requirements.txt` 3. 重啟dashboard以更新DA狀態 `bash startup.sh` 4. check dashboard status `tmux a` press Ctrl+B 1或2切換tmux查看dashboard連接狀況 5. 開啟瀏覽器,輸入網址: dashboard VM IP:7788 查看dasboard 6. 倘若還是無法正常連線,請重啟VM試試 6.1. `sudo reboot` 6.2. 重複步驟3~5 --- ![](https://i.imgur.com/Ie9tr08.png =350x) Q2:如果執行tmux a查看dashboard狀況時,出現如上圖中的錯誤訊息時,該如何處理? A2:這是因為iottalk server沒有對應的DM,所產生的錯誤訊息。 處理流程如下: 1. 開啟瀏覽器,輸入網址: IoTtalk server IP:9999進入IoTtalk Homepage 2. 點擊[Device Feature Management](http://140.113.199.222:7788/dfm)進入DF、DM管理介面 3. 點擊左上Device Feature按鈕,切換至Device Model Window 4. 點擊add new DM後,勾選要加入的ODF 5. 點擊save按鈕存檔 6. 輸入device model name(e.g DataServer) ## Reference

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    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.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully