精品国产人成在线_亚洲高清无码在线观看_国产在线视频国产永久2021_国产AV综合第一页一个的一区免费影院黑人_最近中文字幕MV高清在线视频

電子發燒友App

硬聲App

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

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

3天內不再提示
電子發燒友網>電子資料下載>電子資料>Azure支持的AI冷凍機監視器

Azure支持的AI冷凍機監視器

2022-11-22 | zip | 0.22 MB | 次下載 | 免費

資料介紹

描述

Azure 支持的 AI Freezer Monitor 是基于制造商硬件IoT 監視器,它使用機器學習 (ML) 來提供潛在設備故障的早期警告。本指南涵蓋了構建設備、收集訓練數據、設置電子郵件警報、訓練自定義自動編碼器機器學習模型以及將模型部署到 ESP32 開發板。

該項目旨在為低溫科學冷凍機(-60 C)提供功能,目標是減少災難性故障和保持備用冷凍機全時運行的需要。但是,請注意,該項目主要用于演示和教育目的,尚未經過廣泛的測試。

這個項目大約需要一個小時才能完全完成。

Azure 設置

下面有關于此示例的成本和架構的詳細信息,但如果您只想讓它立即運行,這里是開始的步驟。

部署資源

1. 登錄您的 Azure 帳戶

2. 單擊上面的Deploy to Azure鏈接,為該項目預配所有資源

作為替代方案,您可以使用Azure 門戶中的部署自定義模板服務部署模板,并在編輯器中選擇構建您自己的模板并從該存儲庫上傳azuredeploy.json文件。

3.為項目新建資源組

4.為您的資源選擇一個區域,選擇一個靠近您以獲得最佳性能的區域

注意:某些資源并非在所有地區都可用

5. 為所有資源提供唯一名稱

注意:某些資源需要全局唯一名稱

設置 Azure 函數

1. 部署完成后,使用左側導航打開新功能應用程序

2.從左側導航中選擇功能

3.選擇左上角的添加

4. 在窗口中選擇以下選項:

開發環境:在門戶中開發

模板:定時器觸發器

新功能:dataSaver

您可以保留任何其他設置
poYBAGN6f9aATjuVAADI5xpT5II461.png
?

5. 創建函數后,從左側導航中選擇Code + Test

poYBAGN6f9iACEpwAABkTg_X3HI619.png
?

6. 在run.csx中,將所有現有代碼替換為:

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

#r "Newtonsoft.Json"

using System;
using Newtonsoft.Json;

public static void Run(string myIoTHubMessage, ICollector outputTable, ILogger log)
{
    log.LogInformation($"C# IoT Hub trigger function processed a message: {myIoTHubMessage}");
    dynamic input = JsonConvert.DeserializeObject(myIoTHubMessage);
    Guid guid = Guid.NewGuid();
    log.LogInformation($"Message guid: {guid}");
    outputTable.Add(
            new outTable() { 
                PartitionKey = "test", 
                RowKey = guid.ToString(), 
                deviceId = input.deviceId.ToString(),
                temperature = input.Temperature}
            );
}

public class outTable
{
    public string PartitionKey { get; set; }
    public string RowKey { get; set; }
    public string deviceId { get; set; }
    public float temperature {get; set;}

}

導航到function.json并將所有現有代碼替換為:

{
    "bindings": [
      {
        "type": "eventHubTrigger",
        "name": "myIoTHubMessage",
        "direction": "in",
        "eventHubName": "samples-workitems",
        "connection": "ai-freezer-hub_events_IOTHUB",
        "consumerGroup": "$Default"
      },
      {
        "name": "outputTable",
        "direction": "out",
        "type": "table",
        "tableName": "tempTable",
        "connection": "AzureWebJobsStorage"
      }
    ]
  }

8. 使用以下選項對異常檢測器功能重復這些步驟:

開發環境:在門戶中開發

模板:IoT 中心(事件中心)

新功能:異常檢測器

您可以保留任何其他設置

運行.csx:

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

#r "Microsoft.WindowsAzure.Storage"
#r "Newtonsoft.Json"
#r "System.Text.Json"

using Microsoft.Extensions.Logging;
using Microsoft.WindowsAzure.Storage.Table;
using System.Threading.Tasks;
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;

