{"id":18351248,"url":"https://github.com/driedler/rpi0w_dev_env","last_synced_at":"2025-10-30T17:31:22.054Z","repository":{"id":152440152,"uuid":"375542101","full_name":"driedler/rpi0w_dev_env","owner":"driedler","description":"Raspberry Pi Zero W VSCode Python Development Environment","archived":false,"fork":false,"pushed_at":"2021-06-29T03:42:16.000Z","size":13,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-23T20:17:44.802Z","etag":null,"topics":["debug","debugging","debugging-tool","python","raspberry-pi","raspberry-pi-zero","raspberry-pi-zero-w","raspberrypi","visual-studio-code","vscode"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/driedler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-10T02:08:53.000Z","updated_at":"2024-09-22T07:11:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"d300bde1-7ed1-4445-871e-56b79ccb42c1","html_url":"https://github.com/driedler/rpi0w_dev_env","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driedler%2Frpi0w_dev_env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driedler%2Frpi0w_dev_env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driedler%2Frpi0w_dev_env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driedler%2Frpi0w_dev_env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/driedler","download_url":"https://codeload.github.com/driedler/rpi0w_dev_env/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239015511,"owners_count":19568274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debug","debugging","debugging-tool","python","raspberry-pi","raspberry-pi-zero","raspberry-pi-zero-w","raspberrypi","visual-studio-code","vscode"],"created_at":"2024-11-05T21:30:00.358Z","updated_at":"2025-10-30T17:31:21.655Z","avatar_url":"https://github.com/driedler.png","language":"Python","readme":"Raspberry Pi Zero W Python Development Environment\n===========================================\n\nThis project describes how to setup a Raspberry Pi Zero W for remote Python development using VSCode.  \nOnce setup, you can develop and single-step debug Python scripts from your local PC and execute on a remote Raspberry Pi Zero W.\n\nThe following was adapted from:\nhttps://bitbucket.org/jIRI/rasp-pi-zerow-vscode/src/master/\n\n__NOTE:__ See [rpi0_tflite_picamera](https://github.com/driedler/rpi0_tflite_picamera) which is provides a more realistic dev environment.\n\n# Hardware \n\nThis assumes you have a Raspberry Pi Zero W (W = built-in wifi/bluetooth support).\nThere a tons of dev kits available, e.g.:\nhttps://www.canakit.com/raspberry-pi-zero-wireless.html?src=raspberrypi\n\n__NOTE:__ You need a micro SD card, the RPI board-only doesn't have onboard ROM to store the OS.\n\n__NOTE:__ You might also need a micro SD reader if you computer doesn't have one. e.g.:  \nhttps://www.amazon.com/s?k=usb+micro+sd+card+reader\n\n\n# Raspbery Pi Setup\n\n## 1) Program Raspberry Pi OS to SD Card \n\nPlug the SD card in your computer's SD card reader, then  \nuse the Raspberry PI Imager to program RPI OS to your micro SD card:  \nhttps://www.raspberrypi.org/software/\n\nIt's recommended to start with the default OS (with desktop support) before getting crazy with RPI OS-lite.\n\n## 2) Enable network over USB\n\nAfter programming RPI OS from setup 1, unplug the SD card, then plugin it back into your computer.\nGo to your file explorer, you should see the SD card be mounted as a new drive (at least on Windows)\nwith a description as: `boot`.\n\nOpen the SD card 'boot' drive and edit the following files in the root of the SD card:\n\n__config.txt:__  \nOpen `config.txt` and to the end add:\n```\ndtoverlay=dwc2\n```\nMore details about config.txt here:  \nhttps://www.raspberrypi.org/documentation/configuration/config-txt/\n\n__cmdline.txt:__  \nOpen `cmdline.txt`, just after `rootwait` add:\n```\nmodules-load=dwc2,g_ether\n```\n\n__ssh__   \nCreate empty file named `ssh` in root of the SD card\n\n## 3) Install mDNS onto your computer\n\nIf you're using Windows, install:\nhttps://support.apple.com/kb/DL999?viewlocale=en_US\u0026locale=en_US\n\nIf you're using Linux, install:\n```\nsudo apt-get install avahi-daemon\n```\n\n## 4) Start the Raspberry Pi Zero W\n\nUnmount the SD card an plug it into the RPI.\nThen plug the USB micro into the RPI's `USB` port (_not_ PWR) and the other side into your computer.\n\n## 5) Configure sharing on your Windows network adapter so Pi can see the Internet\nGo somewhere around __Control Panel -\u003e Network and Internet -\u003e Network Connections__  \nDouble click your default network connection, click Properties..., tab Sharing\n\n## 6) Open an SSH session to the RPI\n\nOn Windows, PuTTY is recommended: http://www.putty.org/\n\nConnect over SSH (port 22) with connection string: `pi@raspberrypi.local`   \nAccept certificate  \nDefault password is `raspberry`\n\n## 7) Configure Wi-Fi\n\nFrom the SSH session, issue the command:\n\n```\nsudo nano /etc/wpa_supplicant/wpa_supplicant.conf\n```\nFrom the opened file editor, add the following to the end:\n\n```\nnetwork={\n  ssid=\"MY_NETWORK_NAME\"\n  psk=\"MY_NETWORK_PASSWORD\"\n}\n```\nUpdating `MY_NETWORK_NAME` and `MY_NETWORK_PASSWORD` with your Wi-Fi info.\n\nThen, `Ctrl+O` to save, `Ctrl+X` to exit nano.\n\nNext, issue the command:\n\n```\nsudo wpa_cli reconfigure\n```\n\nThen issue the command:\n\n```\nsudo reboot\n```\n\nThis will reboot the RPI and close your SSH session. \nYou'll need to start a new SSH session for the subsequent steps.\n\n\n## 8) Create the workspace directory \n\nFrom the RPI SSH session (step 7), issue the command:\n\n```\nmkdir workspace\nchmod 0777 workspace\ncd workspace\npwd\n```\n\nWhich should create the directory:\n\n```\n/home/pi/workspace\n```\n\n## 9) Update Pi, install samba, config samba\n\nFrom the RPI SSH session (step 7), issue the commands:\n\n```\nsudo apt-get update\nsudo apt-get install -y samba samba-common-bin\n```\n\nThen issue:\n\n```\nsudo nano /etc/samba/smb.conf\n```\nAdd to the end of file:\n```\n[workspace]\npath=/home/pi/workspace\nbrowsable=yes\nwritable=yes\nonly guest=no\ncreate mask=0777\ndirectory mask=0777\npublic=yes\n```\n\nThen issue:\n```\nsudo service smbd restart\n```\n\nIn your local file explorer, you should be able to open (on Windows):\n```\n\\\\RASPBERRYPI\\workspace\n```\n\n\n## 10) Install debugpy on the Pi to be able debug remotely\n\nWe use [debugpy](https://github.com/microsoft/debugpy) to enable Python remote debugging.\n\nFrom the RPI SSH session (step 7), issue the command:\n\n```\nsudo pip3 install debugpy==1.3.0\n```\n(You may be able to use a newer version, but that version worked for me)\n\n__NOTE:__ This repo uses Python3, hence `pip3`.\n\n## 12) Resize your Pi partition to use all available space on SD card\n\nFrom the RPI SSH session (step 7), issue the commands:\n```\nsudo raspi-config --expand-rootfs\nsudo reboot\n```\n\n# Prepare VSCode Workspace\n\n## 1) Install the dirsync Python package\n\n\nWe use the [dirsync](https://pypi.org/project/dirsync/) Python package\nto automatically synchronize files between the local workspace and the remote RPI workspace.\n\nIssue the following command from a local terminal to install the package:\n\n```\npip3 install dirsync\n```\n\nAfter installing, the `dirsync` command should be accessbile to VSCode.\n\n## 2) Open VSCode Workspace\n\nAssuming you cloned this repo, open the VSCode 'workspace' that is at the root of this repo: `workspace.code-workspace` \nthen install the 'Recommended Extensions'.\n\n## 3) Map Network Drive\n\nIf using Windows, map the `\\\\RASPBERRYPI\\workspace` network drive, more details [here](https://support.microsoft.com/en-us/windows/map-a-network-drive-in-windows-10-29ce55d1-34e3-a7e2-4801-131475f9557d)  \nAfter this is complete, you should have a new drive, e.g. `Z:\\\\` that points to your RPI's `/home/pi/workspace` directory.\n\nThis is required so we can easily sync the local workspace with the RPI's workspace.\n\n## 4) Update tasks.json\n\nOpen `\u003crepo root\u003e/.vscode/tasks.json`,\n\nIn the `sync-workspace` task, update the arguments as necessary for your workspace.  \nAt a minimum, you may need to change `z:/` to your networking mapping drive from the previous step.\n\n# Run the debugger\n\nThat's it! Running the `Debug Python` debug configuration should:\n1. Synchronize the local workspace with the RPI's workspace (assuming the network drive is properly mapped)\n2. Start the `main.py` python script with remote debugging enabled\n3. Cause VSCode to connect to the debug server and allow for single-stepping in the Python script as if it were running locally\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdriedler%2Frpi0w_dev_env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdriedler%2Frpi0w_dev_env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdriedler%2Frpi0w_dev_env/lists"}