This article mainly translates:
https://msdn.microsoft.com/magazine/mt694090 have a lot of nonsense, casually spray, but I will not.
Https://blogs.msdn.microsoft.com/lucian
One of the most commonly used phrases in today's technology industry is the internet of things, which enables each device to use the cloud and intelligently. With the cloud, devices can share data and control other devices. We can remotely control the camera and collect analysis data remotely.
Although there are many articles in MSDN Magazine that say how to collect and analyze data, there is no discussion from the point of view of hardware and cabling. The development of IoT requires electronic design, electrical, welding and other hardware. Developers are generally living in a virtual world and don't really want to get real. As if I was like this, in two times. Of course, the original words did not say. Many developers have difficulty knowing how to do hardware, bridging cables and resistors. To solve this problem, this article describes how WIN10 IoT enables developers to not use hardware. It's impossible not to use hardware, but we can make it great for developers not to understand the hardware.
Programmable hardware has been a long time, in the hardware write program need to understand the hardware, Raspberry Pi 2 Model B can run win10, naturally and our computer win10 different. The WIN10 system can be downloaded from the IoT to Dev.windows.com/iot, Raspberry Pi 2 can run the UWP.
This article author will create the UWP in Raspberry Pi 2 Although this is a usage weather API based on his flashing lights. The author introduces the IoT concept and how to use C #. The author here is not me, Frank La Vigne.
Detection Cream
In the spring they will have frost, we want to detect if there is frost we will tell, tell to use bright lights. In addition to software we also need hardware. I need raspberry Pi 2 Model B, MicroSD card,led light, solder-free Circuit test board, many lines.
Raspberry Pi 2 Model B's introduction can be seen in the following blog. I'll send a picture, because the translation is not good.
The MicroSD Card can do raspberry Pi 2 Model b HDD, which installs the system inside of our UWP. Because the author now has a 4G microSD Card, it is used, recommended or 8G. The MicroSD card size is based on demand.
Solder-free Circuit test board, wire Connection Raspberry Pi 2 assembly. Although I can use random connections, the quickest way is the solder-free circuit test board. Like the name I don't need to weld. I need to connect the lines using 30 rows and 10 columns. Note that there are two five groups, "A-e", "f-j", it is easy to know how to do.
LED resistor I will connect the led to the Raspberry Pi 2, the voltage 5V, will make the LED bad, so we need resistors.
Ethernet cable, USB mouse and keyboard, HDMI monitor Raspberry PI 2 has 4 USB we can connect the keyboard, Ethernet, HDMI, we can put Raspberry Pi 2 as a computer.
Download WINDOWS10 can be run in IoT, can go to Https://developer.microsoft.com/zh-CN/windows/iot/Downloads.htm#Win8
Starting the project is a bit difficult, many developers mobile code is not necessarily suitable for the hardware, for this example I made a very simple led flashing, real-time download data from the Internet. The following hardware is required: LED light, solder-free Circuit test Board, cable.
Raspberry Pi 2 Model B has a lot of Gpio, Gpio is General Purpose Input/output, if you want to know Baidu, of course, I think Google is better, concrete over the wall I do not say, I believe you GitHub Host will soon be able to dry Baidu. There are some interfaces are reserved we can not program, then can not be used to have the mark out, it is possible to see what the above diagram is not able to program.
Design circuit
Led needs the circuit can be seen, the electric flow from the Pin1, labeled 3.3V of the interface, 3.3V to the LED is too large, so we need a resistor, then the current stream Gpio 5, according to the PIN, from the above figure we can see is pin29. This interface can be programmed to make the LED become "smart", through the interface high voltage and low voltage, led lit a bit dark.
Now the author will develop to display the above image so that the LED is dimmed, the author merges the switch to connect the Raspberry Pi 2 pin29. The author chooses e column 7 lines and then the LED long to a Column 8 lines, short to a column 7 row. The translation here is nonsense, because I didn't really do it.
The author put the resistor in column C 8 and C row 15, I put the positive pole in column A 15 line, the negative link in the Pin1, you can see below, I do not know whether translation is.
The author installs Windows IoT Core in a microSD card, Raspberry Pi 2, connected. Boot device See below
Hardware setup, we started to write software, first open the artifact, create a new IoT. We need to create a new UWP project, and we'll name WeatherBlink
it.
Open extensionWindows IoT Extensions for the UWP
In MainPage.xaml.cs
, we need to use Windows.Devices.Gpio
using Windows.Devices.Gpio;
We can easily use PIN, below is we use pin voltage high, as if voltage high is not translation voltage
var gpioController = GpioController.GetDefault();gpioPin = gpioController.OpenPin(5);gpioPin.Write(GpioPinValue.High);
The following code gets the pin voltage
var currentPinValue = gpioPin.Read();
The entire app needs GPIO pins and we put him to write members
private GpioPin gpioPin;private GpioPinValue gpioPinValue;
We are constructing
InitializeGPIO(){ var gpioController = GpioController.GetDefault(); gpioPin = gpioController.OpenPin(5); gpioPinValue = GpioPinValue.High; gpioPin.Write(gpioPinValue); gpioPin.SetDriveMode(GpioPinDriveMode.Output);}
We can use Win10 all control, I feel Microsoft this is nothing good. Many IoT have no good interface, for a slag, no interface is really bad, so we need to do an interface. These words are my own, have not been to find out the focus on the one we do not use.
We get a simple UI, and if we can connect the mouse, use compression to update the weather.
The author needs to download weather information from the Internet, my weather can be received from OPENWEATHERMAP.ORG/API json, temperature is k, we can use
privateasyncvoidLoadWeatherData(){ doubleawait GetMinTempForecast(); // 38F/3.3C = 276.483 Kelvin if276.483) { Blink(500); "Freeze Warning!" } else { Blink(2000); "No freezing weather in forecast." }}
If the weather is bad, we're going to have a lot of alarms, and the function we see is our alarm.
privatevoidBlink(int interval){ new DispatcherTimer(); blinkingTimer.Interval = TimeSpan.FromMilliseconds(interval); blinkingTimer.Tick += BlinkingTimer_Tick;}
privatevoidBlinkingTimer_Tick( objectobject e){ var currentPinValue = gpioPin.Read(); if (currentPinValue == GpioPinValue.High) { gpioPin.Write(GpioPinValue.Low); } else { gpioPin.Write(GpioPinValue.High); }}
We need to deploy on the PC and we need to change the build arm
At run select remote, we can see
We can use my Raspberry Pi 2, I heard there are some great gods can not connect, if you can't connect their own write IP, generally, if still not to find me I did not go
Connected we can see my led in the flash, I have not to get, the author does not have a picture, I could not get one, casually find a feeling and this is not
IoT is a new challenge, development needs to run the environment, requires power and network, most of the challenges come from wanting how to add a weatherproof outdoor scene to the container, my IoT needs to show, many challenges determine my code. If my device has a 4G network, I need to consider the data transfer, he means that he needs money and needs to optimize the device data sent.
Although our weather is not using the cloud, many IoT are going to be network, we can make a simple application that can send mail. IoT can be used in many places, so you can play it when you are free.
Code: Https://github.com/ms-iot/samples
Chinese Good blog:
Http://edi.wang/post/2016/3/26/windows-10-iot-gy-30-light-sensor
Http://edi.wang/post/2016/3/28/windows-10-iot-moisture-sensor-raspberry-pi3
Http://edi.wang/post/2016/4/2/windows-10-iot-hc04-ultra-sonic-distance
Http://edi.wang/post/2016/4/3/windows-10-iot-sound-light
Http://edi.wang/post/2016/4/4/windows-10-iot-stepper-motor
Http://edi.wang/post/2016/4/10/windows-10-iot-azure-remote-light
Win10 UWP IoT