RaspberryPi3 (STRETCH) setup from OS installation to Hello World

Introduction

I've set up the Raspberry Pi many times, but each time I've been searching for a setup method. Some people want to share information, so I'll try to summarize it myself.

I wrote SSH settings.

Necessary equipment

First, prepare what you need.

  1. Windows PC (you can do it on mac, but I don't own it, so I'll omit it)
  2. RaspberryPi3 Model B
  3. micro SD card (8GB or more recommended)
  4. HDMI cable
  5. Display (HDMI compatible)
  6. microUSB cable
  7. Keyboard
  8. Mouse

1. Download OS image

Download the required OS image from the following site. Original site

Many OSs are open to the public, but this time I will download Raspbian.

There are two types, DESKTOP and LITH, but they have the following features.

DESKTOP: A desktop environment is included as standard, for beginners LITH: Lightweight and server-friendly only in CUI environment

This time, select the DESKTOP version. Click the link below to start the download. RASPBIAN STRETCH WITH DESKTOP 2018-04-18 Raspbian.png

Unzip the downloaded image with the tool.

2. Write the OS image to the SD card

  1. Install Win32 Disk Imager

  2. Insert the microSD card into your PC

  3. Launch the app and specify the OS image you downloaded earlier in Image File and the drive on which the SD card is mounted in Device.

  1. Click the Write button to write Win32 Disk Imager(2).png

3. Start Raspberry Pi

  1. Insert the SD card Insert the microSD card containing the OS image into the Raspberry Pi.  20180527_082548 - .jpg

  2. Connect the HDMI cable 20180527_081904 --Copy.jpg

  3. Plug in the micro USB cable 20180527_083633 --Copy.jpg

4. Turn on the power If the green LED flashes, the Raspberry Pi is on. The red LED will illuminate when the Raspberry Pi is connected, regardless of whether it is powered on. 20180527_083657 --Copy.jpg   5. Check the display When you start Raspberry Pi, the following screen will be displayed. The startup is now complete. 2018-05-22-131458_1824x984_scrot --copy.png

4. Make initial settings

1. Open the setting screen

  1. Start the terminal and execute the command Click the black icon at the top left of the screen. 2018-05-22-131458_1824x984_scrot --Copy (2) .png

  2. Enter the command in the terminal

$ sudo raspi-config

2018-05-22-131629_631x270_scrot --copy.png

Enter the command and press the Enter key to open the screen below. Make various settings on this screen. 2018-05-22-131702_783x375_scrot --Copy.png

2. Extend the microSD card partition

Select 7 Advanced Options. You can move the cursor with the arrow keys and select with Enter. 2018-05-22-223015_783x375_scrot --Copy.png

Select A1 Expand Filesystem. 2018-05-22-223022_783x375_scrot --Copy.png

This completes the partition expansion. 2018-05-22-223031_783x375_scrot --Copy.png

3. Change location

  1. Japanese localization

Select "4 Localization Options Set up ......".  2018-05-22-132522_783x375_scrot.png   Select I1 Change Locale.  2018-05-27-110123_655x390_scrot.png

Add * with the Space key according to "ja_JP.UTF-8 UTF-8". Use the Tab key to move to and the Enter key to confirm.  2018-05-27-111142_655x390_scrot.png

Select "ja_JP.UTF-8".  2018-05-27-111202_655x390_scrot.png

This completes the Japanese localization. It will switch to Japanese by restarting, but restarting will be done after all the initial settings are completed.

2. Set the time zone to Japan

Select I2 Chage Timezone.  2018-05-22-132602_783x375_scrot.png

Select "Asia".  2018-05-22-132618_783x375_scrot.png

Select "Tokyo".  2018-05-22-132642_783x375_scrot.png

The time is now Japan time.

    1. Keyboard settings Select I3 Change Keyboard Layout.  2018-05-27-114750_655x390_scrot.png

Select "Generic 105-key (Intel) PC".  2018-05-27-114850_655x390_scrot.png

When the US key setting appears, select "Other".  2018-05-27-115124_655x390_scrot.png

Select "Japanese".  2018-05-27-115135_655x390_scrot.png

Select "Japanese --Japanese (OADG 109A)".  2018-05-27-115144_655x390_scrot.png

Select The default for the keyboard layout.  2018-05-27-115150_655x390_scrot.png

Select No compose key.  2018-05-27-115156_655x390_scrot.png