public static readonly string emailAlertUrl = Environment.GetEnvironmentVariable("EMAIL_ALERT_URL");
public static readonly HttpClient client1 = new HttpClient();

// Anomaly detection API secrets
public static readonly string subscriptionKey = Environment.GetEnvironmentVariable("ANOMALY_DETECTOR_KEY");
public static readonly string endpoint = Environment.GetEnvironmentVariable("ANOMALY_DETECTOR_ENDPOINT");

const string latestPointDetectionUrl = "/anomalydetector/v1.0/timeseries/last/detect";
public const string batchDetectionUrl = "/anomalydetector/v1.0/timeseries/entire/detect";

public static DateTimeOffset targetTime;

public static async Task Run(TimerInfo myTimer, CloudTable inputTable, ILogger log)
{
    log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
    
    // Get traget time from when to start reading the data
    targetTime = DateTime.UtcNow;
    targetTime = targetTime.AddHours(-6);
    log.LogInformation($"Target start time is: {targetTime}");

    TableQuery rangeQuery = new TableQuery().Where(
        TableQuery.GenerateFilterConditionForDate("Timestamp", QueryComparisons.GreaterThan, targetTime));

    // Execute the query and loop through the results
    List data = new List();
    foreach (DataPoint entity in 
    await inputTable.ExecuteQuerySegmentedAsync(rangeQuery, null))
    {
        data.Add(new DataPoint() {Timestamp = entity.Timestamp, temperature = entity.temperature});
    }

    // Sort data by Timestamp
    data.Sort((dp1, dp2) => DateTimeOffset.Compare(dp1.Timestamp, dp2.Timestamp));
    
    List formatedData = new List();
    data.ForEach( delegate(DataPoint point)
    {
        formatedData.Add(new FormatedData() { timestamp = point.Timestamp.ToString("yyyy-MM-ddTHH:mm:00Z"), value = point.temperature});
    });

    var options = new JsonSerializerOptions
    {
        IgnoreNullValues = true,
        // PropertyNamingPolicy = new LowerCaseNamingPolicy()
    };

    List jsonFormat = new List();
    jsonFormat.Add(new JsonFormat() {series = formatedData, granularity = "minutely", customInterval = 1, period = 90, sensitivity = 85});
    string dataToSend = JsonSerializer.Serialize(jsonFormat, options);

    // Call anomaly detection API
    var anomalies = detectAnomaliesBatch(dataToSend, log);

    if (anomalies != null){
        var json = JsonSerializer.Serialize(anomalies);
        var content = new StringContent(json, Encoding.UTF8, "application/json");
        var response = await client1.PostAsync(emailAlertUrl, content);
        log.LogInformation(response.ToString());
    }
}



static async Task Request(string apiAddress, string endpoint, string subscriptionKey, string requestData)
{
    using (HttpClient client = new HttpClient { BaseAddress = new Uri(apiAddress) })
    {
        System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", subscriptionKey);

        var content = new StringContent(requestData, Encoding.UTF8, "application/json");
        var res = await client.PostAsync(endpoint, content);
        return await res.Content.ReadAsStringAsync();
    }
}

static string detectAnomaliesBatch(string requestData, ILogger log)
{
    log.LogInformation("Detecting anomalies as a batch");
   
    requestData = requestData.TrimEnd(']').TrimStart('[');

    //construct the request
    var result = Request(
        endpoint,
        batchDetectionUrl,
        subscriptionKey,
        requestData).Result;

    //deserialize the JSON object, and display it
    dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(result);
    System.Console.WriteLine(jsonObj);

    string foundAnomalies = "Anomalies detected in the following data positions: ";

    if (jsonObj["code"] != null)
    {
        System.Console.WriteLine($"Detection failed. ErrorCode:{jsonObj["code"]}, ErrorMessage:{jsonObj["message"]}");
        
        log.LogInformation($"Detection failed. ErrorCode:{jsonObj["code"]}, ErrorMessage:{jsonObj["message"]}");
    }
    else
    {
        // log.LogInformation(result);
        //Find and display the positions of anomalies in the data set
        bool[] anomalies = jsonObj["isAnomaly"].ToObject<bool[]>();
        System.Console.WriteLine("\nAnomalies detected in the following data positions:");
        log.LogInformation("\nAnomalies detected in the following data positions:");
        for (var i = 0; i < anomalies.Length; i++)
        {
            if (anomalies[i])
            {
                System.Console.Write(i + ", ");
                log.LogInformation(i + ", ");
                foundAnomalies += i;
                foundAnomalies += ", ";
            }
        }
        if (anomalies.Any(item => item == true))
        {
            return foundAnomalies;
        }
    }
    return null;
}

