Difference between revisions of "Template:13.3inch PiPad C4 Guide"

From Waveshare Wiki
Jump to: navigation, search
(Created page with "== Write Raspberry Pi OS== *Download the lasted Raspberry Pi OS image from the [https://www.raspberrypi.com/software/operating-systems/ Rasberry Pi website] and write it to an...")
 
 
(24 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Write Raspberry Pi OS==
 
== Write Raspberry Pi OS==
 
*Download the lasted Raspberry Pi OS image from the [https://www.raspberrypi.com/software/operating-systems/ Rasberry Pi website] and write it to an empty micro SD card.
 
*Download the lasted Raspberry Pi OS image from the [https://www.raspberrypi.com/software/operating-systems/ Rasberry Pi website] and write it to an empty micro SD card.
*Create a new txt file under the BOOT directory of the micro SD card and name it SSH.  
+
**[[Write Image for Compute Module Boards eMMC version]]
*Modify config.txt file which is located at BOOT directory, add the following lines to config.txt file
+
**[[Wrote Image for Compute Module Boards Lite version |Write Image for Compute Module Boards Lite version]]
 +
*Create a new Txt file under the BOOT directory of the micro SD card and name it SSH.  
 +
*Modify the config.txt file which is located in the BOOT directory, and add the following lines to the config.txt file.
 
<pre>
 
<pre>
 
hdmi_group=2
 
hdmi_group=2
Line 8: Line 10:
 
hdmi_cvt 1920 1080 60 6 0 0 0
 
hdmi_cvt 1920 1080 60 6 0 0 0
 
</pre>
 
</pre>
*Save and insert the micro SD card to Raspberry Pi.  
+
*Save and insert the micro SD card into Raspberry Pi.  
*Connect the Magic mirror to network and power on Raspberry Pi.
+
*Connect the Magic mirror to the network and power on Raspberry Pi.
*After booting, you can access Raspberry Pi via SSH, or directly connect the keyboard and mouse.
+
*After booting, you can access Raspberry Pi via SSH/VNC, or directly connect the keyboard and mouse.
 +
 
 
==Check the USB Audio Card==
 
==Check the USB Audio Card==
*Test the sound output device
+
*Test the sound output device:
 
<pre>
 
<pre>
 
aplay -l
 
aplay -l
 
</pre>
 
</pre>
*Test the sound input device
+
*Test the sound input device:
 
<pre>
 
<pre>
 
arecord -l
 
arecord -l
 
</pre>
 
</pre>
 
+
==USB2.0==
== Install Magic Mirror driver ==
+
To reduce consumption, USB interfaces are disabled in CM4 by default. If you need to use USB ports, please add the following line to the config.txt file.<br />
*Open terminal and run the following commands
 
<pre>
 
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
 
sudo apt install -y nodejs
 
git clone https://github.com/MichMich/MagicMirror
 
cd MagicMirror/
 
npm install
 
</pre>
 
*After installing, run the command to display
 
<pre>
 
DISPLAY=:0 npm start
 
</pre>
 
:[[File:MgicMirror-1.png|600px]]
 
*Install MMM-VoiceAssistant model and display
 
<pre>
 
cd ~/MagicMirror/modules
 
git clone https://github.com/waveshare/MMM-VoiceAssistant.git
 
cd MMM-VoiceAssistant
 
cp config/config.js.en ~/MagicMirror/config/config.js
 
cd ~/MagicMirror
 
DISPLAY=:0 npm star
 
</pre>
 
:[[File:MgicMirror-2.png|700px]]
 
 
 
== Install Python3 virtual environment ==
 
<pre>
 
sudo apt-get update
 
sudo apt-get install python3-dev python3-venv
 
python3 -m venv env
 
env/bin/python -m pip install --upgrade pip setuptools wheel
 
source env/bin/activate
 
</pre>
 
 
 
'''Note: The following steps should be taken in the virtual environment, if you close the terminal and restart it, you should use the command below to enter the environment again firstly'''
 
 
 
<pre>
 
source ~/env/bin/activate
 
</pre>
 
 
 
==Install snowboy ==
 
*Install independency libraries
 
<pre>
 
sudo apt-get install swig
 
sudo apt-get install libatlas-base-dev
 
sudo apt-get install portaudio19-dev
 
sudo apt-get install flac
 
pip3 install PyAudio
 
pip3 install SpeechRecognition
 
</pre>
 
*Download snowboy
 
 
<pre>
 
<pre>
git clone https://github.com/Kitt-AI/snowboy.git
+
dtoverlay=dwc2,dr_mode=host
cd snowboy/swig/Python3
 
make
 
cd ../../examples/Python3
 
 
</pre>
 
</pre>
*Modify snowbiydecoder.py file. Change '''from.import snowboydetect''' to '''import snowboydetect'''. Save and enable snowboy
+
Then reboot the CM4.
 +
<font color=red>
 +
If you use the newest Bullseye image, the USB2.0 is set to OTG mode by default, and occurs the error in CM4:
 
<pre>
 
<pre>
cd ~/snowboy/examples/Python3
+
config failed, hub doesn't have any ports! (err -19)
python3 demo.py resources/models/smart_mirror.umdl
 
 
</pre>
 
</pre>
*Try to say '''smart mirror''', you will hear '''ding''' and the information below are printed on the mirror'''
+
To remove the errors, you can remove the line ''otg_mode=1'' from the config.txt file and add the line:
 
<pre>
 
<pre>
INFO:snowboy:Keyword 1 detected at time: 2019-12-03 11:30:16
+
dtoverlay=dwc2,dr_mode=host
 
</pre>
 
</pre>
 +
</font>
 +
[[File:13.3inch PiPad C42.png]]
  
==Install Google Assistant Service==
+
== Kepp Display Always On ==
*Create .asoundrc file in /home/pi directory (the user directory)
+
*Modify lightdm.conf.
<pre>
 
nano .asoundrc
 
</pre>
 
*Add the following lines to the .asoundrc file
 
<pre>
 
pcm.!default {
 
  type asym
 
  capture.pcm "mic"
 
  playback.pcm "speaker"
 
}
 
pcm.mic {
 
  type plug
 
  slave {
 
    pcm "hw:0,0"
 
  }
 
}
 
pcm.speaker {
 
  type plug
 
  slave {
 
    pcm "hw:0,0"
 
  }
 
}
 
</pre>
 
*According to the official guide to installing Google Assistant Service
 
**https://developers.google.com/assistant/sdk/guides/service/python
 
*Please follow the third step of the official guide to configure and create an OAuth Client ID JSON file. Don't forget to copy the JSON file to your Raspberry Pi.
 
*Following the fourth step of the guide to register device model
 
* Install Google Assistant SDK
 
<pre>
 
(env) $ sudo apt-get install portaudio19-dev libffi-dev libssl-dev
 
(env) $ python -m pip install --upgrade google-assistant-sdk[samples]
 
</pre>
 
* Authorize model
 
<pre>
 
(env) $ python -m pip install --upgrade google-auth-oauthlib[tool]
 
</pre>
 
* Genegrate credential, please do notrecommend the json file for properly using.
 
<pre>
 
(env) $ google-oauthlib-tool --scope https://www.googleapis.com/auth/assistant-sdk-prototype \
 
      --save --headless --client-secrets /path/to/client_secret_ client-id .json
 
</pre>
 
* Then you will get an URL, please copy it and open it on the browser of your PC.
 
<pre>
 
Please visit this URL to authorize this application: https://...
 
</pre>
 
* Go to the URL, you are asked to log in to your Google Account and get the authorization code by following guides, Copy the code to the terminal
 
<pre>
 
Please go to this URL: https://...
 
Enter the authorization code:
 
</pre>
 
* If the authorization process is done successfully, you will get the information as below.
 
<pre>
 
credentials saved: /path/to/.config/google-oauthlib-tool/credentials.json
 
</pre>
 
*Use the following command to test.
 
<pre>
 
googlesamples-assistant-push to talk --project-id my-dev-project --device-model-id my-model
 
</pre>
 
*: Note: my-dev-project is the Google Could Platform ID of the Actions Console project you created. You need to find the project ID  in Actions Console. my-model is the device model name you create
 
*Press Enter, and try to ask something.
 
 
 
== Set auto-run ==
 
*Install PM2
 
<pre>
 
sudo npm install -g pm2
 
</pre>
 
* Setup pm2
 
<pre>
 
pm2 startup
 
</pre>
 
*You will get informatin below, please copy the command and run it on terminal
 
<pre>
 
[PM2] To setup the Startup Script, copy/paste the following command:
 
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
 
</pre>
 
*Run Magic mirror by PM2
 
<pre>
 
cd MagicMirror/modules/MMM-VoiceAssistant/pi
 
pm2 start mm.sh
 
</pre>
 
*Run snowbiy by PM2
 
<pre>
 
cd MagicMirror/modules/MMM-VoiceAssistant/pi
 
pm2 start snowboy.sh
 
</pre>
 
*Set auto-run
 
<pre>
 
pm2 save
 
</pre>
 
*If you want to disable the sevices, you can aslo use the following command
 
<pre>
 
pm2 stop mm
 
pm2 stop snowboy
 
</pre>
 
 
 
== kepp display lighting all the time==
 
*Modify lightdm.conf
 
 
<pre>
 
<pre>
 
sudo nano /etc/lightdm/lightdm.conf
 
sudo nano /etc/lightdm/lightdm.conf
 
</pre>
 
</pre>
*Find the line "Xserver-command" below [SeatDefaults] section and change it from
+
*Find the line "Xserver-command" below the [SeatDefaults] section and change it from:
 
<pre>
 
<pre>
 
#xserver-command=X
 
#xserver-command=X
Line 198: Line 54:
 
xserver-command=X -s 0 -dpms
 
xserver-command=X -s 0 -dpms
 
</pre>
 
</pre>
*Then save and reboot
+
*-s # – set screen saver not enabled.
 +
*dpms turn off power saving management.
 +
*Then save and reboot:
 
<pre>
 
<pre>
 
sudo reboot
 
sudo reboot
Line 204: Line 62:
  
 
==RS232==
 
==RS232==
To use the RS232 interface, please modify the config.txt file:
+
In /boot/config.txt, add dtoverlay=uart3.<br>
<pre>
+
<syntaxhighlight lang="python">
sudo nano /boot/config.txt
+
sudo nano /boot/config.txt
</pre>
 
Add the following line the file and save
 
<pre>
 
 
dtoverlay=uart3
 
dtoverlay=uart3
</pre>
+
#device name /dev/ttyAMA1
 +
</syntaxhighlight>
 +
 
 
==RS485==
 
==RS485==
To use the RS485, you need to enable the serial port of PI
+
Open the Raspberry Pi terminal and enter the following command to access the configuration screen.<br />
<pre>
+
<syntaxhighlight lang="python">
 
sudo raspi-config
 
sudo raspi-config
</pre>
+
#Select Interfacing Options -> Serial, disable shell visit, and enable hardware UART port. 
Choose Interface Option -> Serial -> No -> Yes, then reboot
+
#Device name: /dev/ttyS0
== Keys description==
+
</syntaxhighlight>
[[File:13.3inch-HDMI-LCD-H-Manual-02.jpg|100px]]
+
[[file:L76X_GPS_Module_rpi_serial.png|center|1200px]]<br />
*1: Open or Close LCD display. If you don't need the LCD for long time, you can use this button to reduce consumption
 
*2: Direction button
 
*3: "OK" function
 
*4: Open menu and "Return" function
 
  
==Notices==
+
== Keys Description==
;1. If the wakeup word is unworkable for you, please log in snowboy website: https://snowboy.kitt.ai, And add the new wakeup word.
+
[[File:13.3inch-HDMI-LCD-H-Manual-02.jpg|190px]]
:[[File:MgicMirror-3.png|600px]]
+
*1: Turn on or off the LCD. If you don't need the LCD for a long time, you can use this button to reduce consumption.
: Click recording icon to record voice and test if the voice model is workable
+
*2: Direction button.
:[[File:MgicMirror-4.png|500px]]
+
*3: "OK" function.
: Download the model file and copy it to ~/MagicMirror/modules/MMM-VoiceAssistant/pi directory.  
+
*4: Open the menu and the "Return" function.
: Modify snowboy.sh file
 
<pre>
 
nano snowboy.sh
 
</pre>
 
: Modify the name to the one you download, for English, you need to modify the snowboy.umdl to yours
 
<pre>
 
cd ~/MagicMirror/modules/MMM-VoiceAssistant/pi
 
~/env/bin/python3 demo.py smart_mirror.umdl snowboy.umdl
 
</pre>
 
:2. Google Assistant Service can only support 500 request every day.
 

Latest revision as of 07:44, 17 January 2024

Write Raspberry Pi OS

hdmi_group=2
hdmi_mode=82
hdmi_cvt 1920 1080 60 6 0 0 0
  • Save and insert the micro SD card into Raspberry Pi.
  • Connect the Magic mirror to the network and power on Raspberry Pi.
  • After booting, you can access Raspberry Pi via SSH/VNC, or directly connect the keyboard and mouse.

Check the USB Audio Card

  • Test the sound output device:
aplay -l
  • Test the sound input device:
arecord -l

USB2.0

To reduce consumption, USB interfaces are disabled in CM4 by default. If you need to use USB ports, please add the following line to the config.txt file.

dtoverlay=dwc2,dr_mode=host

Then reboot the CM4. If you use the newest Bullseye image, the USB2.0 is set to OTG mode by default, and occurs the error in CM4:

config failed, hub doesn't have any ports! (err -19)

To remove the errors, you can remove the line otg_mode=1 from the config.txt file and add the line:

dtoverlay=dwc2,dr_mode=host

13.3inch PiPad C42.png

Kepp Display Always On

  • Modify lightdm.conf.
sudo nano /etc/lightdm/lightdm.conf
  • Find the line "Xserver-command" below the [SeatDefaults] section and change it from:
#xserver-command=X

to

xserver-command=X -s 0 -dpms
  • -s # – set screen saver not enabled.
  • dpms turn off power saving management.
  • Then save and reboot:
sudo reboot

RS232

In /boot/config.txt, add dtoverlay=uart3.

sudo nano  /boot/config.txt
dtoverlay=uart3
#device name /dev/ttyAMA1

RS485

Open the Raspberry Pi terminal and enter the following command to access the configuration screen.

sudo raspi-config
#Select Interfacing Options -> Serial, disable shell visit, and enable hardware UART port.  
#Device name: /dev/ttyS0
L76X GPS Module rpi serial.png


Keys Description

13.3inch-HDMI-LCD-H-Manual-02.jpg

  • 1: Turn on or off the LCD. If you don't need the LCD for a long time, you can use this button to reduce consumption.
  • 2: Direction button.
  • 3: "OK" function.
  • 4: Open the menu and the "Return" function.