Select "No".  2018-05-27-115210_655x390_scrot.png

This completes the keyboard settings.

Four. Wifi settings (country) Select I4 Change Wi-fi Country.  2018-05-22-222702_783x375_scrot.png

Select "JP Japan".  2018-05-22-222724_783x375_scrot.png

Select "OK".  2018-05-22-222734_783x375_scrot.png

4. Change interface options

    1. Enable camera module Select Interfacing Options.  2018-05-27-121110_655x390_scrot.png

Select P1 Camera.  2018-05-27-121117_655x390_scrot.png

Select .  2018-05-27-121132_655x390_scrot.png

The camera module is now enabled. In addition, let's enable SSH, I2C, etc. as needed.

5. Internet connection

Select 2 Network Options.  2018-05-27-122149_655x390_scrot.png

Select "N2 Wi-fi".  2018-05-27-122201_655x390_scrot.png

Enter the SSID of the network you want to connect to.  2018-05-27-122252_655x390_scrot.png

Enter your password.  2018-05-27-122315_655x390_scrot.png

This completes the wifi settings.

6. Reboot

Select "Finish".  2018-05-27-123012_655x390_scrot.png

If a reboot is requested, it will be rebooted.

This completes the initial settings. Thank you for your hard work. If you back up the OS image after this initial setting is completed, you can save the trouble of initial setting from the next time.

5. Software update

    1. Update package list
$ sudo apt-get update
  1. Update installed packages
$ sudo apt-get upgrade
    1. Upgrade dist to the latest version
$ sudo apt-get dist-upgrade

Steps 1 and 2 should be done every time you start the Raspberry Pi.

  1. HelloWorld Well, the initial setting is finally completed. Next, I would like to display the customary Hello World. This time, we will use Python and C, which are often used in Raspberry Pi.

Hello World in Python

  1. Launch the editor

This time I will use vi, but please use your favorite editor. It is easy to use "nano" for CUI base and "gedit" for GUI base. Python3 (IDLE) is included by default as an integrated development environment.

Installation is required when using editors such as vim and nano

$ sudo apt-get install vim
$ sudo apt-get install nano
  1. coding

Start a text editor and write the program.

$ vi hello.py

hello.py


print ("Hello World")
    1. Run Python is a scripting language, so no compilation is required.
$ python3 hello.py
Hello World

Hello World in C

    1. Launch the editor
$ vi hello.c
  1. coding

hello.c


#include <stdio.h>

int main(){
  printf("Hello World\n");
  return 0;
}
    1. compile
$ gcc -o hello hello.c

Four. Run

$ ./hello
Hello World

7. Summary

This completes the initial setup of Raspberry Pi and Hello World. How was it? The initial settings are difficult, but once you do it, it won't be long. We recommend that you keep a backup.

This time I only displayed Hello World, but you can also do L Chika in Python or C language. I will write about this later.

see you.

I wrote SSH settings.

8. Reference site

Raspberry Pi head family site https://www.raspberrypi.org/

RaspberryPi setup (from writing to SSH setting) https://qiita.com/Halhira/items/1da2ae543217be26988a

How to update Raspberry Pi package http://my-web-site.iobb.net/~yuki/2017-07/raspberry-pi/update/

Recommended Posts

RaspberryPi3 (STRETCH) setup from OS installation to Hello World
Flask tutorial (from installation to hello world)
RabbitMQ Tutorial (1) -From Installation to Hello World (Official Site Translation)
From Kivy environment construction to displaying Hello World
From setting up a Rust environment to running Hello World
From Elasticsearch installation to data entry
From building a Python environment for inexperienced people to Hello world
OpenMPI installation from download to pass-through
Introduction to Ansible Part 1'Hello World !!'
C language to see and remember Part 1 Call C language from Python (hello world)
[Python] Web application from 0! Hands-on (2) -Hello World-
[Note] [PyTorch] From installation to easy usage
How to build Hello, World on #Nix
How to display Hello world in python
Introduction to Scapy ① (From installation to execution of Scapy)
Python beginners tried it in 3 days from OS installation to running Twitter API
Hello world
[Ansible installation procedure] From installation to execution of playbook
Points to note when switching from NAOqi OS 2.4.3 to 2.5.5
From ROS for Windows installation to operation check
From easy git installation to docker startup python
To myself as a Django beginner (3)-Hello world! ---