Practical Configuration for Raspberry Pi B (VNC and Serial Port)

This section discusses practical application configurations, which are not the configurations mentioned earlier under the /boot partition such as config.txt for the display, GPU, etc. Since this is called getting started, the main focus is on practical configurations.

1. Serial Port Debugging with Raspberry Pi

The cables used are USB to TTL cables. Practical Configuration for Raspberry Pi B (VNC and Serial Port) Generally, there are four colors: red, black, white, and green. The red power line is not needed; only the other three lines are used.

The white line is TX, indicating the transmission line.

The green line is RX, indicating the reception line.

The black line is GND, the ground line.

Corresponding to the default mode of Raspberry Pi’s P1, it is as follows:

Black GND = pin 6

White TX = pin 8

Green RX = pin 10. After connecting, it looks like this in the image: Practical Configuration for Raspberry Pi B (VNC and Serial Port)Practical Configuration for Raspberry Pi B (VNC and Serial Port) The P1 pin order can also be seen on the board. This is where it starts from pin 1, and the other end connects to the Ubuntu PC, usually shown as /dev/ttyUSB0 in PC devices. Use #ls /dev/ttyUSB* to find this device, and we use putty to connect to the device: #sudo putty Practical Configuration for Raspberry Pi B (VNC and Serial Port) First, select serial, then fill in the serial line /dev/ttyUSB0, and set the speed to 115200. Open it to pop up a black box and wait for data. At this time, we will power on the Raspberry Pi and restart it. You will see a lot of printed information from the serial port interface; there is a lot of information Practical Configuration for Raspberry Pi B (VNC and Serial Port) Since the Raspberry Pi has also enabled serial login, the final serial port status is waiting for the login state Practical Configuration for Raspberry Pi B (VNC and Serial Port) Enter ‘pi’ and the password ‘raspberry’ to log in. You can also control ‘pi’ Practical Configuration for Raspberry Pi B (VNC and Serial Port) Subsequent operations should be done via the serial port as much as possible. Using SSH to log in for some installation operations may bring some PC environments, such as language configurations, into PI, causing various problems. Therefore, we will perform all subsequent operations in the serial port. Some images are saved from before and are not directly operating the serial port, so they look slightly different.

1. Configure Static IP for Raspberry Pi

In the previous section, we found the login IP of Raspberry Pi using nmap or the router. However, the IP is DHCP, so it is not fixed every time it starts. Therefore, we need to configure a static IP. Previously, we connected to the Raspberry Pi via the default SSH. Therefore, we can modify /etc/network/interfaces: #cd /etc/network delete #sudo rm interfaces create a new one: #sudo nano interfaces directly operate to input content (the ‘eth’ after is a zero, not an ‘O’) auto eth0 iface eth0 inet static address 192.168.1.9 netmask 255.255.255.0 gateway 192.168.1.1 Specific IP should be filled according to your local area network Practical Configuration for Raspberry Pi B (VNC and Serial Port) Press ctrl+o Practical Configuration for Raspberry Pi B (VNC and Serial Port) Then press enter to save and press ctrl+x to exit. The basic operation of nano is like this. The vi editor is relatively difficult for beginners. RPi provides nano to simplify a bit. To prove that we wrote successfully, we can use cat to check: #cat interfaces Restart to see if the configuration is successful: #sudo reboot After restarting, try pinging the IP after a minute. It is found to be OK Practical Configuration for Raspberry Pi B (VNC and Serial Port) This indicates that the configuration has been successful. Wireless configuration

This is the wired configuration. It is inconvenient to always connect to the wired network to play with Raspberry Pi. Therefore, it is best to use wireless. First, confirm that the Raspberry Pi recognizes the USB wireless network card you inserted. It has already provided a model that does not require drivers. Let’s check if it is recognized: #lsusb Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub The first Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter has recognized our wireless device. No need to compile any drivers. The same is to modify /etc/network/interfaces. Only the content inside changes to: auto wlan0 allow-hotplug iface wlan0 inet static wpa-ssid “wifissid” wpa-psk “password” address 192.168.1.9 netmask 255.255.255.0 gateway 192.168.1.1 My network is your SSID name. wpa-psk contains your wireless password. Your wireless should also use PSK encryption. Practical Configuration for Raspberry Pi B (VNC and Serial Port)2. Expand Raspberry Pi’s Storage Use #df -h to check the storage and find that the / directory is occupied 100% #df -h Filesystem Size Used Avail Use% Mounted on /dev/root 3.6G 3.4G 0 100% / If not expanded, there will be no other space to install software. In fact, our SD card may have 16G or 32G, so we need to use Raspberry Pi’s configuration command to expand the space by entering: #sudo raspi-config to pop up the configuration interface Practical Configuration for Raspberry Pi B (VNC and Serial Port) The first item, just press enter to start expanding. It will prompt that the expansion is complete. After the next reboot, the space will be larger Practical Configuration for Raspberry Pi B (VNC and Serial Port) After choosing finish, it will prompt you to reboot. Just reboot, and again: #df -h Filesystem Size Used Avail Use% Mounted on /dev/root 15G 3.4G 11G 25% / Now my / directory only uses 25%. It was originally 16 G. More software can be installed.

