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

電子發(fā)燒友App

硬聲App

掃碼添加小助手

加入工程師交流群

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

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

3天內(nèi)不再提示
創(chuàng)作
電子發(fā)燒友網(wǎng)>電子資料下載>電子資料>量化桌面物聯(lián)網(wǎng)項目

量化桌面物聯(lián)網(wǎng)項目

2022-12-19 | zip | 0.23 MB | 次下載 | 免費

資料介紹

描述

作為一個量化的自我愛好者,我想跟蹤我在站立式辦公桌上坐著和站著的時間,并在圖表中很好地可視化。

我也一直想使用 Microsoft Azure 開展個人物聯(lián)網(wǎng)項目,因此我將我的 Genuino MKR1000 撣掉,將其連接到超聲波傳感器并提出了這個項目。

pYYBAGOYiyqAPiERAALNcTi5fLY110.png
最終結果
?

這個概念很簡單:

  • 使用超聲波傳感器通過將桌子放在桌面下方來測量桌子的高度并計算到地板的距離
  • 定期將該數(shù)據(jù)發(fā)送到 Azure IoT 中心,并將其路由到隊列服務(Azure 服務總線隊列)
  • 使用 Python 應用程序使用數(shù)據(jù)來構建實時儀表板

接線非常簡單:

pYYBAGOaZe6AIt_CAAEFx7_tVMg897.png
原理圖
?

設置:

poYBAGOaZfOAeFU9AAa3mP5BN7g149.jpg
?
pYYBAGOaZfaAYHG-AALWLQWe0Do668.jpg
?

您只需確保將傳感器放置在桌子上與地板之間沒有障礙物的位置(例如:地板上的任何物體、椅子或您坐著時的腿)。所以把它放在一個角落里。

為了避免計算中的“噪音”(即您的腿或手臂可能在傳感器下方的短暫時刻,或者由于測量高度較低而暫時阻礙程序認為您處于坐姿的任何東西),進行了測量每 5 秒一次,并且僅使用最后 12 次測量的平均值來確定當前位置并計算坐/站時間,然后將該數(shù)據(jù)發(fā)送到 azure(12 * 5 = 60 秒,因此每分鐘)。

這是 Arduino 代碼(或從此鏈接獲取):

/*******************************************************************
This code implements the Quantified Desk project, which consists of
an Arduino/Genuino MKR1000 hooked up to an ultrasonic sensor to measure
the distance to the floor (height) of a standing desk.
It keeps track of the time duration (in minutes) in each state (Sitting/Standing)
which is defined by a distance threshold above which the desk is considered to be
in standing position, and below which it is considered in sitting position.
A time counter for each state increases if the corresponding state is the current state.
This data is periodically sent to Azure IoT Hub along with a timestamp.
Complete Project with Dashboard visualization
https://github.com/vmehmeri/az-iot/QuantifiedDesk
PRE-REQUISITE
Setup Azure IoT Hub and upload SSL certificate to device (for your
IoT Hub hostname). With older firmware versions the HTTP Post function
will be unreliable and may fail on several requests, so it's recommended
to update your MKR1000 firmware to the latest version.
- Instructions for setting up Azure IoT Hub:
https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-create-through-portal
- Instructions for updating Firmware and adding SSL certificate to device:
https://www.arduino.cc/en/Tutorial/FirmwareUpdater
*******************************************************************/
#include 
#include 
#include 
#include 
#include "arduino_secrets.h"
// SECRETS CONFIG -- PLEASE SET THESE IN arduino_secrets.h FILE
//WiFi creds -------------------------------------------------------------------------------------------
char ssid[] = SECRET_SSID; //  your network SSID (name)
char pass[] = SECRET_WIFIPASSWD;    // your network password (use for WPA, or use as key for WEP)
//Azure IoT Hub Secrets Config -------------------------------------------------------------------------
char hostname[] = SECRET_IOTHUB_HOSTNAME;
char uri[]= SECRET_DEVICE_POST_URI;
char authSAS[] = SECRET_DEVICE_SAS;
//------------------------------------------------------------------------------------------------------
#define slotNumber 1 //This will vary for multi slot devices
// Project Config variables
unsigned int distanceThreshold = 82; // Define here the distance (in cm) that marks the threshold between sitting and standing
const int GMT = 2; //change this to adapt it to your time zone
const int TrigPin = 4; //number of the Trigger pin
const int EchoPin = 5; //number of the Echo pin
RTCZero rtc;
WiFiSSLClient client;
Ultrasonic ultrasonic(TrigPin, EchoPin);
unsigned int count = 0;
unsigned long distanceSum = 0;
unsigned int timeStanding = 0;
unsigned int timeSitting = 0;
unsigned long startMillis;
unsigned long distanceAvg;
unsigned long distance;
int status = WL_IDLE_STATUS;
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
startMillis = millis();
rtc.begin();
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while (true);
}
// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
Serial.println("Connected to Wi-Fi");
// Get Real-Time from NTP using built-in RTC module
unsigned long epoch;
int numberOfTries = 0, maxTries = 6;
do {
epoch = WiFi.getTime();
numberOfTries++;
}
while ((epoch == 0) && (numberOfTries < maxTries));
if (numberOfTries == maxTries) {
Serial.print("NTP unreachable!!");
while (1);
}
else {
Serial.print("Epoch received: ");
Serial.println(epoch);
rtc.setEpoch(epoch);
Serial.println();
}
}
void loop() {
delay(5000); // wait 5 seconds
ultrasonic.measure();
distance = ultrasonic.get_cm();
Serial.print("Sensor(cm): ");
Serial.println(distance);
distanceSum = distanceSum + distance;
count = count + 1;
/* Takes the average of the last 12 measurements (the number 12 is arbitrary, but
*  with a 5-second delay between measurements and 12 measurements, that means
*  data is aggregated and sent to Azure every 60 seconds, which seems reasonable for
*  this project.
*/
if (count == 12) {
distanceAvg = distanceSum / count;
count = 0;
distanceSum = 0;
if (distanceAvg < distanceThreshold) {
// Add elapsed time since last measurement to sitting time
timeSitting = timeSitting + ((millis()-startMillis)/1000);
} else {
// Add elapsed time since last measurement to standing time
timeStanding = timeStanding + ((millis()-startMillis)/1000);
}
startMillis = millis();
// Show current aggregate numbers
printRTCDate();
printRTCTime();
Serial.println();
Serial.print("Time sitting: ");
Serial.print(timeSitting/60);
Serial.println("min");
Serial.print("Time standing: ");
Serial.print(timeStanding/60);
Serial.println("min");
Serial.println("");
// Creates a string to send to Azure IoT HUB.
// It's simply comma-separated string of values for sitting and standing, followed by date and time (for timestamping)
String data_string = (String(timeSitting/60) + "," + String(timeStanding/60) + "," + getRTCDate() + "," + getRTCTime());
//Serial.println(data_string);
// Send to Azure
httpPost(data_string);
String response = "";
char c;
while (client.available()) {
c = client.read();
response.concat(c);
}
}
}
void httpPost(String content)
{
if (client.connectSSL(hostname, 443)) {
client.print("POST ");
client.print(uri);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(hostname);
client.print("Authorization: ");
client.println(authSAS);
client.println("Connection: close");
client.print("Content-Type: ");
client.println("text/plain");
client.print("Content-Length: ");
client.println(content.length());
client.println();
client.println(content);
delay(500);
} else {
Serial.println("HTTP POST connection failed");
Serial.println(client.read());
}
// close connection
client.stop();
}
void printRTCTime()
{
print2digits(rtc.getHours() + GMT);
Serial.print(":");
print2digits(rtc.getMinutes());
Serial.print(":");
print2digits(rtc.getSeconds());
Serial.println();
}
void printRTCDate()
{
Serial.print(rtc.getDay());
Serial.print("/");
Serial.print(rtc.getMonth());
Serial.print("/");
Serial.print(rtc.getYear());
Serial.print(" ");
}
void print2digits(int number) {
if (number < 10) {
Serial.print("0");
}
Serial.print(number);
}
String getRTCDate()
{
String date_str = String(rtc.getDay()) + "/" + String(rtc.getMonth()) + "/" + String(rtc.getYear());
return date_str;
}
String getRTCTime()
{
String time_str = get2digits(rtc.getHours() + GMT) + ":" + get2digits(rtc.getMinutes()) + ":" + get2digits(rtc.getSeconds());
return time_str;
}
String get2digits(int number) {
if (number < 10) {
return "0" + String(number);
}
return String(number);
}

請注意,必須提供 Azure 連接詳細信息,因此您需要先設置 Azure IoT 中心。

以下是設置 Azure IoT 中心的說明:

https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-create-through-portal

免費層就可以滿足這一需求。所以它不會花費你任何東西!

儀表板

對于實時儀表板,我使用了 Pusher (pusher.com)。我按照本教程修改了我的應用程序的示例代碼。

您可以使用我的代碼(如下提供)作為參考,但您需要創(chuàng)建一個帳戶,創(chuàng)建一個應用程序,并記下您的應用程序連接密鑰,如下所示:

pYYBAGOaZfiAUkEGAACWhhwsDyI079.png
推送應用程序密鑰
?

別擔心,這應該花費您不到 5 分鐘的時間來完成設置。

完成后,下載我的 Github 存儲庫中可用的代碼:

https://github.com/vmehmeri/az-iot/tree/master/QuantifiedDesk

修改以下文件:

frontend/app.py
device_handler.py

使用您的應用程序密鑰(對于設備處理程序,還有您的 Azure 連接信息)。您會注意到需要有關 Azure 服務總線隊列的信息。在我的應用程序中,我讓 Azure IoT 中心將消息路由到服務總線隊列,然后從那里使用它們。設置 Azure 服務總線隊列非常簡單,您可以按照本教程進行操作:

在“消息傳遞”>“消息傳遞路由”>“添加”下配置 IoT 中心消息路由(然后選擇您的隊列)

之后,您就可以運行該應用程序了。首先,運行前端:

python frontend/app.py

在另一個終端中,運行設備處理程序,即后端應用程序:

python device_handler.py

現(xiàn)在,您可以在localhost:5000上打開一個瀏覽器窗口,然后盯著圖表,同時看到條形的增長取決于您站在或坐在辦公桌前的時間長短 :)(可能需要 1-2 分鐘才能看到任何變化在儀表板中)

您還可以打開 Arduino 串行監(jiān)視器以獲得更直接和詳細的輸出。device_handler 的 python 代碼在從設備獲取消息時也應該輸出一些文本。

pYYBAGOYiyqAPiERAALNcTi5fLY110.png
一切都在一起
?

?


物聯(lián)網(wǎng) 超聲波傳感器 python
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

下載該資料的人也在下載 下載該資料的人還在閱讀
更多 >

評論

查看更多

下載排行

本周

  1. 1矽力杰 Silergy SY7215A 同步升壓調(diào)節(jié)器 規(guī)格書 Datasheet 佰祥電子
  2. 1.12 MB  |  5次下載  |  免費
  3. 2HT81696H 內(nèi)置升壓的30W立體聲D類音頻功放數(shù)據(jù)手冊
  4. 1.21 MB   |  1次下載  |  免費
  5. 3HTA6863 3W超低噪聲超低功耗單聲道D類音頻功率放大器數(shù)據(jù)手冊
  6. 0.87 MB   |  次下載  |  免費
  7. 4南芯 Southchip SC8802C 充電控制器 規(guī)格書 Datasheet 佰祥電子
  8. 88.16 KB  |  次下載  |  免費
  9. 5矽力杰 Silergy SY7065 同步升壓轉換器 規(guī)格書 Datasheet 佰祥電子
  10. 910.67 KB  |  次下載  |  免費
  11. 6矽力杰 Silergy SY7066 同步升壓轉換器 規(guī)格書 Datasheet 佰祥電子
  12. 989.14 KB  |  次下載  |  免費
  13. 7WD6208A產(chǎn)品規(guī)格書
  14. 631.24 KB  |  次下載  |  免費
  15. 8NB685 26 V,12 A,低靜態(tài)電流,大電流 同步降壓變換器數(shù)據(jù)手冊
  16. 1.64 MB   |  次下載  |  2 積分

本月

  1. 1EMC PCB設計總結
  2. 0.33 MB   |  12次下載  |  免費
  3. 2PD取電芯片 ECP5702規(guī)格書
  4. 0.88 MB   |  5次下載  |  免費
  5. 3矽力杰 Silergy SY7215A 同步升壓調(diào)節(jié)器 規(guī)格書 Datasheet 佰祥電子
  6. 1.12 MB  |  5次下載  |  免費
  7. 4氮化鎵GaN FET/GaN HEMT 功率驅動電路選型表
  8. 0.10 MB   |  3次下載  |  免費
  9. 5PD取電芯片,可取5/9/12/15/20V電壓ECP5702數(shù)據(jù)手冊
  10. 0.88 MB   |  3次下載  |  免費
  11. 6SY50655 用于高輸入電壓應用的偽固定頻率SSR反激式穩(wěn)壓器英文資料
  12. 1.01 MB   |  3次下載  |  免費
  13. 7怎么為半導體測試儀選擇精密放大器
  14. 0.65 MB   |  2次下載  |  免費
  15. 8SY52341 次級側同步整流英文手冊
  16. 0.94 MB   |  2次下載  |  免費

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935137次下載  |  10 積分
  3. 2開源硬件-PMP21529.1-4 開關降壓/升壓雙向直流/直流轉換器 PCB layout 設計
  4. 1.48MB  |  420064次下載  |  10 積分
  5. 3Altium DXP2002下載入口
  6. 未知  |  233095次下載  |  10 積分
  7. 4電路仿真軟件multisim 10.0免費下載
  8. 340992  |  191469次下載  |  10 積分
  9. 5十天學會AVR單片機與C語言視頻教程 下載
  10. 158M  |  183360次下載  |  10 積分
  11. 6labview8.5下載
  12. 未知  |  81606次下載  |  10 積分
  13. 7Keil工具MDK-Arm免費下載
  14. 0.02 MB  |  73832次下載  |  10 積分
  15. 8LabVIEW 8.6下載
  16. 未知  |  65991次下載  |  10 積分
原阳县| 云安县| 廊坊市| 浦江县| 宁陵县| 岐山县| 织金县| 聊城市| 若尔盖县| 辽中县| 曲麻莱县| 昌乐县| 运城市| 临澧县| 泸定县| 宣化县| 苗栗市| 皮山县| 电白县| 永川市| 堆龙德庆县| 黄骅市| 扎囊县| 静海县| 堆龙德庆县| 台中市| 山东省| 米泉市| 永济市| 德阳市| 东港市| 班玛县| 昭觉县| 扎赉特旗| 山阳县| 凉城县| 浮山县| 华安县| 泗水县| 天柱县| 项城市|