工研院Raspberry pi課程使用
這些指令在 專案根目錄下 執行,將會執行 Makefile裡面的命令。如果只需要編譯請執行 make all
- build this project
make all
- clean project build
make clean
- use scp copy to your target
make scp
請先安裝 Adafruit BMP Python Lib
sudo apt-get update
sudo apt-get install git build-essential python-dev python-smbus
git clone https://github.com/adafruit/Adafruit_Python_BMP.git
cd Adafruit_Python_BMP
sudo python setup.py install
如果沒有Rpi的 GPIO Lib 請安裝此套件, clone this
請先完成上面BMP180部分後,啟動 Rpi 的 i2c
sudo raspi-config
選擇 5. interface options,在選擇 i2c. 如果沒有找到 5. interface options,選擇 advance options
接下來在執行 偵測i2c
i2cdetect -l
你可以發現i2c介面
i2c-1 i2c bcm2835 I2C adapter I2C adapter
如果發現 i2c 地址,則代表已經有偵測到感測器,接下來下載專案
git clone https://github.com/RozenAstrayChen/MQTT_Raspberry.git
cd MQTT_Raspberry
make
使用 paho-mqtt 安裝:
sudo pip install paho-mqtt
先更新和安裝npm 套件
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:gias-kay-lee/npm
sudo apt-get update
sudo apt-get install nodejs npm node-semver
確認 npm版本
npm -v
- Mosquitto 主要功能是將 MQTT port 打開,如果沒有執行,則會造成 Node Red connted boker failed 安裝:
sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
sudo apt-get update
sudo apt-get install mosquitto
sudo apt-get install mosquitto-clients
執行:
sudo service stop mosquitto
sudo service start mosquitto #see note later
如果執行失敗,代表mosquitto 不在 bin 裏,則執行
sudo /etc/init.d/mosquitto start
若需要關掉
sudo /etc/init.d/mosquitto stop
開機自動啟動 Mosquitto,需重新開機。如果沒有自動開啟請參考此連結
systemctl enable mosquitto
sudo reboot
node red clipboard in Clipboard.txt