3. Install VNC Visualization Interface for Raspberry Pi Until now, we have only logged in using the command line and have never seen the Raspberry Pi’s UI interface. After logging in via the serial port, #sudo apt-get update #sudo apt-get install tightvncserver Wait for tightvncserver to finish installing. Once installed, start configuring to manually start vncserver, with port number 1. This port number is not the same as TCP UDP. Execute: #vncserver :1 Practical Configuration for Raspberry Pi B (VNC and Serial Port) The first time you need to set a password. The password must be less than or equal to 8 characters and needs to be filled and verified multiple times. Practical Configuration for Raspberry Pi B (VNC and Serial Port) Next, you can connect using vncview on the PC machine. Test with UBUNTU by connecting with vncviewer: #vncviewer ip:1 #vncviewer 192.168.1.202:1 Practical Configuration for Raspberry Pi B (VNC and Serial Port) Enter the previously set password; login successfully Practical Configuration for Raspberry Pi B (VNC and Serial Port) This is the Raspberry Pi interface! If conditions allow, you can connect an external VGA or HDMI monitor. At the same time, if there are display issues, please refer to the official Raspberry Pi tutorial for configuring /boot/config.txt. As beginners, there is no need to buy another monitor; using the PC VNC viewer is more convenient and cost-effective. Finally, we need to set the VNC service to start automatically. This way, every time the Raspberry Pi starts, we can log in with vncviewer to check it. #cd /etc/init.d/ #sudo nano autostartvnc Write the content inside (this content is not a standard startup script; the standard has start and stop control mechanisms, but we are using a practical and simple way. I won’t elaborate on startup scripts here.) #!/bin/sh su pi -c “/usr/bin/tightvncserver :1” Save Practical Configuration for Raspberry Pi B (VNC and Serial Port) Set the script to execute and execute the auto-start script: #sudo chmod +x autostartvnc You need to enter /etc/init.d to execute this directory: #sudo update-rc.d autostartvnc defaults Practical Configuration for Raspberry Pi B (VNC and Serial Port)

Now it can start automatically. However, I found an error when I rebooted. VNC did not start, but it can be started manually, which is really strange. The serial port debugging function is now very obvious. /home/pi/.vnc/raspberrypi:1.log found two errors, one is that the 75dpi font file is missing, and the other is that /home/pi/.Xresources cannot be found Practical Configuration for Raspberry Pi B (VNC and Serial Port) So we need to fix this: #sudo apt-get install xfonts-75dpi #touch /home/pi/.Xresources #cd /etc/init.d #sudo update-rc.d autostartvnc defaults Reboot again #vncviewer ip:1 This time you can log in directly. You can now operate directly from the host.

Finally, you can also log in and operate with your mobile phone: mainly used to check the working status. For example, if the Raspberry Pi is currently downloading or compiling something lengthy, and the PC is turned off, we can occasionally check with our mobile phone. Mobile APP download: Special attention. Do not download the domestic version of VNC. Download the VNC viewer from the official website, which is also available on Google Play.

The full name is VNC Viewer. Some domestic VNC viewers falsely use this icon and claim to be enhanced versions, so be sure not to use them. This is all in English. Practical Configuration for Raspberry Pi B (VNC and Serial Port) Create a new VNC link by clicking the green + sign and filling in the IP name. Pay attention to the colon after the IP and the 1; don’t forget Practical Configuration for Raspberry Pi B (VNC and Serial Port) Click connect Practical Configuration for Raspberry Pi B (VNC and Serial Port) Enter the password and you can remember the password. Click continue Practical Configuration for Raspberry Pi B (VNC and Serial Port) The warning prompt can be ignored. Click continue Practical Configuration for Raspberry Pi B (VNC and Serial Port) The lovely Raspberry Pi interface will appear Practical Configuration for Raspberry Pi B (VNC and Serial Port) In the future, as long as the Raspberry Pi is powered on, we can log in and check the status anytime using our mobile phone. Later, with an external hard drive, at 100M speed, we can download movies all day. Wouldn’t you want to see how many have been downloaded? No need to turn on the PC to log in; just use your phone. Finally, if necessary, we can modify the software source for Raspberry Pi. When installing software, the default is to download from the Raspberry Pi source, which is very slow. Software updates and downloads take a long time. Fortunately, Alibaba Cloud provides such domestic mirrors. In some areas, Alibaba Cloud may not work well. You can search for other sources and back up the original source. The source location is saved in /etc/apt/source.list: #cd /etc/apt #sudo cp sources.list sources.list.bak Start editing: #sudo nano source.list Delete the original content inside and fill in Alibaba Cloud’s source: deb http://mirrors.aliyun.com/raspbian/raspbian wheezy main non-free contrib rpi Start updating the data: #sudo apt-get update If unable to update or fails, restore the original backup and honestly update from the official source. In the next episode, we will try to light up an LED.

See Snow Crowdsourcing: http://ce.kanxue.com

Snow Forum: http://bbs.pediy.com/

Practical Configuration for Raspberry Pi B (VNC and Serial Port)

—– WeChat ID: ikanxue —–

Snow • Security has been focusing on security for 16 years, providing professional services for you!

Leave a Comment

Your email address will not be published. Required fields are marked *