chinese直男口爆体育生外卖, 99久久er热在这里只有精品99, 又色又爽又黄18禁美女裸身无遮挡, gogogo高清免费观看日本电视,私密按摩师高清版在线,人妻视频毛茸茸,91论坛 兴趣闲谈,欧美 亚洲 精品 8区,国产精品久久久久精品免费

電子發(fā)燒友App

硬聲App

掃碼添加小助手

加入工程師交流群

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

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示
創(chuàng)作
電子發(fā)燒友網(wǎng)>電子資料下載>電子資料>Netduino WiFi鎖開源分享

Netduino WiFi鎖開源分享

2022-11-08 | zip | 3.60 MB | 次下載 | 免費(fèi)

資料介紹

描述

無鑰匙進(jìn)入和智能鎖

智能鎖的想法已經(jīng)出現(xiàn)了一段時(shí)間,但歸根結(jié)底,人們最終還是要么攜帶 RFID,要么只使用鎖本身。我們現(xiàn)在幾乎一直隨身攜帶手機(jī),到門口時(shí),我們會(huì)自動(dòng)連接到我們自己的 WiFi 網(wǎng)絡(luò)。通過使用Netduino 3 WiFi,我們實(shí)際上可以實(shí)現(xiàn)真正的無鑰匙體驗(yàn),以我們的手機(jī)為鑰匙,通過WiFi網(wǎng)絡(luò)開鎖。

第 1 步:收集材料

我們將需要以下物品:

  • 網(wǎng)絡(luò)杜伊諾 3 WiFi
  • Seeed Grove 基礎(chǔ)護(hù)盾
  • 種子繼電器
  • 鎖舌
  • 安卓手機(jī)
  • 一個(gè)外殼的盒子
?
pYYBAGNombSAfQAhAAOVeyOi3vU427.jpg
?

?

第 2 步:設(shè)置 Netduino 3 WiFi

Netduino 是基于 ac# 和 .net 的物聯(lián)網(wǎng)板,具有很多功能,這樣我們就可以基于 C# 創(chuàng)建整個(gè)項(xiàng)目。

安裝 Visual Studio,在這種情況下,我使用的是 Mac。然后進(jìn)入 Visual Studio Community menu -> Extension -> Gallery,并搜索“MicroFramework”來安裝 Micro Framework。

?
poYBAGNombeAJeDcAABk7aTTUZ8643.png
微框架
?

按照此頁面的說明更新到最新固件

安裝最新固件后,我們需要通過 Netduino Deploy 設(shè)置 WiFi 網(wǎng)絡(luò),以便設(shè)備連接到互聯(lián)網(wǎng),我們將在這里使用靜態(tài) IP,以便稍后使用手機(jī)調(diào)用套接字

?
poYBAGNombmAAkicAABvi6jCZkA422.png
Netduino 部署
?

第 3 步:連接硬件

因?yàn)殒i舌需要 12v,而 Netduino 的常規(guī)輸出只能提供 5v,所以我們需要通過在頂部焊接 2 根電線來接入 Netduino 的電源,如下所示,這將允許我們?cè)跊]有額外電源的情況下打開和關(guān)閉鎖舌。

?
pYYBAGNomcCATfPPAA2Q0BK47EM648.jpg
修改后的 Netduino,帶 12v 輸出
?

然后,我們可以利用設(shè)備的 12v 輸出直接連接到繼電器,一個(gè)連接到鎖舌,因此繼電器將從電路板本身接收 12v 正電壓,并從繼電器接收負(fù)電壓。當(dāng)一切都說完了,它應(yīng)該如下所示

?
pYYBAGNomd-AbLEeABDPCFKeYhQ542.jpg
接線架
?

第 4 步:設(shè)置 Netduino 網(wǎng)絡(luò)服務(wù)器

我們現(xiàn)在可以使用以下代碼連接到周圍的計(jì)算機(jī)。當(dāng)它工作時(shí),我們可以進(jìn)入下一步,我們已經(jīng)創(chuàng)建了一個(gè) NetDuino Webserver 供其他設(shè)備通過 Wifi 網(wǎng)絡(luò)連接。以下代碼設(shè)置插座,當(dāng)收到“ON”時(shí),它會(huì)打開 LED 以及繼電器,這允許我們打開鎖。

