Академический Документы
Профессиональный Документы
Культура Документы
1. PIR Sensor senses if any object moves over it, within 120 degrees.
2. Sends message(deviceID,TimeStamp) to Azure IoT hub when PIR Senses an Object.
3. Console Application(ServiceSide) reads event hub data.
4. After detecting consecutive 10 motions, Console App will send message as “Alert”.
5. Buzzer makes sound after receiving message as FacesDetected from hub.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Devices.Gpio;
using Microsoft.Azure.Devices.Client;
using System.Text;
namespace homesecurity_clientapp
{
/// <summary>
/// An empty page that can be used on its own or navigated to
within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
const string deviceConnectionString = "HostName =
security.azure - devices.net;
SharedAccessKeyName=iothubowner;SharedAccessKey=nvkm6kUI287iGJnG/tgrtT
cUKOPdj/K5YpTU=";
private const int BUZZER_PIN = 12;
private const int PIR_PIN = 69;
private GpioPin BuzzerPin;
private GpioPin PirPin;
private GpioPinValue BuzzerPinValue;
public MainPage()
{
this.InitializeComponent();
initgpio();
Recieve();
}
await Recieve();
}
BuzzerPin.Write(GpioPinValue.Low);
BuzzerPin.SetDriveMode(GpioPinDriveMode.Output);
PirPin.SetDriveMode(GpioPinDriveMode.Input);
PirPin.DebounceTimeout = TimeSpan.FromMilliseconds(500);
PirPin.ValueChanged += buttonPin_ValueChanged;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.ServiceBus.Messaging;
using Microsoft.Azure.Devices;
namespace home1
{
class Program
{
static ServiceClient serviceClient;
static DateTime startingDateTimeUtc;
static Dictionary<string, int> dictionary = new
Dictionary<string, int>();
//check this once!!
static string connectionString = "HostName=security.azure-
devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=nvkm6kUI28
7iGJnG/tgrtTcUKOPdj/K5YpTdKJpqPGU=";
static void Main(string[] args)
{
serviceClient =
ServiceClient.CreateFromConnectionString(connectionString);
ConnectCloud();
}