A detailed introduction to Raspberry Pi (Raspberry pi,rpi)

Source: Internet
Author: User
Preface





Raspberry Pi (Raspberry pi,rpi) is designed for students ' computer programming education, only card-sized card computers that can run Linux or Windows IoT core operating systems. This article uses the Raspberry Pi and UWP (Universal Windows Platform) development technology to build a weather station system that can be monitored in real time.



Hardware and technology involved



  



Hardware section:


    • Raspberry Pi 2 or 31 blocks, 8G or more memory card, a card reader (or computer with SD card interface) one;

    • Dht11 temperature and humidity sensor one, GY-68 BMP180 barometer one;

    • LY-69 Soil Moisture Meter One, MQ-2 smoke gas sensor one, raindrop sensor one;

    • Male and female DuPont line some, bread board one, micro USB cable a root, power one;

    • HDMI Interface monitor one (or HDMI to other interface).








Development section:


    • Integrated development Environment: Visual Studio 2017 (Community edition recommended);

    • Development language: C #;

    • Development platform: UWP;

    • Communication protocol: MQTT;

    • Raspberry Pi Operating system: WIndows IoT Core;

    • Database: Sqlite


Download and install the operating system:


    • Install the Windows IoT Core Dashboard app, visit the Microsoft Developer Center, select Raspberry Pi 3,install onto my blank MicroSD card,windows10 IoT Core, click N Ext button comes to the new page, click Download Dashboard button to download and then install.

    • Burn the operating system to the microSD card, after the installation is complete, select Set new device entry to the burn page. Device type Select Raspberry Pi 2&3;os Build Select Windows IoT Core (15063), drive Select the microSD card to insert, enter device name, password, confirm password, tick Wi-Fi network connection ( After checking this, you can copy the WLAN information connected by the current computer to the operating system of the Raspberry Pi Board, eliminating the hassle of re-configuring it. The Raspberry Pi installation of the Windows IoT operating system is complete.


Such as:






Windows Device Portal:



In the same network environment, the browser input the IP address of the Raspberry Pi, the port is 8080, enter the user name and password prompt. The default user name is Administrator, which is the password that is set when the operating system is burned, and can only be reinstalled if the password is forgotten. Successful login will see the Raspberry Pi Development Board under the current operating system details, application management interface, set the default program and boot boot and so on.






Realize






MQTT Communication:






MQTT (msg Queuing Telemetry Transport, Message Queuing telemetry transmission) is an Instant Messaging protocol developed by IBM. After years of development, MQTT has been used in a variety of fields, and it can be used as a messaging push tool for mobile clients, and has a large proportion in Android applications. As a communications protocol designed for the internet of Things, MQTT has the features to work in a low-bandwidth, unstable network environment. It has three modes of message delivery:





    1. At most one time, messages are lost or duplicated, and this mode is suitable for the sensor class's data transfer, even if the message is lost and will be sent again soon.

    2. Only once, make sure that the message arrives and that no duplicate data occurs, for systems that require accurate data, such as billing systems.

    3. At least once, make sure the message arrives, but duplicates may occur.


For an MQTT server build, you can refer to:



The use of Mqtt under the UWP can be referenced by:



To use Mqtt under the UWP, you need to install the NuGet package M2mqtt



Here I'll stick to the MQTT connection code:





 public class Mqtt : MqttClient
    {public Mqtt(string host) : base(host, 61613, false, MqttSslProtocols.None)
        {
            Connect(Guid.NewGuid().ToString(), "admin", "password");
            Subscribe(new string[] { "atmo" }, new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE });           // PostData("Hello World!");        } public void RequestData(string msg)
        {
            Publish("atmo", Encoding.UTF8.GetBytes(msg));
        }public void PostData(string msg)
        {
            Publish("atmo", Encoding.UTF8.GetBytes(msg));
        }
    }





SQLite implementations:



To use SQLite under the UWP requires first installing the VS extension SQLite for Universal Windows platform and NuGet package SQLITE.NET-PCL. For more information on how to use SQLite, refer to:



The following is the database class in this system:


 public class DataBase : SQLiteConnection
    {public static string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, "atmo.db");public DataBase() : base(new SQLitePlatformWinRT(), path)
        {
            CreateTable<DataModel>();
        }
    }


INotifyPropertyChanged Interface Implementation


 public class ViewModelBase : INotifyPropertyChanged
    {public event PropertyChangedEventHandler PropertyChanged;protected void OnPropertyChanged([CallerMemberName]string name = "")
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
    }





Raspberry Pi Gpio diagram









Hardware Connection diagram:






Sensor PIN Diagram:









Project Address:



The project is not perfect, please add and correct!







Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.