Knowledge Base
Raspberry Pi
How do I get an on-screen keyboard?
Florence Virtual Keyboard
Install with:
sudo apt-get install florence
Commands
Stop pm2 command for Magic Mirror
pm2 stop mm
pm2 stop MagicMirror
----------------------------------------------------------------------------
Edit the config file
sudo nano /boot/config.txt
----------------------------------------------------------------------------
Find the screen resolution of your monitor connected with raspberry pi
fbset -s
------------------------------------------------------------------------------
How to remove a module of MagicMirror
cd ~/MagicMirror
rm -rf modules/module_to_delete
------------------------------------------------------------------------------
How to change the hostname of raspberrypi?
1. Update the hostname in this file. Then save the file, and exit the text editor.
sudo nano /etc/hostname
2. Open the /etc/hosts file with your favorite text editor. For example:
sudo nano /etc/hosts
Change the first line and replace your old hostname with the new one. Save the file and exit the editor.
3. Reboot Raspberrypi
sudo reboot
How to change the display to portrait for Touch monitor
In config.txt file
sudo nano /boot/config.txt
Add
display_rotate=3
In 10-evdev.conf file, make the following changes
cd /usr/share/X11/xorg.conf.d
sudo nano 10-evdev.conf
Then, go to the following section
Section "InputClass"
Identifier "evdev touchscreen catchall"
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
EndSection
And add
Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"
Useful links :
https://www.raspberrypi.org/forums/viewtopic.php?p=425962#p425962
https://github.com/swkim01/waveshare-dtoverlays
https://unix.stackexchange.com/questions/42039/configure-touchscreen-on-debian
https://askubuntu.com/questions/890629/my-touchpad-works-like-a-touchscreen
How to install 3rd party modules in Magic Mirror?
1. Go to the modules sub folder in the installed Magic Mirror folder.
cd MagicMirror/modules
2. Clone the git folder of the 3rd party module. For example,
sudo git clone https://github.com/shbatm/MMM-Carousel
3. Install dependencies (If any)
To install the dependencies, you need to go to the respective module that you installed.
For example,
cd MagicMirror/modules/MMM-Carousel
and then install all the dependencies as mentioned in the module page.
4. Final step - Edit the magic mirror config.js file and add the entry as mentioned in the respective module page.
For example,
{
module: 'MMM-Carousel',
position: 'bottom_bar', // Required only for navigation controls
config: {
transitionInterval: 10000,
ignoreModules: ['clock', 'alert'],
mode: 'slides',
showPageIndicators: true,
showPageControls: true,
slides: {
main: ['calendar', 'compliments', 'currentweather'],
"Slide 2": ['weatherforecast', 'MMM-Trello', 'planetrise', 'newsfeed'],
"Slide 3": ['MMM-fitbit']
},
keyBindings: {
enabled: true,
map: {
NextSlide: "ArrowRight",
PrevSlide: "ArrowLeft",
Slide0: "Home"
},
mode: "DEFAULT"
}
}
}
NOTE: Please take care of comma (,) after the curly brackets.
How to upgrade node js in raspberry pi?
$ node -v
v10.12.0
$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
$ sudo apt install nodejs
$ node -v
v12.10.0
How to install Respeaker in raspberry pi?
Step 1. Please Make sure running the lastest Raspbian Operating System(debian 9) on Pi. (updated at 2018.11.13)
Step 2. Get the seeed voice card source code.
sudo apt-get update
sudo apt-get upgrade
git clone https://github.com/respeaker/seeed-voicecard.git
cd seeed-voicecard sudo ./install.sh reboot
Step 3. Then select the headphone jack on Raspberry Pi for audio output:
sudo raspi-config
# Select 7 Advanced Options
# Select A4 Audio
# Select 1 Force 3.5mm ('headphone') jack
# Select Finish
Step 4. Check that the sound card name looks like this:
pi@raspberrypi:~ $ arecord -L
If we want to change the alsa settings, we can use sudo alsactl --file=ac108_asound.state store to save it. And when we need to use the settings again, copy it to: sudo cp ~/seeed-voicecard/ac108_asound.state /var/lib/alsa/asound.state
Step 5. Open Audacity and select AC108 & 4 channels as input and bcm2835 alsa: - (hw:0:0)as output to test:
$ sudo apt update
$ sudo apt install audacity
$ audacity // run audacity
Step 6. Or we could record with arecord and play with aplay:
// only support 4 channels
arecord -Dac108 -f S32_LE -r 16000 -c 4 hello.wav
// make sure default device // Audio will come out via audio jack of Raspberry Pi
aplay hello.wav
------------------------------------------------------------------------------------
References
http://wiki.seeedstudio.com/ReSpeaker_4_Mic_Array_for_Raspberry_Pi/
How to use a standard USB webcam
Install fswebcam
First, install the fswebcam package:
sudo apt-get install fswebcam
Add your user to video group
If you are not using the default pi user account, you need to add your username to the video group, otherwise you will see 'permission denied' errors.
sudo usermod -a -G video
To check that the user has been added to the group correctly, use the groupscommand.
Basic usage
Enter the command fswebcam followed by a filename and a picture will be taken using the webcam, and saved to the filename specified:
fswebcam image.jpg
Specify resolution
The webcam used in this example has a resolution of 1280 x 720 so to specify the resolution I want the image to be taken at, use the -r flag:
fswebcam -r 1280x720 image2.jpg
Specify no banner
Now add the --no-banner flag:
fswebcam -r 1280x720 --no-banner image3.jpg
Bash script
You can write a Bash script which takes a picture with the webcam. The script below saves the images in the /home/pi/webcam directory, so create the webcam subdirectory first with:
mkdir webcam
To create a script, open up your editor of choice and write the following example code:
#!/bin/bash
DATE=$(date +"%Y-%m-%d_%H%M")
fswebcam -r 1280x720 --no-banner /home/pi/webcam/$DATE.jpg
This script will take a picture and name the file with a timestamp. Say we saved it as webcam.sh, we would first make the file executable:
chmod +x webcam.sh
Then run with:
./webcam.sh
----------------------------------------------------------------------------------
References
https://www.raspberrypi.org/documentation/usage/webcams/
How to video stream using Raspberry pi camera
References
https://randomnerdtutorials.com/video-streaming-with-raspberry-pi-camera/
How to install Python 3.7 on Raspberry Pi?
https://www.ramoonus.nl/2018/06/30/installing-python-3-7-on-raspberry-pi/
https://samx18.io/blog/2018/09/05/python3_raspberrypi.html