using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Net.NetworkInformation;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace Lock
{
 public class Program
 {
 // Main method is called once as opposed to a loop method called over and over again
 public static void Main()
 {
 Thread.Sleep(5000);
 App app = new App();
 app.Run();
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
 OutputPort relay = new OutputPort(Pins.GPIO_PIN_D5, false);
int port = 80;
Socket listenerSocket = new Socket(AddressFamily.InterNetwork,
 SocketType.Stream,
 ProtocolType.Tcp);
 IPEndPoint listenerEndPoint = new IPEndPoint(IPAddress.Any, port);
Debug.Print("setting up socket");
// bind to the listening socket
 listenerSocket.Bind(listenerEndPoint);
 // and start listening for incoming connections
 listenerSocket.Listen(1);
 Debug.Print("listening");
while (true)
 {
 Debug.Print(".");
// wait for a client to connect
 Socket clientSocket = listenerSocket.Accept();
 // wait for data to arrive
 bool dataReady = clientSocket.Poll(5000000, SelectMode.SelectRead);
// if dataReady is true and there are bytes available to read,
 // then you have a good connection.
 if (dataReady && clientSocket.Available > 0)
 {
 byte[] buffer = new byte[clientSocket.Available];
 clientSocket.Receive(buffer);
 string request =
 new string(System.Text.Encoding.UTF8.GetChars(buffer));
Debug.Print(request);
if (request.IndexOf("ON") >= 0)
 {
 led.Write(true);
 relay.Write(true);
 Thread.Sleep(5000);
 led.Write(false);
 relay.Write(false);
 }
string statusText = "Lock is " + (led.Read() ? "ON" : "OFF") + ".";
 // return a message to the client letting it
 // know if the LED is now on or off.
 string response = statusText ;
 clientSocket.Send(System.Text.Encoding.UTF8.GetBytes(response));
}
 // important: close the client socket
 clientSocket.Close();
}
}
 }
public class App
 {
 NetworkInterface[] _interfaces;
public string NetDuinoIPAddress { get; set; }
 public bool IsRunning { get; set; }
public void Run()
 {
 //this.IsRunning = true;
 bool goodToGo = InitializeNetwork();
this.IsRunning = false;
 }
protected bool InitializeNetwork()
 {
 if (Microsoft.SPOT.Hardware.SystemInfo.SystemID.SKU == 3)
 {
 Debug.Print("Wireless tests run only on Device");
 return false;
 }
Debug.Print("Getting all the network interfaces.");
 _interfaces = NetworkInterface.GetAllNetworkInterfaces();
// debug output
 ListNetworkInterfaces();
// loop through each network interface
 foreach (var net in _interfaces)
 {
 // debug out
 ListNetworkInfo(net);
switch (net.NetworkInterfaceType)
 {
 case (NetworkInterfaceType.Ethernet):
 Debug.Print("Found Ethernet Interface");
 break;
 case (NetworkInterfaceType.Wireless80211):
 Debug.Print("Found 802.11 WiFi Interface");
 break;
 case (NetworkInterfaceType.Unknown):
 Debug.Print("Found Unknown Interface");
 break;
 }
// check for an IP address, try to get one if it's empty
 return CheckIPAddress(net);
 }
// if we got here, should be false.
 return false;
 }
public void MakeWebRequest(string url)
 {
 var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
 httpWebRequest.Method = "GET";
 httpWebRequest.Timeout = 1000;
 httpWebRequest.KeepAlive = false;
httpWebRequest.GetResponse();
 /*
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
                Debug.Print("this is what we got from " + url + ": " + result);
            }*/
 }
protected bool CheckIPAddress(NetworkInterface net)
 {
 int timeout = 10000; // timeout, in milliseconds to wait for an IP. 10,000 = 10 seconds
// check to see if the IP address is empty (0.0.0.0). IPAddress.Any is 0.0.0.0.
 if (net.IPAddress == IPAddress.Any.ToString())
 {
 Debug.Print("No IP Address");
if (net.IsDhcpEnabled)
 {
 Debug.Print("DHCP is enabled, attempting to get an IP Address");
// ask for an IP address from DHCP [note this is a static, not sure which network interface it would act on]
 int sleepInterval = 10;
 int maxIntervalCount = timeout / sleepInterval;
 int count = 0;
 while (IPAddress.GetDefaultLocalAddress() == IPAddress.Any && count < maxIntervalCount)
 {
 Debug.Print("Sleep while obtaining an IP");
 Thread.Sleep(10);
 count++;
 };
// if we got here, we either timed out or got an address, so let's find out.
 if (net.IPAddress == IPAddress.Any.ToString())
 {
 Debug.Print("Failed to get an IP Address in the alotted time.");
 return false;
 }
Debug.Print("Got IP Address: " + net.IPAddress.ToString());
 return true;
//NOTE: this does not work, even though it's on the actual network device. [shrug]
 // try to renew the DHCP lease and get a new IP Address
 //net.RenewDhcpLease ();
 //while (net.IPAddress == "0.0.0.0") {
 //    Thread.Sleep (10);
 //}
}
 else
 {
 Debug.Print("DHCP is not enabled, and no IP address is configured, bailing out.");
 return false;
 }
 }
 else
 {
 Debug.Print("Already had IP Address: " + net.IPAddress.ToString());
 return true;
 }
}
protected void ListNetworkInterfaces()
 {
 foreach (var net in _interfaces)
 {
 switch (net.NetworkInterfaceType)
 {
 case (NetworkInterfaceType.Ethernet):
 Debug.Print("Found Ethernet Interface");
 break;
 case (NetworkInterfaceType.Wireless80211):
 Debug.Print("Found 802.11 WiFi Interface");
 break;
 case (NetworkInterfaceType.Unknown):
 Debug.Print("Found Unknown Interface");
 break;
 }
 }
 }
protected void ListNetworkInfo(NetworkInterface net)
 {
 Debug.Print("MAC Address: " + BytesToHexString(net.PhysicalAddress));
 Debug.Print("DHCP enabled: " + net.IsDhcpEnabled.ToString());
 Debug.Print("Dynamic DNS enabled: " + net.IsDynamicDnsEnabled.ToString());
 Debug.Print("IP Address: " + net.IPAddress.ToString());
 Debug.Print("Subnet Mask: " + net.SubnetMask.ToString());
 Debug.Print("Gateway: " + net.GatewayAddress.ToString());
if (net is Wireless80211)
 {
 var wifi = net as Wireless80211;
 Debug.Print("SSID:" + wifi.Ssid.ToString());
 }
this.NetDuinoIPAddress = net.IPAddress.ToString();
}
private static string BytesToHexString(byte[] bytes)
 {
 string hexString = string.Empty;
// Create a character array for hexadecimal conversion.
 const string hexChars = "0123456789ABCDEF";
// Loop through the bytes.
 for (byte b = 0; b < bytes.Length; b++)
 {
 if (b > 0)
 hexString += "-";
// Grab the top 4 bits and append the hex equivalent to the return string.        
 hexString += hexChars[bytes[b] >> 4];
// Mask off the upper 4 bits to get the rest of it.
 hexString += hexChars[bytes[b] & 0x0F];
 }
return hexString;
 }
public string getIPAddress()
 {
 return this.NetDuinoIPAddress;
 }
 }
}