public class FormatedData
{
    public string timestamp { get; set; }
    public string value { get; set; }
}

public class DataPoint : TableEntity
{
    [JsonPropertyName("value")]
    public string temperature { get; set;}
    public string timestamp { get; set; }
    
}

public class JsonFormat
{
    public List series { get; set; }
    public string granularity { get; set; }
    public int customInterval { get; set; }
    public int period { get; set; }
    // public float maxAnomalyRatio { get; set; }
    public int sensitivity { get; set; }
}

public class LowerCaseNamingPolicy : JsonNamingPolicy
{
    public override string ConvertName(string name) =>
        name.ToLower();
}

函數.json:

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

#r "Microsoft.WindowsAzure.Storage"
#r "Newtonsoft.Json"
#r "System.Text.Json"

using Microsoft.Extensions.Logging;
using Microsoft.WindowsAzure.Storage.Table;
using System.Threading.Tasks;
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;

public static readonly string emailAlertUrl = Environment.GetEnvironmentVariable("EMAIL_ALERT_URL");
public static readonly HttpClient client1 = new HttpClient();

// Anomaly detection API secrets
public static readonly string subscriptionKey = Environment.GetEnvironmentVariable("ANOMALY_DETECTOR_KEY");
public static readonly string endpoint = Environment.GetEnvironmentVariable("ANOMALY_DETECTOR_ENDPOINT");

const string latestPointDetectionUrl = "/anomalydetector/v1.0/timeseries/last/detect";
public const string batchDetectionUrl = "/anomalydetector/v1.0/timeseries/entire/detect";

public static DateTimeOffset targetTime;

public static async Task Run(TimerInfo myTimer, CloudTable inputTable, ILogger log)
{
    log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
    
    // Get traget time from when to start reading the data
    targetTime = DateTime.UtcNow;
    targetTime = targetTime.AddHours(-6);
    log.LogInformation($"Target start time is: {targetTime}");

    TableQuery rangeQuery = new TableQuery().Where(
        TableQuery.GenerateFilterConditionForDate("Timestamp", QueryComparisons.GreaterThan, targetTime));

    // Execute the query and loop through the results
    List data = new List();
    foreach (DataPoint entity in 
    await inputTable.ExecuteQuerySegmentedAsync(rangeQuery, null))
    {
        data.Add(new DataPoint() {Timestamp = entity.Timestamp, temperature = entity.temperature});
    }

    // Sort data by Timestamp
    data.Sort((dp1, dp2) => DateTimeOffset.Compare(dp1.Timestamp, dp2.Timestamp));
    
    List formatedData = new List();
    data.ForEach( delegate(DataPoint point)
    {
        formatedData.Add(new FormatedData() { timestamp = point.Timestamp.ToString("yyyy-MM-ddTHH:mm:00Z"), value = point.temperature});
    });

    var options = new JsonSerializerOptions
    {
        IgnoreNullValues = true,
        // PropertyNamingPolicy = new LowerCaseNamingPolicy()
    };

    List jsonFormat = new List();
    jsonFormat.Add(new JsonFormat() {series = formatedData, granularity = "minutely", customInterval = 1, period = 90, sensitivity = 85});
    string dataToSend = JsonSerializer.Serialize(jsonFormat, options);

    // Call anomaly detection API
    var anomalies = detectAnomaliesBatch(dataToSend, log);

    if (anomalies != null){
        var json = JsonSerializer.Serialize(anomalies);
        var content = new StringContent(json, Encoding.UTF8, "application/json");
        var response = await client1.PostAsync(emailAlertUrl, content);
        log.LogInformation(response.ToString());
    }
}



static async Task Request(string apiAddress, string endpoint, string subscriptionKey, string requestData)
{
    using (HttpClient client = new HttpClient { BaseAddress = new Uri(apiAddress) })
    {
        System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", subscriptionKey);

        var content = new StringContent(requestData, Encoding.UTF8, "application/json");
        var res = await client.PostAsync(endpoint, content);
        return await res.Content.ReadAsStringAsync();
    }
}

static string detectAnomaliesBatch(string requestData, ILogger log)
{
    log.LogInformation("Detecting anomalies as a batch");
   
    requestData = requestData.TrimEnd(']').TrimStart('[');

    //construct the request
    var result = Request(
        endpoint,
        batchDetectionUrl,
        subscriptionKey,
        requestData).Result;

    //deserialize the JSON object, and display it
    dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(result);
    System.Console.WriteLine(jsonObj);

    string foundAnomalies = "Anomalies detected in the following data positions: ";

    if (jsonObj["code"] != null)
    {
        System.Console.WriteLine($"Detection failed. ErrorCode:{jsonObj["code"]}, ErrorMessage:{jsonObj["message"]}");
        
        log.LogInformation($"Detection failed. ErrorCode:{jsonObj["code"]}, ErrorMessage:{jsonObj["message"]}");
    }
    else
    {
        // log.LogInformation(result);
        //Find and display the positions of anomalies in the data set
        bool[] anomalies = jsonObj["isAnomaly"].ToObject<bool[]>();
        System.Console.WriteLine("\nAnomalies detected in the following data positions:");
        log.LogInformation("\nAnomalies detected in the following data positions:");
        for (var i = 0; i < anomalies.Length; i++)
        {
            if (anomalies[i])
            {
                System.Console.Write(i + ", ");
                log.LogInformation(i + ", ");
                foundAnomalies += i;
                foundAnomalies += ", ";
            }
        }
        if (anomalies.Any(item => item == true))
        {
            return foundAnomalies;
        }
    }
    return null;
}

public class FormatedData
{
    public string timestamp { get; set; }
    public string value { get; set; }
}

public class DataPoint : TableEntity
{
    [JsonPropertyName("value")]
    public string temperature { get; set;}
    public string timestamp { get; set; }
    
}

public class JsonFormat
{
    public List series { get; set; }
    public string granularity { get; set; }
    public int customInterval { get; set; }
    public int period { get; set; }
    // public float maxAnomalyRatio { get; set; }
    public int sensitivity { get; set; }
}

public class LowerCaseNamingPolicy : JsonNamingPolicy
{
    public override string ConvertName(string name) =>
        name.ToLower();
}

配置邏輯應用

1. 部署完成后,使用左側導航打開新創建的 Logic App

2.從左側導航中選擇邏輯應用程序設計器

3.選擇+新步驟

4. 搜索您要使用的電子郵件客戶端(Office 365 Outlook、Gmail 和 Outlook.com)

poYBAGN6f9-AFqx7AAA-9pe8Y9k475.png
Azure 邏輯應用設計器
?

5. 選擇發送電子郵件操作

注意:這將根據您使用的電子郵件客戶端而有所不同

6. 使用您的電子郵件帳戶登錄

7. 自定義您的消息,此電子郵件將在任何時候檢測到異常時發送。

設置物聯網設備

1. 接下來,您需要獲取設備的連接字符串,導航到您之前創建的 IoT 中心

2.在左側導航中選擇物聯網設備

3.在頁面左上角選擇+新建

4.給設備一個ID

pYYBAGN6f-qAbWCDAABjuP9k5kk826.png
物聯網設備配置
?

5. 按屏幕底部的保存

6.選擇您創建的設備

7. 復制您將在下一節中使用的主連接字符串

pYYBAGN6f-2AVrTKAAB7a9HJXb0269.png
IoT 設備的連接字符串
?

設備構建

pYYBAGN6f--Af-MvAACU92IQLgI779.jpg
溫度監視器的完整構建
?

1. 將螺絲端子焊接到 MCP9600 的頂部。

poYBAGN6f_KAfuIDAACM8kZfLJc876.jpg
?

2. 將引腳焊接到 MCP9600 的底部。

提示:將引腳放在面包板上,以便在焊接時將它們固定到位。
poYBAGN6f_WANeCIAACz9xdzg7I342.jpg
?

3. 將 ESP32 和熱電偶放大器插入面包板。

4. 按照下面的接線圖,使用跳線將熱電偶放大器連接到 ESP32。

poYBAGN6f_eAZF56AAEbGfX1bgY829.png
?

5. 將熱電偶連接到 MCP9600 上的螺絲端子

下圖使用通用 ESP32 開發板,即將推出帶有 Adafruit Huzzah32 的新圖片!
pYYBAGN6f_qAa_mCAADAL9fVRks425.jpg
?

設備代碼

1. 如果您還沒有,請將此 repo 克隆到您的計算機

2.用VS Code打開AiFreezer文件夾

3.在這個文件夾中新建一個文件,命名為config.h

4. 將以下代碼粘貼到config.h

const char* ssid     = "";
const char* password = "";
static const char* connectionString = "";

5. 填寫您的網絡憑據

6. 從 IoT 中心粘貼連接字符串

7. 按照本 [指南] 的第一部分將 ESP32 擴展添加到 Arduino IDE。

8. 使用 Arduino 的庫管理器安裝下面列出的庫。如果您在 [此處]之前使用過庫管理器,這是一個有用的指南。

9. Adafruit MCP9600

注意:如果系統提示您為這些庫安裝其他依賴項,請選擇全部安裝

10. 在 VS Code 中打開 FreezerTempAlert.ino,打開命令面板(CTL+SHIFT+P)并輸入Arduino:Change Board Type然后搜索Adafruit ESP32 Feather

11.接下來選擇活動串口,打開命令面板并輸入Arduino:選擇串口

12. 最后將您的代碼上傳到您的羽毛板,打開命令面板并輸入Arduino:


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

評論

查看更多

下載排行

本周

  1. 1山景DSP芯片AP8248A2數據手冊
  2. 1.06 MB  |  532次下載  |  免費
  3. 2RK3399完整板原理圖(支持平板,盒子VR)
  4. 3.28 MB  |  339次下載  |  免費
  5. 3TC358743XBG評估板參考手冊
  6. 1.36 MB  |  330次下載  |  免費
  7. 4DFM軟件使用教程
  8. 0.84 MB  |  295次下載  |  免費
  9. 5元宇宙深度解析—未來的未來-風口還是泡沫
  10. 6.40 MB  |  227次下載  |  免費
  11. 6迪文DGUS開發指南
  12. 31.67 MB  |  194次下載  |  免費
  13. 7元宇宙底層硬件系列報告
  14. 13.42 MB  |  182次下載  |  免費
  15. 8FP5207XR-G1中文應用手冊
  16. 1.09 MB  |  178次下載  |  免費

本月

  1. 1OrCAD10.5下載OrCAD10.5中文版軟件
  2. 0.00 MB  |  234315次下載  |  免費
  3. 2555集成電路應用800例(新編版)
  4. 0.00 MB  |  33566次下載  |  免費
  5. 3接口電路圖大全
  6. 未知  |  30323次下載  |  免費
  7. 4開關電源設計實例指南
  8. 未知  |  21549次下載  |  免費
  9. 5電氣工程師手冊免費下載(新編第二版pdf電子書)
  10. 0.00 MB  |  15349次下載  |  免費
  11. 6數字電路基礎pdf(下載)
  12. 未知  |  13750次下載  |  免費
  13. 7電子制作實例集錦 下載
  14. 未知  |  8113次下載  |  免費
  15. 8《LED驅動電路設計》 溫德爾著
  16. 0.00 MB  |  6656次下載  |  免費

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935054次下載  |  免費
  3. 2protel99se軟件下載(可英文版轉中文版)
  4. 78.1 MB  |  537798次下載  |  免費
  5. 3MATLAB 7.1 下載 (含軟件介紹)
  6. 未知  |  420027次下載  |  免費
  7. 4OrCAD10.5下載OrCAD10.5中文版軟件
  8. 0.00 MB  |  234315次下載  |  免費
  9. 5Altium DXP2002下載入口
  10. 未知  |  233046次下載  |  免費
  11. 6電路仿真軟件multisim 10.0免費下載
  12. 340992  |  191187次下載  |  免費
  13. 7十天學會AVR單片機與C語言視頻教程 下載
  14. 158M  |  183279次下載  |  免費
  15. 8proe5.0野火版下載(中文版免費下載)
  16. 未知  |  138040次下載  |  免費