I am trying to use VNC in a headless install on my Raspberry Pi 4, running Raspberry Pi OS, installed via Raspberry Imager. The install is more or less vanilla, as the only changes I have made are for connecting (seting up SSH, wireless and VNC as noted in this guide: https://www.tomshardware.com/reviews/raspberry-pi-headless-setup-how-to,6028.html).
When I log in via VNC I get the "Cannot Currently Show the Desktop"-error. It should be possible to fix by changing the screen resolution via raspi-config, but that makes the pi unresponsive. Setting the pi to use "G3 legacy" should fix that issue either after a reboot or without (answers vary on that), but it doesn't seem to make a difference in either case.
Does anyone know how I can get to connect via VNC to my pi?
Thanks :)
According to the documentation:
If your Raspberry Pi is headless (i.e. not plugged into a monitor) or
controlling a robot, it is unlikely to be running a graphical desktop.
So the idea is to create a new virtual desktop via vncserver command and use the display number in VNC.
Basically should be sufficient to specify a HDMI mode. I have a Raspberry Pi4 headless, this is my configuration in /boot/config.txt
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=1
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720
# uncomment if hdmi display is not detected and composite is being output
hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (this will force VGA)
hdmi_group=2
hdmi_mode=82
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4
# uncomment for composite PAL
#sdtv_mode=2
#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800
# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18
# Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
[all]
#dtoverlay=vc4-fkms-v3d
gpu_mem=128
start_x=1
enable_uart=1
#hdmi_enable_4kp60=1
Then I disabled encryption and set a VNC password. In addition, if you to see the raspistill/raspivid preview through VNC you have to enable this: RealVNC Viewer > Menu > Options > Troubleshooting > Optimize screen capture - select 'Enable direct capture mode'
Raspbian Buster:
Launch command line and run:
sudo raspi-config
Display options -> Resolution. Then select a resolution mode, I recommend select 1280x720 but you can also choose the higher resolution (1920x1080). Save and finish.
Reboot and connect to raspberry again through VNC client.
Raspbian Bullseye:
Launch command line and run:
sudo raspi-config
Display options -> VNC Resolution. Then select a resolution mode, I recommend select 1280x720 but you can also choose the higher resolution (1920x1080). Save and finish.
Reboot and connect to raspberry again through VNC client.
This solved the problem for me: https://www.shellhacks.com/raspberry-pi-force-hdmi-hotplug/.
TL;DR
Setting the resolution of VNC in Raspberry Pi (RPi):
/usr/bin/xrandr --fb 1920x1080
Long answer
One can examine the code of raspi-config bash script, here
Look for the do_vnc_resolution function.
My Rpi4 Bullseye machine had set itself into safe mode … in /boot/config.txt the line
hdmi_safe=1
Was uncommented.
Commenting it out fixed my lo-resolution VNC display problem
Then had to reboot, then logout, and login for everything to be set ok
Related
I have been trying to get my raspberry pi camera to work for a while now. Probably every 2 weeks or so I would fire up the raspberry pi to convince myself that something changed but whatever I try, libcamera-hello or libcamera-still always produces the same error:
ERROR RPI raspberrypi.cpp:1812 Unicam has timed out!
ERROR RPI raspberrypi.cpp:1813 Please check that your camera sensor connector is attached securedly.
ERROR RPI raspberrypi.cpp:1814 Alternatively, try another cable and/or sensor.
I have tested this on 2 Raspberry Pi 4 model Bs, 2 Cameras(the UC-873 and the UC291), 3 different cables, but only one SD card. I am using an official raspberry pi power supply. I have tried both Buster and the newest version of Bullseye hoping that it would be the software that is causing the problem. For some reason on my newest camera, the UC-783, instead of the Unicam error, it just says that there are no cameras detected and the code:
vcgencmd get_camera
results with
supported=1 detected=0
My config file looks like this:
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720
# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4
# uncomment for composite PAL
#sdtv_mode=2
#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18
# Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
# Automatically load overlays for detected cameras
camera_auto_detect=1
# Automatically load overlays for detected DSI displays
display_auto_detect=1
# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2
# Disable compensation for displays with overscan
disable_overscan=1
[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1
[all]
[pi4]
# Run as fast as firmware / board allows
arm_boost=1
[all]
gpu_mem=124
I feel like I have tried every possible solution. Could it be an option that I somehow damaged both cameras or all cables? I have made sure not to switch out a camera when the raspberry pi was on so the only way I think I could have done something is by static electricity.
Any suggestions?
Audio output to both Pulseaudio and HDMI?
On my boat the raspberry pi 3 B+ Buster, is used in two ways:
it runs Kodi to play music that outputs via bluetooth to a car radio that outputs to speakers. (it took two days of work to get that to happen finally found https://peppe8o.com/fixed-connect-bluetooth-headphones-with-your-raspberry-pi/)
it also plays movies that output to an HDMI projector with speakers.
The Pi boots up into LXDE which runs a bash script to connect (and to keep trying to connect as per BluManCZ's answer in https://unix.stackexchange.com/questions/334386/how-to-set-up-automatic-connection-of-bluetooth-headset) to the radio by bluetooth and then autostarts Kodi.
The music is controlled by an Android Yatse app.
When I want to play a movie, I stop the music playing with the Yatse app and then turn on the projector and use a wireless keyboard to play a movie. But I have to manually go to Kodi system settings and select HDMI as the sound ouput.
When I finish the movie, I power off the Pi correctly. But if I forget to first go and manually put the sound output back to Pulseaudio within Kodi then when I next boot it up, and expect to get music, I hear nothing, as it is still going to HDMI. So then I have to go and turn on the projector so I can use the keyboard to switch it back over to pulseaudio.
So, is there some way I can get it to either output to BOTH pulseaudio (bluetooth) AND HDMI so that whichever device is switched on (radio or projector) I get sound out?
Or can I have it automatically detect which one is active and output to that?
How do I get it so that I can seamlessly switch from playing music through the bluetooth to playing videos through the projector?
Bear in mind that when I power up the Pi either one, or other, or both the radio and projector might be powered on at that time.
Ok, I solved it, I think, using the following steps. This asumes that bluetooth output to the a2dp speakers works (see the steps I took for that in the original question):
Install paprefs:
$ sudo apt install paprefs
Then run it on the desktop using Terminal:
$ paprefs
This brings up a GUI window with several tabs. Select the 'Simultaneour Out Put' tab which offers one checkbox to enable or disable the feature. Turn it on.
Then restart pulseaudio
$ killall pulseaudio
Now you can go to VLC and select the audio tab to send the output to Simultaneous output. The sound will go to both. Unfortunately when you shut down VLC it goes back to HDMI and you have to manually change it again. Also in Kodi it does not appear as an option.
So, a few more steps:
Edit the default configuration for pulseaudio
$ sudo nano /etc/pulse/default.pa
and add the following line at the beginning, before any other modules are loaded:
load-module module-combine-sink sink_name=combined
This sets up a new virtual device that outputs to all the others.
While you are there, make sure that this line is also in there, somewhere (probably farther down)
module-default-device-restore
This will revert back the the default device if something changes in the system (eg HDMI is turned off or on).
Exit nano and save the file by doign ctrl-x and saying yes to the prompts.
List the available devices known to pulseaudio:
$ pacmd list-sinks | grep -e 'name:' -e 'index:'
This should now list the bluetooth, jack, HDMI and also combined devices. The one with the asterix is the current fall-back device. You want to make this the 'combined' sink. To do that:
$ sudo pacmd set-default-sink combined
$ sudo reboot 0
Check again, and this time the combined should have the asterix next to it:
$ pacmd list-sinks | grep -e 'name:' -e 'index:'
Now when you play VLC or Kodi the sound should go to both HDMI and Bluetooth.
This seems to survive a full shutdown and power up, so I think it achieves the goal. I have not yet tried all the different combinations of starting with the different output devices on or off, But I am hopefull that it works.
I'm not able to enable the Raspberry Pi's VNC capture mode from the command line.
ExperimentalRaspiCapture mode allows you to remotely view videos running.
If not enabled, you cannot watch videos. As my application has disabled the raspbian graphical mode, I only have operations from the command line and I do not have access to the internet on them, only local network.
I did tests on an alternative raspberry and in graphical mode I enabled this option according to the tutorial on page vncserver experimental direct capture mode missing and it worked for me, but I have several raspberries and enabling it by command line is my best option at the moment, but I can't enable it.
I already tried the tutorial on the page:
How do I get VNC access to Kano OS working correctly?
But it did not work.
Any idea? Has anyone managed to do this?
Thanks.
Use vnc version: VNC (R) Server 6.2.1 (r32538) ARMv6
I use the raspberry:
*Linux raspberrypi 4.14.34-v7 *
I found the problem. I wasn't doing it right. I have to change the file in the root user and then restart the serviced. ;)
Edit the config file '/root/.vnc/config.d/vncserver-x11'
adding the following:
CaptureTech=raspi
ExperimentalRaspiCapture=1
ServerPreferredEncoding=JPEG
and then restarted:
sudo systemctl restart vncserver-x11-serviced
There is a demo which comes with UV4L demo OS for Raspberry PI, https://raspberry:8080/stream/webrtc. When i run it on a macOS computer (Firefox browser), and select that a screen is to be shared, it always says 'no suitable video device found!' and apparently doesn't connect anywhere. Same happens when i go there on a Chromium browser on a Raspberry PI itself. There doesn't seem to be any error messages anywhere - some deprecation warnings but no more than that:
onopen() webrtc:197:25
navigator.mozGetUserMedia has been replaced by navigator.mediaDevices.getUserMedia webrtc:251:32
WebRTC interfaces with the “moz” prefix (mozRTCPeerConnection, mozRTCSessionDescription, mozRTCIceCandidate) have been deprecated. webrtc:105:25
{"iceServers":[{"urls":["stun:stun.l.google.com:19302","stun:192.168.0.101:3478"]}]} webrtc:104:21
onaddstream is deprecated! Use peerConnection.ontrack instead. webrtc:107
peer connection successfully created! webrtc:110:21
URL.createObjectURL(MediaStream) is deprecated and will be removed soon. webrtc:255:60
call(), request={"what":"call","options":{"force_hw_vcodec":false,"vformat":"60"}} webrtc:193:25
message =message webrtc:281:25
Where shall i look into?
Clarification: i can see my desktop in a 'local' box, so sharing has been successful, same on Raspberry PI. But it never goes to the other side, i can't even use the data channel - it is greyed out - so apparently no connection happens, at all.
The following command runs an instance of UV4L that allows to mirror your desktop or window to the Raspberry Pi HDMI display. Note that you must pass the SSL certificates .key and .crt (see the UV4L installation instructions to know how to generate them):
uv4l --enable-server --driver dummy --server-option '--use-ssl=yes' --server-option '--ssl-private-key-file=/home/pi/selfsign.key' --server-option '--ssl-certificate-file=/home/pi/selfsign.crt' --verbosity=7 --server-option '--enable-webrtc-video=no' --server-option '--enable-webrtc-audio=no' --server-option '--webrtc-receive-video=yes' --server-option '--webrtc-renderer-fullscreen=yes' --server-option=--webrtc-renderer-window=0 0 1920 1080 --server-option '--webrtc-receive-datachannels=yes' --server-option '--webrtc-receive-audio=yes' --auto-video_nr --server-option '--webrtc-receive-audio=yes --server-option '--port=9000'
You can then access the WebRTC streaming page at:
https://raspberry:9000/stream/webrtc
You must explicitly enable screen sharing in firefox or chrome according to the instructions written in the the same page.
I would check if the camera module on the pi itself is attached correctly. Did you try to capture a test image using something likeraspistill -o test.jpg yet? I've seen the 'No Suitable devices found' problem come up when I either didn't enable the camera on raspi-config or I didn't insert the camera's ribbon cable correctly. You can also check if you've connected the GPIO corresponding pins right.
I have a Logitech QuickCam 9000 Pro (V-UBM46) and I cannot control the focus from my RaspberryPi (all packages up to date).
When I list the available webcam controls with uvcdynctrl
uvcdynctrl -d /dev/video0 -c
Listing available controls for device /dev/video0:
Brightness
Contrast
Saturation
White Balance Temperature, Auto
Gain
Power Line Frequency
White Balance Temperature
Sharpness
Backlight Compensation
Exposure, Auto
Exposure (Absolute)
Exposure, Auto Priority
the focus control is missing. However, when I run the same command on my Ubuntu 13.04 machine, the focus command is present and I can use it.
uvcdynctrl -d /dev/video1 -c
[libwebcam] Unknown V4L2 private control ID encountered: 0x0A046D04 (V4L2_CID_PRIVATE_BASE + 33844484)
Listing available controls for device /dev/video1:
Brightness
Contrast
Saturation
White Balance Temperature, Auto
Gain
Power Line Frequency
White Balance Temperature
Sharpness
Backlight Compensation
Exposure, Auto
Exposure (Absolute)
Exposure, Auto Priority
Focus
Focus (absolute)
LED1 Mode
LED1 Frequency
Disable video processing
Raw bits per pixel
I have checked the versions for libwebcam0, uvcdynctrl, uvcdynctrl-data, libv4l-0 and they are all up to date to the same version on both the RaspberryPi and Ubuntu. The only difference is libv4l-0 where the version on Ubuntu is 0.8.9-4 and the RaspberryPi is 1.0.0-1.
Is there perhaps another package or driver that is missing or outdated on the RaspberryPi? How do I get the Raspbian to "see" the focus control?
I have the RaspberryPi Model B running Octopi on it.
I figured out an easy solution for our problem. It works flawlessly for my Pi.
Hope it works on yours too.
sudo apt-get install uvcdynctrl
sudo apt-get install guvcview
sudo guvcview
unplug and replug the webcam
After this four steps uvcdynctrl -c shows Focus, Led and more options available.