Drive a car (Raspberry Pi)

Preparations are necessary to play the lab “1. Drive a car”

1 What you need

  • Personal Computer (Windows or Mac)
  • Raspberry Pi 4 Model B (No limitation to the memory capacity. Either OKdo or Element14 can be used.)
  • Sun Founder Raspberry Pi AI Car Kit – PiCar-X (SKU:CN0351D)
  • microSD card (8GB or more)
  • SD card reader (Not required if your computer has a SD slot.)
  • Two 18650 Lithium-ion batteries (With protection circuit)
    • Although Sun Founder recommends lithium-ion batteries without protection circuits, we recommend using those with protection circuits because the former may catch fire if mishandled. Please note the size of the battery increases due to the protection circuit, which may make it difficult to insert the battery into the battery box.
  • 18650 Lithium-ion battery charger
  • Local Area Network and Internet access (Wi-Fi or LAN cable connection)

2 Write Raspberry Pi OS image to the micro SD card

Write an OS image to the microSD by referring to the Sun Founder’s documentation.

  • Supplementary note
    • STEP 4

      • Sun Founder recommends using the “Debian Buster” version, but we use “Debian Bullseye” because of errors that occur during setup.
        > Raspberry Pi OS (64-bit) 
        > A port of Debian Bullseye with the Raspberry Pi Desktop (Compatible with Raspberry Pi 3/4/400) 
        > Released: 2023-05-03
    • STEP 6

      • hostname: raspberrypi
      • Username: pi
      • Password: any (You use it later.)
      • Wi-Fi setup is not required when connecting to a network using a LAN cable.

3 Assemble a PiCar-X halfway

Referring to the YouTube video, assemble a PiCar-X up to the point where the Raspberry Pi and Robot HAT board (white one) are connected. (up to about 08:25 in the video)

  • Stop assembling at this point and install the necessary modules on the Raspberry Pi. (If you assemble it all the way to the end, you may have to disassemble it to adjust the motors.)

4 Remotely access Raspberry Pi from your computer

  1. Insert the microSD card to the slot on the Raspberry Pi.
  2. Turn on the Robot HAT board and start the Raspberry Pi.
    • It takes a little while for the Raspberry Pi to start.
  3. Connect the Raspberry Pi to the same local area network to which your computer is connected.
    • If connecting them over a LAN cable, plug it into the Raspberry Pi.
    • If connecting them over Wi-Fi, do nothing.
  4. Remotely access Raspberry Pi from your computer via SSH.
    • Open the command prompt (“Power Shell” for Windows or “Terminal” for mac).


    • Excecute the SSH command below.

      > ssh pi@raspberrypi.local
    • Enter “yes” when the following message is displayed. (Only the first time)

      > The authenticity of host ‘raspberrypi.local (fe80::8efa:432f:f776:dcf1%10)’ can’t be established.
      > ED25519 key fingerprint is SHA256:3Lw04A+Ox+jzsoyKOu3E1hse8vSYtBGpBVAxULcBxCE.
      > This key is not known by any other names
      > Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    • Next, enter the password you set in the Raspberry Pi Imager.

      > pi@raspberrypi.local’s password:
    • The connection is successful when the following message is displayed.

      > pi@raspberrypi:~ $


    • To disconnect from SSH connection, execute the “exit” command.

      > exit
    • If you get the error “WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!”, execute the following command.

      > ssh-keygen -R raspberrypi.local

5 Install the necessary modules on the Raspberry Pi

  1. Open the command prompt and execute the SSH command.

    > ssh pi@raspberrypi.local
    > pi@raspberrypi.local’s password:
  2. Install the modules. Follow the instructions here.
    • An error may occur during the installation of the vilib module, but you do not have to address it as it is related to the image recognition functionality that will not be used in this project.
    • Run i2samp.sh after rebooting the Raspberry Pi. Otherwise it will not work properly.

6 Calibrate the servo motors

  1. Open the command prompt and execute the SSH command.

    > ssh pi@raspberrypi.local
    > pi@raspberrypi.local’s password:
  2. Calibrate the servo motors. Follow the instructions here.

7 Assemble a PiCar-X to the end

Refer to the included instructions and YouTube video to assemble it all the way to the end.

8 Transfer a Python program for Mind Render to the Raspberry Pi

  1. Download the zip file “mrcar.zip” from the button below.
  1. Extract the downloaded zip file.
  2. Open the command prompt.
  3. Go to the location where the expanded folder is located.
    • For example, if you have the folder on your desktop,

      > cd ~/Desktop
  4. Execute the SCP command.

    > scp -r mrcar pi@raspberrypi.local:~/mind-render/

    Enter your password.

    > pi@raspberrypi.local’s password:
  5. Execute the SSH command.

    > ssh pi@raspberrypi.local
    > pi@raspberrypi.local’s password:
  6. Execute setup.sh.

    > cd ~/mind-render/mrcar
    > sh ./setup.sh

9 Run the Python program for Mind Render

  1. Open the command prompt and execute the SSH command.

    > ssh pi@raspberrypi.local
    > pi@raspberrypi.local’s password:
  2. Run the program.

    > cd ~/mind-render/mrcar
    > sudo python3 main.py
  3. To stop the program, press “Ctrl+C”.

10 Start Mind Render and run the lab program

Start Mind Render and run the lab program.(iPhone/Android smartphone or tablet, Windows, or Mac)

  1. Navigate to Create (or Lab) > Connect with external > Raspberry Pi > 1. Drive a car and click the “Start” button.
  2. Click the green “Raspberry Pi” image on the scene edit screen.
  3. Connect Mind Render and the Raspberry Pi on the Bluetooth connection screen that appears.
    (Select “Raspberry MR Car” or “raspberrypi”)
  4. Close the connection screen.
  5. Close the connection screen.
  6. Press the Run button to execute the program.

*Raspberry Pi is a trademark of Raspberry Pi Ltd.
*Other product names and company names mentioned herein are generally trademarks or registered trademarks of their respective companies.