上傳后,您會(huì)看到下面的圖像,已連接互聯(lián)網(wǎng)。在 Netduino 上部署后,我們可以在終端上使用以下命令

echo "ON" | nc 192.168.1.90 80 
?
Netduino Webserver 解鎖 Deadbolt
?

第 5 步:構(gòu)建 Android 應(yīng)用程序

我們可以構(gòu)建一個(gè)簡(jiǎn)單的 Android 應(yīng)用程序來與我們之前編寫的 Netduino Server 進(jìn)行通信。使用開源幻燈片視圖。

?

?
pYYBAGNomeKAQdHfAADBpIVK1wg535.png
安卓屏幕截圖
?

我們使用以下代碼將消息直接發(fā)送到 Netduino Webserver,這將啟動(dòng)繼電器以解鎖死鎖。

package com.demo.netduinolock;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import java.io.BufferedWriter;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import cheekiat.slideview.SlideView;
public class MainActivity extends AppCompatActivity {
    SlideView mSlideView;
    private Socket socket;
    private static final int SERVERPORT = 80;
    private static final String SERVER_IP = "192.168.1.90";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mSlideView = (SlideView) findViewById(R.id.slide_view);
        mSlideView.setOnFinishListener(new SlideView.OnFinishListener() {
            @Override
            public void onFinish() {
            new ConnectTask().execute();
            mSlideView.reset();
            }
        });
    }
    public class ConnectTask extends AsyncTask, String, String> {
        @Override
        protected String doInBackground(String... message) {
            try {
                InetAddress serverAddr = InetAddress.getByName(SERVER_IP);
                socket = new Socket(serverAddr, SERVERPORT);
                if(socket.isConnected()) {
                    PrintWriter out = new PrintWriter(new BufferedWriter(
                            new OutputStreamWriter(socket.getOutputStream())),
                            true);
                    out.println("ON");
                    out.flush();
                    out.close();
                    socket.close();
                    socket = null;
                }
                else
                {
                    Log.d("doh", "not conneected");
                }
            } catch (UnknownHostException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }
        @Override
        protected void onProgressUpdate(String... values) {
            super.onProgressUpdate(values);
            //response received from server
            Log.d("test", "done ");
            //process server response here....
        }
    }
} 

完成后,如果我們連接到 WiFi,我們可以輕松滑過并解鎖螺栓。

?
使用安卓解鎖螺栓
?

第 6 步:演示您的 WiFi 是您的關(guān)鍵

現(xiàn)在一切都已設(shè)置好,您可以使用手機(jī)解鎖螺栓,而 WiFi 就是您的鑰匙。:-)

?

?


WIFI 智能鎖 Netduino
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

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

評(píng)論

查看更多

下載排行

本周

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

本月

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

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935137次下載  |  10 積分
  3. 2開源硬件-PMP21529.1-4 開關(guān)降壓/升壓雙向直流/直流轉(zhuǎn)換器 PCB layout 設(shè)計(jì)
  4. 1.48MB  |  420064次下載  |  10 積分
  5. 3Altium DXP2002下載入口
  6. 未知  |  233095次下載  |  10 積分
  7. 4電路仿真軟件multisim 10.0免費(fèi)下載
  8. 340992  |  191469次下載  |  10 積分
  9. 5十天學(xué)會(huì)AVR單片機(jī)與C語言視頻教程 下載
  10. 158M  |  183360次下載  |  10 積分
  11. 6labview8.5下載
  12. 未知  |  81606次下載  |  10 積分
  13. 7Keil工具M(jìn)DK-Arm免費(fèi)下載
  14. 0.02 MB  |  73832次下載  |  10 積分
  15. 8LabVIEW 8.6下載
  16. 未知  |  65991次下載  |  10 積分