2016年7月30日 星期六

Introduction to mbed Device Connector










    


# ARM mbed #IoT # Raspberry Pi 







相關連結:

1)Raspberry Pi 上編譯mbed client http://blog.ittraining.com.tw/2016/06/raspberry-pi-mbed-client.html#links

2) To Deploy mbed IoT cloud
http://blog.ittraining.com.tw/2016/07/to-deploy-mbed-iot-cloud.html

3)ARM mbed cloud server https://connector.mbed.com/ 4)ARM mbed cloud slide http://blog.ittraining.com.tw/2016/08/arm-mbed-client-code.html



艾鍗 ARM mbed GitHub:

ARM mbed Client on Raspberry Pi 3
git clone https://github.com/ntu-joseph/iot_demo.git

ARM mbed Cloud WebAPP
git clone https://github.com/it-robot/mbed-webapp.git



2016年7月26日 星期二

2016年7月24日 星期日

利用CNY70量測心跳



在經過多次專題實驗後, 決定利用CNY70 紅外線感應器製作紅外線感應電路模組,未來可以很快進行到以心律相關的研究主題。然而光製作一個CNY70紅外線反射模組,離取得心跳還有段距離. 我們整理了要畫出一個心律圖的波形, 從底層韌體、心律訊號演算法的處理,到上層HMI 人機界面, 大概要了解以下主題。

  1. CNY70 心律感測器電路設計
  2. 邏輯分析儀之數位訊號分析
  3. ADC取樣處理
  4. CNY70 心律訊號與演算法分析
  5. Python GUI 圖控介面設計


CNY 70  基本方塊

「CNY70」的圖片搜尋結果

「CNY70」的圖片搜尋結果





參考資料: 

  1. CNY70 DataSheet
  2. 連接MCU 使用ADC
  3. 感測電路應用設計


-----------------------------------------------------------------------------------------------


1) CNY70 結合Raspberry Pi +ESP8266 Wi-Fi 應用 


IoT of heart rate watchdog from 義方 陳

2) 穿戴式裝置 (包含CNY70作為心跳量測)



3)  CNY70心跳量測結合藍芽與2.4GRF(CC2500) 應用





2016年7月16日 星期六

登出後程序繼續跑 nohup 指令


如何使Process 成為 daemon ?

nohup 指令 (no hang up,不要掛斷)。當 使用ssh 登入linux後,一旦登出或關掉 ssh 軟體,那個在執行的程式就會結束,原因是它的parent process 被關閉了 (Session-->Bash shell --> your process)


nohup <your command and parameters go here> &
Demo:
nohup 可以讓ssh登出後, 仍保留程式繼續執行中 。但此程式的PPID (parent PID) 會掛在PID=1(即init 程式)


nohup sleep 100



登出後再進去看ps -aux 查看, PID 14128還在, 且可以ps -lx查到其PPID=1




nohup --help


Usage: nohup COMMAND [ARG]...
  or:  nohup OPTION
Run COMMAND, ignoring hangup signals.

      --help     display this help and exit
      --version  output version information and exit

If standard input is a terminal, redirect it from /dev/null.
If standard output is a terminal, append output to 'nohup.out' if possible,'$HOME/nohup.out' otherwise.
If standard error is a terminal, redirect it to standard output.
To save output to FILE, use 'nohup COMMAND > FILE'.

NOTE: your shell may have its own version of nohup, which usually supersedes
the version described here.  Please refer to your shell's documentation
for details about the options it supports.

Report nohup bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'nohup invocation'


2016年7月10日 星期日

Node.js Socket.io 範例 --聊天室


Node.js Socket.io

1) 安裝Node.js

下載 node.js binary code (v 6.3.1) 並複製到/usr/local 下


  • wget https://nodejs.org/dist/v6.3.1/node-v6.3.1-linux-x64.tar.xz
  • tar Jxvf node-v6.3.1-linux-x64.tar.xz
  • cd node-v6.3.1-linux-x64/
  • sudo cp * -r /usr/local/
  • node -v  ==>  會輸出 v6.3.1

2) 安裝 Express

  • npm install -g express-generator

2) 從GitHub程式下載, 用這個範例快速學習Socket.io

git clone https://github.com/guille/chat-example.git
cd chat-example;
sudo npm install --save
# 執行node 程式
node index.js

出現==>  listening on *:3000

開兩個瀏覽器連到 http://xxx.xxx.xxx.xxx:3000


######## index.html ########

  <body>
    <ul id="messages"></ul>
    <form action="">
      <input id="m" autocomplete="off" /><button>Send</button>
    </form>
    <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
    <script src="http://code.jquery.com/jquery-1.11.1.js"></script>
    <script>
      var socket = io();
      $('form').submit(function(){
        socket.emit('chat message', $('#m').val());
        $('#m').val('');
        return false;
      });
      socket.on('chat message', function(msg){
        $('#messages').append($('<li>').text(msg));
      });
    </script>
  </body>

########  index.js ########

// express 處理route ,url path 作為主要的程式app
// 軟體層次 : io(http(express))


var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

app.get('/', function(req, res){   // http;//xxx.xxx.xxx.xxx: 3000 ,傳回/index.html
  res.sendFile(__dirname + '/index.html');
});

// 再收到'connection' event後會獲得socket, 可以作socket.on('event', handler()) 進行讀socket
// 送出是透過 io.emit(''event', message);

io.on('connection', function(socket){   
  socket.on('chat message', function(msg){
    io.emit('chat message', msg);
  });

    socket.on('disconnect', function(){ //斷線時即browser關閉
           console.log('user disconnected');
    });

});

http.listen(3000, function(){  //listen on port 3000
  console.log('listening on *:3000');
});

IOT


參考資源:

  1. http://socket.io/get-started/chat/
  2. https://nodejs.org