Video Graphic Teaching-Install the DotNet Core Blazor program to the Raspberry Pi at the fastest speed and use the webpage to control the GPIO flash

Foreword

dotnet core has developed very well in the 3.0 era. Especially in cross-platform, it has reached a very practical stage.

As a dotnet programmer, you should have a good understanding of Linux, and you can also play with hardware in your spare time and be a little maker

In fact, many online tutorials are uneven. When I looked at various materials before, I took a lot of meaningless detours.  

This teaching is to allow netizens who play cross-border to get started in the shortest time. 

The supporting video address of this article is  https://www.bilibili.com/video/BV1Ap4y1y7Bh/  

 

What is a Raspberry Pi? 

As shown:

 

 

 

The Raspberry Pi is first and foremost a computer  , it has an Arm version of CPU, and memory calculated by G. After installing Linux (official Raspbian), you can go to the desktop to open a webpage to watch videos, and do most of the things Linux can do. 

At the same time, it can also be called hardware , because it has pins like a microcontroller , and unlike the Windows desktop we usually buy, the Raspberry Pi comes with 40 pins

 

For those who are not familiar with hardware, these pins can be interpreted as these uses: 

  1. Power supply, divided into 3.3v, 5v, and ground wire, 
  2. For GPIO output purposes, you can use code to control the voltage of a certain pin. It can achieve the function of turning on / off LED / relay. You can even use a relay to control the switch of 220v household power supply.  (In short, it is a code control switch)
  3. GPIO input purpose, you can monitor the voltage of GPIO, the most commonly used is to make a button. Or used as the simplest communication receiver function.  
  4. More complex voltage output function and collection function. Can be made into a speaker or microphone. (How the quality has not been tested)
  5. The data transmission function uses UART / I2C / SPI / ... to connect and communicate with other hardware. These are all words, you just need to remember that  you can transfer binary data between hardware and hardware at high speed .
  6. Note that various peripherals, such as display screens, such as temperature sensors, etc., are also hardware, and they use this set of methods to transfer binary data. 

OK, this article is just teaching, how to quickly use DotNet Core to control GPIO, and let an LED light flash automatically and periodically. 

 

About the version of the Raspberry Pi

Now the best version of the Raspberry Pi is 4B, 2G memory version is the most cost-effective. The  price is about 270 free shipping, it is recommended that the code farmers should start one.  Take it out and play it when you have time. 

This 4B + 2G version uses TYPE-C power supply. There are 2 HDMI outputs. After starting the desktop, you can view Youku on the web. Comes with a network card / WIFI / Bluetooth, with 4 USB ports. Connect the keyboard and mouse, and the mobile hard disk is no problem. . 

However, for this tutorial,   HDMI is not used, keyboard and mouse are not connected, network cable is not connected, and  WIFI is directly connected

 

Things needed:  

A Raspberry Pi (cannot be ZERO), TF card (the Raspberry Pi itself is not stored), TF card reader (used to write into the system), TYPE-C line (powered by external power supply, computer USB can not be moved ), It is best to have LED lights, the kind of 3.3v. Low voltage forget to connect the resistor will burn. 

Home WIFI, a computer, used to operate this series of things. (Nonsense)

Software to be installed: 

VS2019, used to compile programs. 

PuTTY, WinSCP, Win32 disk imaging tools (please download these yourself, note that now there are download stations with bad intentions everywhere ...)

 

Download and burn the image: 

The Raspberry Pi can be installed with many systems. But the most recommended is of course the official mirror:

https://www.raspberrypi.org/downloads/raspbian/

If you choose the lite version, you do n’t have a desktop. However, there are few downloads. You need to download desktops on demand. 

The lite version address is: 

https://downloads.raspberrypi.org/raspbian_lite_latest

Anyway, I think the download is very card:

In the application manager in the bottom right corner of the QQ point, select Weiyun, create a new-offline download-link, paste the link and close it, then refresh, 

 

Refresh, so that when you download it, you can get a good download speed of 500KB / s

 

After decompression, use image software to write into the TF card: 

 

 

Do not pull out the TF card after writing. We need to create two new files and  copy them into the BOOT partition

 

 

 

wpa_supplicant.conf content

country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="WiFi名字"
psk="WiFi密码"
key_mgmt=WPA-PSK
priority=1
}

 

The purpose of these two files is as follows: 

ssh is to open port 22, otherwise you will not be able to access the Raspberry Pi without a keyboard, mouse or display. 

wpa_supplicant.conf is for setting up WIFI, otherwise you just connect the network cable. 

 

Card, power on, boot

Without the power button, plug in TYPE-C to automatically power on. The red light is the power light, the green light is the hard disk light. Broadly defined hard disk.

Wait 1 minute. God knows if the TF card you bought will work. 

 

Then we test, is it started? Is it connected to Wifi? 

 

 

In addition to ping, you can also enter the router management interface to see if there are more devices under the router. 

The network is OK, also have to see if ssh is turned on, start WinSCP, try to connect: 

 

 

 

Raspberry Pi default username pi , default password raspberry 

At this point, the Raspberry Pi has successfully started. It can be used as a Linux host to play. 

 


 

 

Start playing the DotNet Core part

Blazor Server Side open source program BlazorLinuxAdmin 

 Download the program from  https://github.com/BlazorPlus/BlazorLinuxAdmin (by the way, there is an account to point a star, thank you for not giving money, please help me also point a star for other projects, thank you.)

 

 

Post item:

 

 

 

 

 

 Edit configuration:

 

 

 

 

 

 

 Go back to WinSCP and copy the file

First create a bla directory, ie / home / pi / bla 

 

 

 

Copy everything in the publish folder. 

You will see that there is no dll, and BlazorLinuxAdmin is as big as 99M.

Because it already contains all dlls, it also contains the core of dotnet. No need to install the framework SDK.  

(If you publish the option above, choose to trim unused assemblies, you can compress the size to 50M

 

Set the properties of the program, the X in the permissions means "run", no brain hit. 

 

 

 

The program has been published. 

 

Run the program

Use the old brand PuTTY: 

 

 

Continue to enter pi Enter, enter the password raspberry Enter (do not think that the keyboard is not pressed, just not displayed) 

 

 

 

 

 

After logging in, the default directory is ~ /, which is / home / pi / 

We need to enter the directory bla just now 

cd bla

  

Then start the program just now:

sudo ./BlazorLinuxAdmin

  

 

 

Seeing this information, DotNet Core's website has been launched

 

Visit website: 

On a computer browser, enter  http: // raspberrypi: 6011 / 

 

 

Continue to enter pi and raspberry

Congratulations, the tutorial is now complete. 

 

About GPIO layout

 

 

The ON and OFF of this page can be pressed. You can also use CTRL + click to enter the flashing mode.  

 

For more details, please refer to the video   https://www.bilibili.com/video/BV1Ap4y1y7Bh/  

 

common problem: 

Ping raspberrypi, connect raspberrypi, visit http: // raspberrypi: 6011 / all prompts that there is no host, what should I do? 

This may be because the system failed to recognize the local network, or the Raspberry Pi did not successfully broadcast its name to the network. 

At this time, you can go to the router to see the IP of each device, or guess the IP .. If you ca n’t guess, it may be that the device is not connected to the Internet. Make sure that every step is not wrong. 

 

Guess you like

Origin www.cnblogs.com/zhgangxuan/p/blazor_raspberrypi_gpio.html