Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4151

General • Re: Connecting a raspberry pie zero 2 W with a pi pico

$
0
0
I connected a Pi Zero W to a Pi Pico and it's working well for me. If you want to use I2C, you probably want the Zero to be the master, so look up how to do I2C master in python on a Raspberry Pi. You might want to test your Zero's I2C with something that you know communicates with i2c, like a sensor. Then, you can learn how to do slave I2C in micropython on the Pico.

My implementation was a lot easier than using I2C. I connected the USB ports with a Host USB cable like this one from adafruit: https://www.adafruit.com/product/3610?g ... ZdEALw_wcB. It worked because I'm connecting my desktop to the Zero W with Wifi, so I don't need the data USB port for development. I used C++ on the pico and a mix of C++ and Python on the Zero, so an entirely Python implementation would be a bit different. If you're interested, you can find it on GitHub: https://github.com/NirajPatelRobots/sim ... /tree/main

For the Pico:
In C++ you can use "pico_enable_stdio_usb" in CMakeLists.txt, there is probably some equivalent in python. That connects the USB port on the Pico to "stdin" and "stdout", which are the easiest ways for a program to input and output data. If you do, you can read data using input() or raw_input() and write data using print() in python. Learning more about "stdio" will help you with this.

For the Zero:
The USB port uses Serial communication with the port name "/dev/ttyACM0". You can use the convenient python Serial library to open a serial port with:

Code:

picoUSB = serial.Serial(port='/dev/ttyACM0', baudrate=115200, parity=serial.PARITY_NONE,                            stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1)
.

Statistics: Posted by mteverestand — Wed Mar 13, 2024 4:41 am



Viewing all articles
Browse latest Browse all 4151

Trending Articles