Sensor收到資料後透過DA送進IoTtalk Server。
由ODF的DA將資料拉下來寫入mysql。
當資料寫入mysql後,dashboard會定期去mysql取資料顯示在Dashboard上。
經由config動作:Dashboard知道要去詢問mysql內的哪些DB以顯示資料,DA知道要去讀取哪些ODF以將資料存入mysql。
Sensor設定與連接包含兩個步驟:
適用ubuntu 16.04 or ubuntu 18.04
可輸入指令:cat /etc/os-release
查看系統資訊
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_secure_installation
mysql -u root -p
status
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';
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.flush privileges;
:刷新權限以更新權限設定create database db_name;
git clone https://gitlab.com/IoTtalk/FarmDashboard.git
cd FarmDashboard
sudo pip3 install -r requirements.txt
vim config.py
DB_CONFIG = 'mysql+pymysql://user_name:user_password@localhost:3306/db_name?charset=utf8'
CSM_HOST = 'iottalk_server IP'
CSM_HOST= '140.113.199.213'
)sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
sudo vim /etc/mysql/my.cnf
vim app.py
app.run('0', port=7788, debug=config.DEBUG, threaded=True)
python3 db.py init
tmux a
(二擇一)
sudo reboot
screen -r
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。
IDF
vim iottalk_server_1.0/da/Map/FetchData/FetchData_OrchidHouse/DAI.py
)ODF(使用dashboard的GUI新增ODF)
name | df_name | alias | unit | icon | color |
---|---|---|---|---|---|
humidity1 | Humidity-O1 | 入口濕度 | % | ion-waterdrop | bg-aqua |
4.4 點擊create建立新sensor |
add
button to enter Field Management interfacename | 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 |
可參考video進行操作
Q1:如果執行tmux a查看dashboard狀況時,出現如上圖中的錯誤訊息時,該如何處理?
A1:處理流程如下:
virtualenv venv
source venv/bin/activate
sudo pip install -r requirements.txt
bash startup.sh
tmux a
sudo reboot
Q2:如果執行tmux a查看dashboard狀況時,出現如上圖中的錯誤訊息時,該如何處理?
A2:這是因為iottalk server沒有對應的DM,所產生的錯誤訊息。
處理流程如下: