日B视频 亚洲,啪啪啪网站一区二区,91色情精品久久,日日噜狠狠色综合久,超碰人妻少妇97在线,999青青视频,亚洲一区二卡,让本一区二区视频,日韩网站推荐

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內(nèi)不再提示

怎樣將樹莓派連接到Oregon Scientific BLE氣象站

454398 ? 來源:wv ? 2019-10-12 09:09 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

步驟1:俄勒岡科學氣象站BLE協(xié)議

探索氣象站公開的BLE服務的一種簡單方法是在智能手機或平板電腦上使用BLE掃描儀應用程序。在這里,我將使用Android上的Nordic Semiconductor的nRF Connect。

對于不熟悉BLE的人們,您可能想開始使用此低功耗藍牙入門指南。這將幫助您了解GATT,服務和特性之類的術語。

借助BLE掃描器應用程序,您將找到周圍的所有BLE設備。并且您會看到俄勒岡科學氣象站正在將其自己廣告為 IDTW211R 。

如果連接到氣象站,您將獲得設備公開的服務列表

通用訪問UUID:0x1800

通用屬性UUID:0x1801

專有服務UUID:74e7fe00-c6a4-11e2-b7a9-0002a5d5c51b

設備信息UUID:0x180A

電池服務UUID:0x180F

對我們而言重要的服務是專有服務(UUID:74e7fe00-c6a4- 11E2-b7a9-0002a5d5c51b)。因此,我們單擊該服務并獲得該服務公開的特征列表。

我們的應用程序的相關特征是UUID:74e78e10-c6a4-11e2-b7a9-0002a5d5c51b(INDOOR_AND_CH1_TO_3_TH_DATA)。

如屬性中所示,此特征不可讀,但提供指示服務。而且我們將必須通過相應的客戶端特征配置描述符(UUID:0x2902)啟用指示。

事實證明,必須為設備的所有特征啟用指示/通知,才能開始獲取任何指示。

步驟2:將Raspberry Pi3連接到BLE氣象站

現(xiàn)在,我們對如何通過BLE檢索溫度數(shù)據(jù)有了更好的了解,讓我們嘗試讓Raspberry Pi與氣象站進行通訊。

Raspberry Pi上的BLE

我將使用Raspberry Pi3(集成了WLAN/BT控制器)和具有像素2016-09-23的Raspbian Jessie。

bluez (5.23)的版本此Raspbian版本已經(jīng)過時了,我們必須升級到 bluez 的更高版本才能使用Bluetooth Low Energy。

下載 bluez 5.43 》并安裝所需的依賴項:

sudo apt-ge t update

sudo apt-get install -y libglib2.0-dev libdbus-1-dev libudev-dev libical-dev libreadline-dev

wget http://www.kernel .org/pub/linux/bluetooth/bluez-5.43.tar.xz

tar xvf bluez-5.43.tar.xz

配置,構建和安裝 bluez

。/configure

make

sudo make install

最后重新啟動Raspberry Pi。

現(xiàn)在,讓我們使用cmd hciconfig dev

驗證藍牙堆棧是否已啟動并且正在運行,然后確認我們可以掃描BLE設備: sudo hcitool lescan

我們應該看到氣象站的廣告為 IDTW211R 。

下一步是連接到氣象站:

sudo gatttool -b -t random -I

您應該獲得一個新的命令提示符,其BLE地址位于方括號之間。

connect

您應該獲得“連接成功”的提示,并變?yōu)椴噬?/p>

連接后,我們可以運行一些命令以獲取有關設備的更多詳細信息。例如,主要命令將列出設備公開的服務。

從氣象站收集數(shù)據(jù)

如前所述,開始獲取有關在INDOOR_AND_CH1_TO_3_TH_DATA(UUID:74e78e10-c6a4-11e2-b7a9-0002a5d5c51b)中,我們必須啟用所有特征的指示/通知。

我們通過在客戶端特征配置描述符中寫入0x0002(用于通知的0x0001)來啟用指示。 (UUID:0x2902)每個特性。寫應該以小尾數(shù)形式放置,這樣: char-write-req 0200

作為回報,您應該開始獲得指示/通知。對我們而言,相關的是INDOOR_AND_CH1_TO_3_TH_DATA指示(因此句柄0x0017)。

指示句柄= 0x0017值:01 05 01 15 01 ff 7f ff 7f 7f 7f 7f 7f ff ff 7f 7f 7f 7f 7f 7f

指示句柄= 0x0017值:82 7f 7f 7f 21 01 f8 00 24 01 ba 00 ff 7f ff 7f ff 7f ff 7f

對于每一輪指示,我們得到兩個20的數(shù)據(jù)包每個字節(jié)。最高有效字節(jié)指示數(shù)據(jù)類型(類型0或類型1)。有關數(shù)據(jù)包的更多詳細信息,請參見上一張圖片。

步驟3:檢索氣象站數(shù)據(jù)的Python腳本

現(xiàn)在我們成功地從氣象站中獲取了數(shù)據(jù),讓我們自動化了整個過程并理解了數(shù)據(jù)。

這是一個連接到氣象站,檢索數(shù)據(jù)并提取氣象站底座和隨附的無線傳感器的溫度。

此腳本利用bluepy庫提供了API,以允許從Python訪問Bluetooth Low Energy設備。因此,您必須在執(zhí)行腳本之前安裝此模塊:https://github.com/IanHarvey/bluepy#installation

用法

可以使用MAC地址執(zhí)行腳本

在后一種情況下,腳本將執(zhí)行掃描并查找廣告為 IDTW211R 的設備。它必須以root特權執(zhí)行,因為 bluez 需要 root 特權才能進行掃描操作。

python bleWeatherStation.py [mac-address]

sudo python bleWeatherStation.py

bleWeatherStation.py

#!/usr/bin/python

# -*- coding: utf-8 -*-

# Connect to Oregon Scientific BLE Weather Station

# Copyright (c) 2016 Arnaud Balmelle

#

# This script will connect to Oregon Scientific BLE Weather Station

# and retrieve the temperature of the base and sensors attached to it.

# If no mac-address is passed as argument, it will scan for an Oregon Scientific BLE Weather Station.

#

# Supported Oregon Scientific Weather Station: EMR211 and RAR218HG (and probably BAR218HG)

#

# Usage: python bleWeatherStation.py [mac-address]

#

# Dependencies:

# - Bluetooth 4.1 and bluez installed

# - bluepy library (https://github.com/IanHarvey/bluepy)

#

# License: Released under an MIT license: http://opensource.org/licenses/MIT

import sys

import logging

import time

import sqlite3

from bluepy.btle import *

# uncomment the following line to get debug information

logging.basicConfig(format=‘%(asctime)s: %(message)s’, level=logging.DEBUG)

WEATHERSTATION_NAME = “IDTW211R” # IDTW213R for RAR218HG

class WeatherStation:

def __init__(self, mac):

self._data = {}

try:

self.p = Peripheral(mac, ADDR_TYPE_RANDOM)

self.p.setDelegate(NotificationDelegate())

logging.debug(‘WeatherStation connected !’)

except BTLEException:

self.p = 0

logging.debug(‘Connection to WeatherStation failed !’)

raise

def _enableNotification(self):

try:

# Enable all notification or indication

self.p.writeCharacteristic(0x000c, “x02x00”)

self.p.writeCharacteristic(0x000f, “x02x00”)

self.p.writeCharacteristic(0x0012, “x02x00”)

self.p.writeCharacteristic(0x0015, “x01x00”)

self.p.writeCharacteristic(0x0018, “x02x00”)

self.p.writeCharacteristic(0x001b, “x02x00”)

self.p.writeCharacteristic(0x001e, “x02x00”)

self.p.writeCharacteristic(0x0021, “x02x00”)

self.p.writeCharacteristic(0x0032, “x01x00”)

logging.debug(‘Notifications enabled’)

except BTLEException as err:

print(err)

self.p.disconnect()

def monitorWeatherStation(self):

try:

# Enable notification

self._enableNotification()

# Wait for notifications

while self.p.waitForNotifications(1.0):

# handleNotification() was called

continue

logging.debug(‘Notification timeout’)

except:

return None

regs = self.p.delegate.getData()

if regs is not None:

# expand INDOOR_AND_CH1_TO_3_TH_DATA_TYPE0

self._data[‘index0_temperature’] = ‘’.join(regs[‘data_type0’][4:6] + regs[‘data_type0’][2:4])

self._data[‘index1_temperature’] = ‘’.join(regs[‘data_type0’][8:10] + regs[‘data_type0’][6:8])

self._data[‘index2_temperature’] = ‘’.join(regs[‘data_type0’][12:14] + regs[‘data_type0’][10:12])

self._data[‘index3_temperature’] = ‘’.join(regs[‘data_type0’][16:18] + regs[‘data_type0’][14:16])

self._data[‘index0_humidity’] = regs[‘data_type0’][18:20]

self._data[‘index1_humidity’] = regs[‘data_type0’][20:22]

self._data[‘index2_humidity’] = regs[‘data_type0’][22:24]

self._data[‘index3_humidity’] = regs[‘data_type0’][24:26]

self._data[‘temperature_trend’] = regs[‘data_type0’][26:28]

self._data[‘humidity_trend’] = regs[‘data_type0’][28:30]

self._data[‘index0_humidity_max’] = regs[‘data_type0’][30:32]

self._data[‘index0_humidity_min’] = regs[‘data_type0’][32:34]

self._data[‘index1_humidity_max’] = regs[‘data_type0’][34:36]

self._data[‘index1_humidity_min’] = regs[‘data_type0’][36:38]

self._data[‘index2_humidity_max’] = regs[‘data_type0’][38:40]

# expand INDOOR_AND_CH1_TO_3_TH_DATA_TYPE1

self._data[‘index2_humidity_min’] = regs[‘data_type1’][2:4]

self._data[‘index3_humidity_max’] = regs[‘data_type1’][4:6]

self._data[‘index3_humidity_min’] = regs[‘data_type1’][6:8]

self._data[‘index0_temperature_max’] = ‘’.join(regs[‘data_type1’][10:12] + regs[‘data_type1’][8:10])

self._data[‘index0_temperature_min’] = ‘’.join(regs[‘data_type1’][14:16] + regs[‘data_type1’][12:14])

self._data[‘index1_temperature_max’] = ‘’.join(regs[‘data_type1’][18:20] + regs[‘data_type1’][16:18])

self._data[‘index1_temperature_min’] = ‘’.join(regs[‘data_type1’][22:24] + regs[‘data_type1’][20:22])

self._data[‘index2_temperature_max’] = ‘’.join(regs[‘data_type1’][26:28] + regs[‘data_type1’][24:26])

self._data[‘index2_temperature_min’] = ‘’.join(regs[‘data_type1’][30:32] + regs[‘data_type1’][28:30])

self._data[‘index3_temperature_max’] = ‘’.join(regs[‘data_type1’][34:36] + regs[‘data_type1’][32:34])

self._data[‘index3_temperature_min’] = ‘’.join(regs[‘data_type1’][38:40] + regs[‘data_type1’][36:38])

return True

else:

return None

def getValue(self, indexstr):

val = int(self._data[indexstr], 16)

if val 》= 0x8000:

val = ((val + 0x8000) & 0xFFFF) - 0x8000

return val

def getIndoorTemp(self):

if ‘index0_temperature’ in self._data:

temp = self.getValue(‘index0_temperature’) / 10.0

max = self.getValue(‘index0_temperature_max’) / 10.0

min = self.getValue(‘index0_temperature_min’) / 10.0

logging.debug(‘Indoor temp : %.1f°C, max : %.1f°C, min : %.1f°C’, temp, max, min)

return temp

else:

return None

def getOutdoorTemp(self):

if ‘index1_temperature’ in self._data:

temp = self.getValue(‘index1_temperature’) / 10.0

max = self.getValue(‘index1_temperature_max’) / 10.0

min = self.getValue(‘index1_temperature_min’) / 10.0

logging.debug(‘Outdoor temp : %.1f°C, max : %.1f°C, min : %.1f°C’, temp, max, min)

return temp

else:

return None

def disconnect(self):

self.p.disconnect()

class NotificationDelegate(DefaultDelegate):

def __init__(self):

DefaultDelegate.__init__(self)

self._indoorAndOutdoorTemp_type0 = None

self._indoorAndOutdoorTemp_type1 = None

def handleNotification(self, cHandle, data):

formatedData = binascii.b2a_hex(data)

if cHandle == 0x0017:

# indoorAndOutdoorTemp indication received

if formatedData[0] == ‘8’:

# Type1 data packet received

self._indoorAndOutdoorTemp_type1 = formatedData

logging.debug(‘indoorAndOutdoorTemp_type1 = %s’, formatedData)

else:

# Type0 data packet received

self._indoorAndOutdoorTemp_type0 = formatedData

logging.debug(‘indoorAndOutdoorTemp_type0 = %s’, formatedData)

else:

# skip other indications/notifications

logging.debug(‘handle %x = %s’, cHandle, formatedData)

def getData(self):

if self._indoorAndOutdoorTemp_type0 is not None:

# return sensors data

return {‘data_type0’:self._indoorAndOutdoorTemp_type0, ‘data_type1’:self._indoorAndOutdoorTemp_type1}

else:

return None

class ScanDelegate(DefaultDelegate):

def __init__(self):

DefaultDelegate.__init__(self)

def handleDiscovery(self, dev, isNewDev, isNewData):

global weatherStationMacAddr

if dev.getValueText(9) == WEATHERSTATION_NAME:

# Weather Station in range, saving Mac address for future connection

logging.debug(‘WeatherStation found’)

weatherStationMacAddr = dev.addr

if __name__==“__main__”:

weatherStationMacAddr = None

if len(sys.argv) 《 2:

# No MAC address passed as argument

try:

# Scanning to see if Weather Station in range

scanner = Scanner().withDelegate(ScanDelegate())

devices = scanner.scan(2.0)

except BTLEException as err:

print(err)

print(‘Scanning required root privilege, so do not forget to run the script with sudo.’)

else:

# Weather Station MAC address passed as argument, will attempt to connect with this address

weatherStationMacAddr = sys.argv[1]

if weatherStationMacAddr is None:

logging.debug(‘No WeatherStation in range !’)

else:

try:

# Attempting to connect to device with MAC address “weatherStationMacAddr”

weatherStation = WeatherStation(weatherStationMacAddr)

if weatherStation.monitorWeatherStation() is not None:

# WeatherStation data received

indoor = weatherStation.getIndoorTemp()

outdoor = weatherStation.getOutdoorTemp()

else:

logging.debug(‘No data received from WeatherStation’)

weatherStation.disconnect()

except KeyboardInterrupt:

logging.debug(‘Program stopped by user’)

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內(nèi)容侵權或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 氣象站
    +關注

    關注

    1

    文章

    861

    瀏覽量

    17112
  • 樹莓派
    +關注

    關注

    122

    文章

    2085

    瀏覽量

    110862
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關推薦
    熱點推薦

    車載揚塵監(jiān)測站,走航式氣象站

    氣象站
    pingao141378
    發(fā)布于 :2026年02月25日 13:58:18

    濕度傳感器模塊HW2200用于氣象站低濕度環(huán)境下的高精度精確監(jiān)測

    氣象站作為基礎氣象監(jiān)測設備,憑借穩(wěn)定的運行和精準的數(shù)據(jù),廣泛應用于能源、鄉(xiāng)鎮(zhèn)防控、生態(tài)科研、市政建設等多個領域。它可實現(xiàn)全天候無人值守,自動采集各類氣象要素,實時上傳數(shù)據(jù),為各行業(yè)提供可靠的
    的頭像 發(fā)表于 02-05 10:00 ?491次閱讀
    濕度傳感器模塊HW2200用于<b class='flag-5'>氣象站</b>低濕度環(huán)境下的高精度精確監(jiān)測

    便攜式氣象站:移動場景下的氣象“感知官”

    便攜式氣象站:移動場景下的氣象“感知官”柏峰【BF-BQX】在野外勘探的深山里,在賽事保障的運動場上,在農(nóng)業(yè)生產(chǎn)的田壟間,精準、實時的氣象數(shù)據(jù)往往是決策的關鍵。傳統(tǒng)固定式氣象站受限于安
    的頭像 發(fā)表于 11-14 09:13 ?496次閱讀
    便攜式<b class='flag-5'>氣象站</b>:移動場景下的<b class='flag-5'>氣象</b>“感知官”

    超聲波氣象站:精準監(jiān)測的技術新選擇

    超聲波氣象站:精準監(jiān)測的技術新選擇 柏峰【BF-CSQX】在氣象監(jiān)測技術持續(xù)升級的背景下,超聲波氣象站憑借無機械損耗、高靈敏度、強環(huán)境適應性等核心特性,逐漸取代傳統(tǒng)機械氣象站,成為
    的頭像 發(fā)表于 10-24 10:12 ?974次閱讀
    超聲波<b class='flag-5'>氣象站</b>:精準監(jiān)測的技術新選擇

    小型自動氣象站:精細化氣象監(jiān)測的技術革新與應用拓展

    小型自動氣象站:精細化氣象監(jiān)測的技術革新與應用拓展 柏峰【BF-QX】隨著氣象服務向“精細化、精準化、智能化”升級,傳統(tǒng)氣象觀測站點密度不足、覆蓋范圍有限的問題日益凸顯。小型自動
    的頭像 發(fā)表于 10-23 10:53 ?1144次閱讀
    小型自動<b class='flag-5'>氣象站</b>:精細化<b class='flag-5'>氣象</b>監(jiān)測的技術革新與應用拓展

    校園科普氣象站:技術賦能下的自然探索課堂

    校園科普氣象站:技術賦能下的自然探索課堂 柏峰【BF-XQX】在素質(zhì)教育深化推進的背景下,校園科普氣象站正成為連接課堂理論與自然實踐的重要橋梁。它以模塊化的技術架構、可視化的交互設計和趣味化的教學場景,
    的頭像 發(fā)表于 10-22 10:05 ?506次閱讀
    校園科普<b class='flag-5'>氣象站</b>:技術賦能下的自然探索課堂

    超聲波自動氣象站技術方案

    超聲波自動氣象站技術方案 柏峰【BF-CSQX】一、項目背景與需求分析 1.1 項目背景 傳統(tǒng)機械轉(zhuǎn)動式氣象站存在部件磨損、易受惡劣天氣影響(如風沙堵塞、雨雪結冰)、維護成本高等問題,難以滿足現(xiàn)代化氣象監(jiān)測對數(shù)據(jù)精準性、連續(xù)性及
    的頭像 發(fā)表于 10-16 14:18 ?581次閱讀
    超聲波自動<b class='flag-5'>氣象站</b>技術方案

    光伏自動氣象站技術架構與發(fā)電效率保障應用

    光伏自動氣象站技術架構與發(fā)電效率保障應用 柏峰【BF-GFQX】光伏自動氣象站以“精準輻照感知、發(fā)電效率評估、運維智能輔助”為核心技術特征,融合光伏專用氣象監(jiān)測與發(fā)電性能分析功能,成為光伏電站高效運營的關鍵技術裝備。
    的頭像 發(fā)表于 10-15 17:29 ?1989次閱讀
    光伏自動<b class='flag-5'>氣象站</b>技術架構與發(fā)電效率保障應用

    景區(qū)負氧離子氣象站

    氣象站
    pingao141378
    發(fā)布于 :2025年10月14日 14:06:19

    華為推出鴻蒙智能交通氣象站

    華為全聯(lián)接大會2025期間,在氣象海洋論壇上,華為聯(lián)合陜西省氣象局發(fā)布鴻蒙智能交通氣象站,這標志著陜西在落實中國氣象局“觀測即服務”理念、搶占交通
    的頭像 發(fā)表于 09-20 14:41 ?1501次閱讀

    北斗自動氣象站: 護航無網(wǎng)區(qū)的 “氣象信使”

    北斗自動氣象站: 護航無網(wǎng)區(qū)的 “氣象信使”柏峰【BF-BDQX】在沙漠深處的油田、高原無人區(qū)的牧區(qū),或是地震災后的通信中斷地帶,一種能擺脫網(wǎng)絡依賴的氣象設備正持續(xù)傳遞著關鍵數(shù)據(jù) —— 它就是北斗自動
    的頭像 發(fā)表于 09-08 11:35 ?1419次閱讀
    北斗自動<b class='flag-5'>氣象站</b>: 護航無網(wǎng)區(qū)的 “<b class='flag-5'>氣象</b>信使”

    數(shù)字傳感器,如何通過小型氣象站賦能農(nóng)耕、生態(tài)與防災?

    小型氣象站是一種針對局部區(qū)域氣象環(huán)境進行精細化監(jiān)測的便攜式或固定式設備,其核心功能是通過實時采集所處區(qū)域的溫度、濕度、氣壓、風速、風向、降水量、光照等氣象數(shù)據(jù),為農(nóng)業(yè)生產(chǎn)、生態(tài)研究及環(huán)境監(jiān)測等特定
    的頭像 發(fā)表于 09-04 14:34 ?1024次閱讀
    數(shù)字傳感器,如何通過小型<b class='flag-5'>氣象站</b>賦能農(nóng)耕、生態(tài)與防災?

    防爆工業(yè)氣象站:工業(yè)場景的 “氣象監(jiān)測中樞”

    防爆工業(yè)氣象站:工業(yè)場景的 “氣象監(jiān)測中樞”柏峰【BF-FB】在石油化工、煤礦開采、天然氣處理等高危工業(yè)場景中,一個容易被忽視卻關乎安全生產(chǎn)的問題始終存在:如何在易燃易爆環(huán)境下
    的頭像 發(fā)表于 08-26 12:00 ?869次閱讀
    防爆工業(yè)<b class='flag-5'>氣象站</b>:工業(yè)場景的 “<b class='flag-5'>氣象</b>監(jiān)測中樞”

    智慧農(nóng)業(yè)氣象站技術方案

    智慧農(nóng)業(yè)氣象站技術方案 柏峰【BF-QX】隨著農(nóng)業(yè)現(xiàn)代化進程的加速,傳統(tǒng)農(nóng)業(yè)正逐步向智慧農(nóng)業(yè)轉(zhuǎn)型。氣象條件對農(nóng)業(yè)生產(chǎn)具有至關重要的影響,精準的氣象監(jiān)測與預測能夠幫助農(nóng)戶合理安排農(nóng)事活動,有效降低
    的頭像 發(fā)表于 08-21 09:05 ?1009次閱讀
    智慧農(nóng)業(yè)<b class='flag-5'>氣象站</b>技術方案

    光伏實驗氣象站的技術架構與應用實踐

    光伏實驗氣象站的技術架構與應用實踐 柏峰【BF-GFQX】在光伏產(chǎn)業(yè)快速發(fā)展與新能源科研不斷深入的背景下,光伏實驗氣象站作為獲取精準氣象數(shù)據(jù)與光伏性能參數(shù)的核心設備,其技術先進性直接決定了科研成果的可靠性與工程應用的實效性。
    的頭像 發(fā)表于 08-19 08:57 ?2327次閱讀
    光伏實驗<b class='flag-5'>氣象站</b>的技術架構與應用實踐
    大方县| 渝中区| 修武县| 璧山县| 星座| 彭山县| 临江市| 博乐市| 明光市| 勐海县| 余干县| 平湖市| 米脂县| 香港| 章丘市| 永吉县| 塔河县| 都安| 安吉县| 巴东县| 平顺县| 峨眉山市| 肇源县| 高邮市| 柳州市| 喀喇沁旗| 富平县| 阜城县| 永嘉县| 百色市| 万宁市| 沙雅县| 东乌珠穆沁旗| 肃南| 贡觉县| 河北省| 伽师县| 宁南县| 巴里| 施甸县| 雷山县|