![]() If not, you can install it from the VS Code downloads page.įrom inside VS Code, you will need to install the Remote SSH extension. Once the Raspberry Pi is set up, you can connect from VS Code on your Mac or PC.įirst make sure you have VS Code installed. If you don’t know how to do this, it is also covered in the Raspberry Pi documentation. You also need to know either the IP address of the Raspberry Pi, or its hostname. The Raspberry Pi documentation has a great article on setting up a headless Raspberry Pi if you don’t already know how to do this. Set up remote development on Raspberry Piįor remote development, your Raspberry Pi needs to be connected to your network either by ethernet or WiFi, and have SSH enabled. It is not supported on older Raspberry Pis, or on Raspberry Pi Zero. I can access the Raspberry Pi file system, run commands on a terminal connected to it, access whatever hardware my Raspberry Pi has, and debug on it. When you are debugging, the debug session runs on the remote device, but VS Code runs on the host machine.įor example – I can run VS Code on my MacBook Pro, and connect remotely to a Raspberry Pi 4 that is running headless. You see the remote file system, the VS Code terminal runs on the remote device, and you access the remote device’s hardware. ![]() This extension allows you to connect to a remote device over SSH, and run VS Code as if you were running on that remote device. ![]() One of the extensions that helps here is the Remote SSH extension, part of a pack of remote development extensions. You can run VS Code on Windows, macOS, and of course on a Raspberry Pi. I practically live day to day in VS Code: whether I’m writing blog posts, documentation or Python code, or programming microcontrollers, it’s my work ‘home’. There is a better way – using Visual Studio Code remote development! Visual Studio Code, or VS Code, is a free, open source, developer’s text editor with a whole swathe of extensions to support you coding in multiple languages, and provide tools to support your development. The downside is programming and debugging it – do you plug your Raspberry Pi into a monitor and run the full Raspberry Pi OS desktop, or do you use Raspberry Pi OS Lite and try to program and debug over SSH using the command line? Or is there a better way? Remote development with VS Code to the rescue The upside of headless is that my Raspberry Pi can be anywhere, not tied to a monitor, keyboard and mouse. Like a lot of Raspberry Pi users, I like to run my Raspberry Pi as a ‘headless’ device to control various electronics – such as a busy light to let my family know I’m in meetings, or my IoT powered ugly sweater. Need Help? Open a discussion thread on GitHub.Jim Bennett from Microsoft, who showed you all how to get Visual Studio Code up and running on Raspberry Pi last week, is back to explain how to use VS Code for remote development on a headless Raspberry Pi. ![]() And you should now be connected to Raspberry Pi and able to develop on it remotely. Youl will be prompted for password again. You will get a dropdown, navigate to the folder you want to open and then press OK. Open the explorer on VSCode and you should see the following message. Once you're connected you should see the SSH: raspberrypi on bottom left part of your VSCode. This will setup the VSCode Remote Server on the Raspberry PI. You will be prompted for password for your user on Raspberry Pi, enter the password. Then, open the Command Palette again by typing Ctrl Shift P, and search for Remote-SSH: Connect to a Host again. ![]() When prompted to select SSH configuration file to update, choose the one under C:\Users\YourName\.ssh\config. Then in the prompt type ssh assuming you username is pi and the hostname of your Raspberry Pi is raspberrypi. Then open the command Palette by pressing Ctrl Shift P, search for Remote-SSH: Connect to a Host then click on " Add New SSH Host.". Add Raspberry Pi as recognised hostsįire up your VSCode and first search and install the Microsoft provided official Remote - SSH extension. So the compromise is, you can simply use VSCode on your PC and use VSCOde to SSH in to the Raspberry PI and develop remotely. But for a VSCode fan such as me, that's not an acceptable option specially because I don't want to reconfigure all of my preferences. You could use VIM, but then you need to login to your Raspberry Pi using either VNC Viewer, or SSH into Raspberry Pi using some form of terminal. Raspberry Pi is of course lightweight, and consumes very little power but that also makes it quite unsuitable for developing anything small apps and running lightweight code editors such as Geany, Thonny etc. So you got yourself a Raspberry Pi and want to develop something on it. By Rehan Haider, Sat 16 October 2021 Category: Snippets ![]()
0 Comments
Leave a Reply. |