雷射測距模組 樹莓派3b 485通訊轉串列埠

2021-09-13 12:16:24 字數 1108 閱讀 8978

由於專案需求,我在**買了兩個雷射測距模組。

模組介面

實物圖:

以下是關於這個模組的簡單使用方法:

硬體連線

接入樹莓派使用之前,我先使用windows電腦串列埠助手進行測試:

現在接入樹莓派來使用:

import serial

import binascii

port = serial.serial("/dev/ttyama0", baudrate=115200, timeout=3.0)

while true:

print("please input the command:")

cmd = raw_input()

if(cmd == "d1"):

print("modbus test...")

single_measure_cmd ="\x01\x03\x00\x0f\x00\x02\xf4\x08"

port.write(single_measure_cmd)

rcv = port.read(16)

new_receive = int(binascii.hexlify(rcv[5:7]), 16)

print("the detected instance is " + str(new_receive) + " mm")

if(cmd == "d2"):

print("modbus test...")

single_measure_cmd ="\x02\x03\x00\x0f\x00\x02\xf4\x3b"

port.write(single_measure_cmd)

rcv = port.read(16)

new_receive = int(binascii.hexlify(rcv[5:7]), 16)

print("the detected instance is " + str(new_receive) + " mm")

七 樹莓派3B 訪問樹莓派

上週都是把樹莓派帶到公司玩,這個確實不怎麼好。就一直在想怎麼可以訪問放在宿舍的樹莓派。網上有很多方法。我還是選擇了做,這個簡單。csdn的大佬們,求審核通過,第三次了,上線半年給下架了,修改後又拒絕,難受。安裝之前請看文件 花生殼 3.0 for 樹莓派 安裝使用攻略 1.安裝 dpkg i phd...

樹莓派 樹莓派3B 的系統安裝

樹莓派3b 系統安裝 參考 樹莓派3b 安裝系統 建議使用谷歌瀏覽器,看不懂可以一鍵翻譯,比較方便,其他瀏覽器可不可以我已經不記得了 解壓後 3.52g 準備一張sd卡 其實u盤也可,我用的u盤 最起碼16g,稍大點比較好,我用的是32gu盤 windows系統下安裝 1.用讀卡器連線sd卡與電腦,...

樹莓派3b 安裝

2019獨角獸企業重金招聘python工程師標準 一 貼散熱片 背面一片,正面兩篇。二 系統安裝 1 使用sd formatter格式化sd卡 2 使用win32diskimager寫入映象 3 將樹莓派連上電視 鍵盤 電源啟動 4 設定一些引數,連上網路。三 設定 1 在首選項中rasberry ...