備份回復 rpi image 的時候有時會遇到 sd card 雖號稱一樣 g 數,但實際大小卻不一樣,導致回復時出問題,此時可以用底下 scripts 解決,先把檔案變小就好解決… (linux 環境下)
Shrink your Raspberry Pi SD Card Image size
https://github.com/Drewsif/PiShrink
Very Nice !!
硬體從 rpi2 改到 rpi3
舊 SDCard 無法順利在 rpi3 開機的問題
apt-get install rpi-update
rpi-update
2018年7月20日 星期五
2018年7月1日 星期日
mqtt@RaspberryPi
broker / server / client library install...
sudo apt-get install mosquitto mosquitto-clients
sudo apt-get install python3-pip
sudo pip3 install paho-mqtt
import paho.mqtt.publish as publish
# publish a message then disconnect.
host = "localhost"
topic = "where/is/my/topic"
payload = "hello"
# If broker asks user/password.
auth = {'username': "", 'password': ""}
# If broker asks client ID.
client_id = ""
publish.single(topic, payload, qos=1, hostname=host)
#publish.single(topic, payload, qos=1, host=host, auth=auth, client_id=client_id)
# 安裝 broker 及 所需函式庫
sudo apt-get install mosquitto mosquitto-clients
sudo apt-get install python3-pip
sudo pip3 install paho-mqtt
fix python search path...
# poah 安裝路徑若 python 找不到要作修正
cd /usr/lib/python2.7/dist-packages
sudo ln -s /usr/local/lib/python3.5/dist-packages/paho
import paho.mqtt.client as mqtt
sudo ln -s /usr/local/lib/python3.5/dist-packages/paho
subscribe...
# Subscribe 訂閱訊息/接收訊息
import paho.mqtt.client as mqtt
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
client.subscribe("where/is/my/topic")
print("Connected with result code "+str(rc))
client.subscribe("where/is/my/topic")
def on_message(client, userdata, msg):
print(msg.topic+" "+str(msg.payload))
print(msg.topic+" "+str(msg.payload))
client = mqtt.Client()
client.on_connect = on_connect #call back function
client.on_message = on_message #call back function
client.connect("localhost", 1883, 60)
client.loop_forever()
client.on_connect = on_connect #call back function
client.on_message = on_message #call back function
client.connect("localhost", 1883, 60)
client.loop_forever()
pubilsh...
# Publisher 發佈訊息
import paho.mqtt.publish as publish
# publish a message then disconnect.
host = "localhost"
topic = "where/is/my/topic"
payload = "hello"
# If broker asks user/password.
auth = {'username': "", 'password': ""}
# If broker asks client ID.
client_id = ""
publish.single(topic, payload, qos=1, hostname=host)
#publish.single(topic, payload, qos=1, host=host, auth=auth, client_id=client_id)
訂閱:
文章 (Atom)
VirtualBox 空間減肥
sdelete64 -z c: VBoxManage modifymedium disk "/Users/fellow/VirtualBox VMs/Win10/Win10.vdi" --compact *.vdi 路徑可以在 VirtualBox 儲...
-
https://github.com/ljean/modbus-tk/ install pip… sudo apt-get install python-pip install... download modbus_tk-x.x.x.tar.gz tar zxvf...
-
ARis... ARis 是日本一間公司出品的產品,應用了 ARToolKit 技術。 展示影片在這… http://www.youtube.com/watch?v=yCCx7zANsGE YouTube上可以找到更多類似的影片。 這邊是我用 FLARToolK...
-
由於ASSEMBLA即將開始收費,因此要把所有的SVN進行大搬家,連帶的一些教學文件也跟著搬家了,看來還是GOOGLE的窩最舒適(重點是免費) FPPA實驗平台教學教材-使用C語言 FPPA實驗平台簡介 實驗(一) 8位元LED輸出單元 與 模組設計總論 實驗(二) 按鍵開關輸入...