{"id":1661,"date":"2026-09-15T07:53:29","date_gmt":"2026-09-15T07:53:29","guid":{"rendered":"https:\/\/aadhuniklabs.com\/casp-blog\/?p=1661"},"modified":"2026-09-15T08:49:28","modified_gmt":"2026-09-15T08:49:28","slug":"access-raspberry-pi-pico2-pins-from-python-through-serial","status":"publish","type":"post","link":"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/","title":{"rendered":"Access Raspberry Pi Pico2 Pins From Standard Python Through Serial"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">CASP supports accessing micro-controller pins from a standard Python script on host computer through low latency serial or WiFi communication. This feature allows the micro-controller pins to be visualized as if they were part of the host computer. This example shows how to easily access Raspberry Pi Pico2 pins from a Python script on host computer through serial communication. It also shows how to plot and control the data from a GUI based control panel invoked from a Python script.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Python code in this example implements following logic<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">Display ADC (pin-GP26) and digital input pin (pin-GP2) values<\/li>\n\n\n\n<li class=\"\">Blink on-board LED<\/li>\n\n\n\n<li class=\"\">Toggle digital output pin-GP6 value<\/li>\n\n\n\n<li class=\"\">Vary PWM on pin-GP16<\/li>\n\n\n\n<li class=\"\">Vary Servo angle on pin-GP10<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Pre-Requisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">Raspberry Pi Pico2 board.<\/li>\n\n\n\n<li class=\"\">Compatible USB cable.<\/li>\n\n\n\n<li class=\"\">CASP software along with Raspberry Pi Pico BSP is installed. From CASP GUI install CASP Python libraries. Please refer this <a href=\"https:\/\/aadhuniklabs.com\/casp-blog\/category\/getting-started\/installing-updating\/\">page <\/a>for details.<\/li>\n\n\n\n<li class=\"\">Download the project zip file from this <a href=\"https:\/\/aadhuniklabs.com\/casp\/casp_web_examples\/casp_rgpio_examples\/rgpio_pico2_serial.zip\">link<\/a> and extract the downloaded file. The Python files are located in the &#8216;python&#8217; folder of the extracted directory.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Procedure<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">Connect Raspberry Pi Pico2 board to the host computer through a serial cable.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" width=\"1002\" height=\"431\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/circuit_rpi_pico2.jpg?fit=1002%2C431&amp;ssl=1\" alt=\"\" class=\"wp-image-1667\" style=\"aspect-ratio:1.9727219055950562;width:905px;height:auto\" srcset=\"https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/circuit_rpi_pico2.jpg?w=1002&amp;ssl=1 1002w, https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/circuit_rpi_pico2.jpg?resize=150%2C64&amp;ssl=1 150w, https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/circuit_rpi_pico2.jpg?resize=300%2C129&amp;ssl=1 300w, https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/circuit_rpi_pico2.jpg?resize=767%2C330&amp;ssl=1 767w, https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/circuit_rpi_pico2.jpg?resize=1000%2C430&amp;ssl=1 1000w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p class=\"wp-block-paragraph\"><strong>Flashing Raspberry Pi Pico2 with the binary file<\/strong>: In the extracted project directory, open terminal or command prompt in the &#8216;python&#8217; folder and type the following command twice (without and with serial port as argument).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#first type the below command to display available serial ports in which Raspberry Pi Pico2 serial port is one of them\npython(or python3) rgpio_flasher.py\n#now repeat the above command with serial port (to which the board is connected) as an argument\npython(or python3) rgpio_flasher.py \"COM3\"\n#the above command should program Raspberry Pi Pico2 board with the hex file supporting python communication<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once the board is programmed, disconnect the USB cable. Connect suitable peripherals such as LDR or IR distance sensor to pin-GP26, limit switch to pin-GP2, external LED or relay module to pin-GP6, DC motor driver module to pin-GP16, servo to pin-GP10 etc. of Raspberry Pi Pico2 and re-connect the USB cable to the board.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Run the basic Python script file<\/strong>: Open &#8216;rgpio_from_pc.py&#8217; in a text editor. Locate text &#8220;COM62&#8221; and replace it with the actual serial port to which Raspberry Pi Pico2 board is connected. Save and close the file. Run terminal or command prompt in \u2018python\u2019 folder. Type python or python3 with \u2018rgpio_from_pc.py\u2019 as argument and press Enter key. The Python code should start communicating with the board and execute the implemented logic. Python script from &#8216;rgpio_from_pc.py&#8217; file is shown below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># This example demonstrates how to use CASP Remote GPIO from Python script that runs on host computer. Ensure matching target's casp_pins.py file in present in the script folder before running.\n\nimport sys\nimport time\n\n#modify this path to point to 'casp_user_data\/pycasp' directory in your system\n#sys.path.append(\"C:\/Users\/AL\/Documents\/casp_user_data\/pycasp\/src\")\n\nimport casp_rgpio as rgpio\nimport casp_pins as pins\n\n#initialize GPIO instance\nrgpio.Init()\n\n#displays available serial ports\n#rgpio.SerialPorts()\n\n#establish communication with the board. loop till the connection is established\n#modify serial port (\"COM62\") to which the target is connected on your system.\n#to know about available serial ports, use above commented command.\nconnected: bool = False\nwhile connected == False:\n    connected = rgpio.ConnectSerial(\"COM37\", 115200, True, 1, 24, 24) #port, baud, enable_dtr, delay_msec, read_bytes, write_bytes\n    time.sleep(5)\n\n#run a for loop to blink on-board LED, read ADC value and control pwm and servo every one second\npwm_val = 0\nservo_val = -90\nfor i in range(1000):\n    di = rgpio.ReadDigital(pins.GP2_DI)\n    adc = rgpio.ReadAnalog(pins.GP26)\n    print(f\"di={di}, adc={adc}\")\n    #\n    rgpio.WriteDigital(pins.GP_LED_DO, (i % 2)) #blink logic\n    rgpio.WriteDigital(pins.GP6_DO, (i % 2))\n    #\n    pwm_val += 50\n    if pwm_val &gt; 4095:\n        pwm_val = 0\n    rgpio.WriteAnalog(pins.GP16, pwm_val) #pwm control\n    #\n    servo_val += 10\n    if servo_val &gt; 90:\n        servo_val = -90\n    rgpio.WriteAnalog(pins.GP10_SERVO, servo_val) #servo control\n    #\n    time.sleep(1)\n\n#close CASP GPIO instance\nrgpio.Close()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The contents of &#8216;casp_pins.py&#8217; file referred in above code is shown below<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"\"\"! Python module for GPIO pins from pin source: rgpio_rpi_pico_pico2_serial.pins\nTarget details:\n Name: RaspberryPiPico\n Read size (bytes): 24\n Write size (bytes): 24\n Communication type: serial\n Serial port: set during runtime\n Serial baud: 115200\n Serial flow control (0-none, 1-dtr, 2-hardware, 3-software): 0\n IP address: set during runtime\n IP port: 0\n\"\"\"\n\n#Pin details:\nGP0_DI = 0 #DI0\nGP1_DI = 1 #DI0\nGP2_DI = 2 #DI0\nGP3_DI = 3 #DI0\nGP4_DI = 4 #DI0\nGP5_DI = 5 #DI0\nGP6_DO = 0 #DO0\nGP7_DO = 1 #DO0\nGP8_DO = 2 #DO0\nGP9_DO = 3 #DO0\nGP_LED_DO = 4 #DO0\nGP26 = 1 #ADC\nGP27 = 3 #ADC\nGP28 = 5 #ADC\nTEMP = 7 #ADC\nGP16 = 1 #PWM\nGP17 = 3 #PWM\nGP18 = 5 #PWM\nGP19 = 7 #PWM\nGP20 = 9 #PWM\nGP21 = 11 #PWM\nGP22 = 13 #PWM\nGP10_SERVO = 15 #PWM\nGP11_SERVO = 17 #PWM\nGP12_SERVO = 19 #PWM\nGP13_SERVO = 21 #PWM\nGP14_SERVO = 23 #PWM<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Run advanced Python script file that shows a GUI panel for plotting and control<\/strong>: Open &#8216;rgpio_from_pc_plot.py&#8217; in a text editor. Locate text &#8220;COM62&#8221; and replace it with the actual serial port to which Raspberry Pi Pico2 board is connected. Save and close the file. Run terminal or command prompt in \u2018python\u2019 folder.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">Run GUI Panel Server: Type python or python3 with &#8216;rgpio_plot_n_control_server.py&#8217; as argument and press Enter key. This will start GUI panel server.<\/li>\n\n\n\n<li class=\"\">Run the Python script: Type python or python3 with &#8216;rgpio_from_pc_plot.py&#8217; as argument and press Enter key. The Python code should start communicating with the board and execute the implemented logic. Output control panel displaying pin values from Raspberry Pi Pico2 board is shown below. You can control LED, DO, PWM and servo from the panel UI.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"959\" height=\"484\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/plot_control_panel-1.png?fit=959%2C484&amp;ssl=1\" alt=\"\" class=\"wp-image-1650\" srcset=\"https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/plot_control_panel-1.png?w=959&amp;ssl=1 959w, https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/plot_control_panel-1.png?resize=150%2C76&amp;ssl=1 150w, https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/plot_control_panel-1.png?resize=300%2C151&amp;ssl=1 300w, https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/plot_control_panel-1.png?resize=767%2C387&amp;ssl=1 767w\" sizes=\"auto, (max-width: 959px) 100vw, 959px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Python script from &#8216;rgpio_from_pc_plot.py&#8217; file is shown below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># This example demonstrates how to use CASP Remote GPIO from Python script that runs on host computer. Ensure matching target's casp_pins.py file in present in the script folder before running.\n\nimport sys\nimport time\n\n#modify this path to point to 'casp_user_data\/pycasp' directory in your system\n#sys.path.append(\"C:\/Users\/AL\/Documents\/casp_user_data\/pycasp\/src\")\n\nimport casp_rgpio as rgpio\nimport casp_pins as pins\nimport casp_udio\n\nserver = casp_udio.UdioClass()\nserver.ConnectEth(\"127.0.0.1\", 42001, False, 1, 8, 8) #ip, port, tcp, delay, udi_size, udo_size\n\n#initialize RGPIO instance\nrgpio.Init()\n\n#displays available serial ports\n#rgpio.SerialPorts()\n\n#establish communication with the board. loop till the connection is established\n#modify serial port (\"COM62\") to which the target is connected on your system.\n#to know about available serial ports, use above commented command.\nconnected: bool = False\nwhile connected == False:\n    connected = rgpio.ConnectSerial(\"COM37\", 115200, True, 1, 24, 24) #port, baud, enable_dtr, delay_msec, read_bytes, write_bytes\n    time.sleep(5)\n\n#run a for loop to blink on-board LED, read ADC value and control pwm and servo every one second\nfor i in range(1000):\n    di = rgpio.ReadDigital(pins.GP2_DI) #digital input\n    adc = rgpio.ReadAnalog(pins.GP26) #analog input\n    server.WriteI(0, di)\n    server.WriteI(1, adc)\n    print(f\"di={di}, adc={adc}\")\n    #\n    led_on = server.ReadI(0)\n    rgpio.WriteDigital(pins.GP_LED_DO, led_on) #led control\n    #\n    do_on = server.ReadI(1)\n    rgpio.WriteDigital(pins.GP6_DO, do_on) #digital output\n    #\n    pwm_val = server.ReadI(2)\n    rgpio.WriteAnalog(pins.GP16, pwm_val) #pwm control\n    #\n    servo_val = server.ReadI(3)\n    rgpio.WriteAnalog(pins.GP10_SERVO, servo_val) #servo control\n    #\n    time.sleep(0.05)\n\n#close CASP GPIO instance\nrgpio.Close()<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Related Links<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\"><a href=\"https:\/\/aadhuniklabs.com\/casp-blog\/installing-casp\/\" target=\"_blank\" rel=\"noreferrer noopener\">Installing CASP<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"https:\/\/aadhuniklabs.com\/casp-blog\/updating-casp\/\" target=\"_blank\" rel=\"noreferrer noopener\">Updating CASP<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2w-pins-from-standard-python-remotely-through-wifi\/\" target=\"_blank\" rel=\"noreferrer noopener\">Similar Example Through WiFi Communication<\/a><\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CASP supports accessing micro-controller pins from a standard Python script on host computer through low latency serial or WiFi communication. This feature allows the micro-controller pins to be visualized as&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1672,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_view_id":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[72,87,27,85,84,89],"tags":[93,47,39,97],"post_folder":[68],"class_list":["post-1661","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-communication","category-desktop-computers","category-examples","category-microcontroller-boards","category-platforms","category-raspberry-pi-pico","tag-communication","tag-python","tag-raspberry-pi-pico","tag-rgpio"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Access Raspberry Pi Pico2 Pins From Python Through Serial<\/title>\n<meta name=\"description\" content=\"This example shows how to easily access Raspberry Pi Pico2 pins from a Python script on host computer through serial communication.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Access Raspberry Pi Pico2 Pins From Python Through Serial\" \/>\n<meta property=\"og:description\" content=\"This example shows how to easily access Raspberry Pi Pico2 pins from a Python script on host computer through serial communication.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/\" \/>\n<meta property=\"og:site_name\" content=\"CASP Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-15T07:53:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-09-15T08:49:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/circuit_rpi_pico2-1000x430.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"430\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"AadhunikLabs\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"AadhunikLabs\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/access-raspberry-pi-pico2-pins-from-python-through-serial\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/access-raspberry-pi-pico2-pins-from-python-through-serial\\\/\"},\"author\":{\"name\":\"AadhunikLabs\",\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/#\\\/schema\\\/person\\\/4b27a4300337e4cc03b790befda00fe7\"},\"headline\":\"Access Raspberry Pi Pico2 Pins From Standard Python Through Serial\",\"datePublished\":\"2026-09-15T07:53:29+00:00\",\"dateModified\":\"2026-09-15T08:49:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/access-raspberry-pi-pico2-pins-from-python-through-serial\\\/\"},\"wordCount\":552,\"publisher\":{\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/access-raspberry-pi-pico2-pins-from-python-through-serial\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/aadhuniklabs.com\\\/casp-blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/circuit_rpi_pico2-1000x430.webp?fit=1000%2C430&ssl=1\",\"keywords\":[\"Communication\",\"Python\",\"Raspberry Pi Pico\",\"RGPIO\"],\"articleSection\":[\"Communication\",\"Desktop Computers\",\"Examples\",\"MC Boards\",\"Platforms\",\"Raspberry Pi Pico Series\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/access-raspberry-pi-pico2-pins-from-python-through-serial\\\/\",\"url\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/access-raspberry-pi-pico2-pins-from-python-through-serial\\\/\",\"name\":\"Access Raspberry Pi Pico2 Pins From Python Through Serial\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/access-raspberry-pi-pico2-pins-from-python-through-serial\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/access-raspberry-pi-pico2-pins-from-python-through-serial\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/aadhuniklabs.com\\\/casp-blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/circuit_rpi_pico2-1000x430.webp?fit=1000%2C430&ssl=1\",\"datePublished\":\"2026-09-15T07:53:29+00:00\",\"dateModified\":\"2026-09-15T08:49:28+00:00\",\"description\":\"This example shows how to easily access Raspberry Pi Pico2 pins from a Python script on host computer through serial communication.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/access-raspberry-pi-pico2-pins-from-python-through-serial\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/access-raspberry-pi-pico2-pins-from-python-through-serial\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/access-raspberry-pi-pico2-pins-from-python-through-serial\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/aadhuniklabs.com\\\/casp-blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/circuit_rpi_pico2-1000x430.webp?fit=1000%2C430&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/aadhuniklabs.com\\\/casp-blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/circuit_rpi_pico2-1000x430.webp?fit=1000%2C430&ssl=1\",\"width\":1000,\"height\":430},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/access-raspberry-pi-pico2-pins-from-python-through-serial\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Access Raspberry Pi Pico2 Pins From Standard Python Through Serial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/#website\",\"url\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/\",\"name\":\"CASP Blog\",\"description\":\"Let&#039;s make for fun\",\"publisher\":{\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/#organization\",\"name\":\"CASP Blog\",\"url\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/aadhuniklabs.com\\\/casp-blog\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/casp_logo.png?fit=747%2C157&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/aadhuniklabs.com\\\/casp-blog\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/casp_logo.png?fit=747%2C157&ssl=1\",\"width\":747,\"height\":157,\"caption\":\"CASP Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/#\\\/schema\\\/person\\\/4b27a4300337e4cc03b790befda00fe7\",\"name\":\"AadhunikLabs\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/AL_Logo-Inv-Circle-96x96.webp\",\"url\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/AL_Logo-Inv-Circle-96x96.webp\",\"contentUrl\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/AL_Logo-Inv-Circle-96x96.webp\",\"caption\":\"AadhunikLabs\"},\"sameAs\":[\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\"],\"url\":\"https:\\\/\\\/aadhuniklabs.com\\\/casp-blog\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Access Raspberry Pi Pico2 Pins From Python Through Serial","description":"This example shows how to easily access Raspberry Pi Pico2 pins from a Python script on host computer through serial communication.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/","og_locale":"en_US","og_type":"article","og_title":"Access Raspberry Pi Pico2 Pins From Python Through Serial","og_description":"This example shows how to easily access Raspberry Pi Pico2 pins from a Python script on host computer through serial communication.","og_url":"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/","og_site_name":"CASP Blog","article_published_time":"2026-09-15T07:53:29+00:00","article_modified_time":"2026-09-15T08:49:28+00:00","og_image":[{"width":1000,"height":430,"url":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/circuit_rpi_pico2-1000x430.webp","type":"image\/webp"}],"author":"AadhunikLabs","twitter_card":"summary_large_image","twitter_misc":{"Written by":"AadhunikLabs","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/#article","isPartOf":{"@id":"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/"},"author":{"name":"AadhunikLabs","@id":"https:\/\/aadhuniklabs.com\/casp-blog\/#\/schema\/person\/4b27a4300337e4cc03b790befda00fe7"},"headline":"Access Raspberry Pi Pico2 Pins From Standard Python Through Serial","datePublished":"2026-09-15T07:53:29+00:00","dateModified":"2026-09-15T08:49:28+00:00","mainEntityOfPage":{"@id":"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/"},"wordCount":552,"publisher":{"@id":"https:\/\/aadhuniklabs.com\/casp-blog\/#organization"},"image":{"@id":"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/circuit_rpi_pico2-1000x430.webp?fit=1000%2C430&ssl=1","keywords":["Communication","Python","Raspberry Pi Pico","RGPIO"],"articleSection":["Communication","Desktop Computers","Examples","MC Boards","Platforms","Raspberry Pi Pico Series"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/","url":"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/","name":"Access Raspberry Pi Pico2 Pins From Python Through Serial","isPartOf":{"@id":"https:\/\/aadhuniklabs.com\/casp-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/#primaryimage"},"image":{"@id":"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/circuit_rpi_pico2-1000x430.webp?fit=1000%2C430&ssl=1","datePublished":"2026-09-15T07:53:29+00:00","dateModified":"2026-09-15T08:49:28+00:00","description":"This example shows how to easily access Raspberry Pi Pico2 pins from a Python script on host computer through serial communication.","breadcrumb":{"@id":"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/#primaryimage","url":"https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/circuit_rpi_pico2-1000x430.webp?fit=1000%2C430&ssl=1","contentUrl":"https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/circuit_rpi_pico2-1000x430.webp?fit=1000%2C430&ssl=1","width":1000,"height":430},{"@type":"BreadcrumbList","@id":"https:\/\/aadhuniklabs.com\/casp-blog\/access-raspberry-pi-pico2-pins-from-python-through-serial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/aadhuniklabs.com\/casp-blog\/"},{"@type":"ListItem","position":2,"name":"Access Raspberry Pi Pico2 Pins From Standard Python Through Serial"}]},{"@type":"WebSite","@id":"https:\/\/aadhuniklabs.com\/casp-blog\/#website","url":"https:\/\/aadhuniklabs.com\/casp-blog\/","name":"CASP Blog","description":"Let&#039;s make for fun","publisher":{"@id":"https:\/\/aadhuniklabs.com\/casp-blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/aadhuniklabs.com\/casp-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/aadhuniklabs.com\/casp-blog\/#organization","name":"CASP Blog","url":"https:\/\/aadhuniklabs.com\/casp-blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/aadhuniklabs.com\/casp-blog\/#\/schema\/logo\/image\/","url":"https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/05\/casp_logo.png?fit=747%2C157&ssl=1","contentUrl":"https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/05\/casp_logo.png?fit=747%2C157&ssl=1","width":747,"height":157,"caption":"CASP Blog"},"image":{"@id":"https:\/\/aadhuniklabs.com\/casp-blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/aadhuniklabs.com\/casp-blog\/#\/schema\/person\/4b27a4300337e4cc03b790befda00fe7","name":"AadhunikLabs","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/04\/AL_Logo-Inv-Circle-96x96.webp","url":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/04\/AL_Logo-Inv-Circle-96x96.webp","contentUrl":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/04\/AL_Logo-Inv-Circle-96x96.webp","caption":"AadhunikLabs"},"sameAs":["https:\/\/aadhuniklabs.com\/casp-blog"],"url":"https:\/\/aadhuniklabs.com\/casp-blog\/author\/admin\/"}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/aadhuniklabs.com\/casp-blog\/wp-content\/uploads\/2026\/09\/circuit_rpi_pico2-1000x430.webp?fit=1000%2C430&ssl=1","_links":{"self":[{"href":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-json\/wp\/v2\/posts\/1661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-json\/wp\/v2\/comments?post=1661"}],"version-history":[{"count":10,"href":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-json\/wp\/v2\/posts\/1661\/revisions"}],"predecessor-version":[{"id":1695,"href":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-json\/wp\/v2\/posts\/1661\/revisions\/1695"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-json\/wp\/v2\/media\/1672"}],"wp:attachment":[{"href":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-json\/wp\/v2\/media?parent=1661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-json\/wp\/v2\/categories?post=1661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-json\/wp\/v2\/tags?post=1661"},{"taxonomy":"post_folder","embeddable":true,"href":"https:\/\/aadhuniklabs.com\/casp-blog\/wp-json\/wp\/v2\/post_folder?post=1661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}