Hello,
Just a quick update on that topic, I just realized I hadn’t replied yet.
I was able to establish communication between my lego Hub (which I received a few weeks ago) with a raspberry pi using UART.
For speed I was able to use 230400 bauds and I didn’t try to go further since the Pixy doesn’t support it anyway.
I only tested communication in the Hub -> RPi direction for now, but there is no reason that I will encounter errors in the other direction, I try to be carefull when plugin things into the hub.
Regarding other settings it was pretty much what looks to be a standard: 8 data bits, no parity, 1 stop bit. So it matches what is described in the wiki for the Pixy 2, so it should work. I haven’t bought a Pixy2 cam yet so I can’t try, that’s something I’m planning to do in the future.
One quirk about the Lego API is that not everything works like it should:
import hub
from mindstorms.control import wait_for_seconds
port = hub.port
f = port.F
#doesn't work
#f.mode(port.MODE_FULL_DUPLEX, 115200)
#works
f.mode(port.MODE_FULL_DUPLEX)
wait_for_seconds(0.5)
f.baud(115200)
I figured that out while reading someone else’s code on GitHub: antonvh UartRemote library
Regarding which pins are used for ground / TX / RX on the hub, this website was very clear: philohome.com - The Power Functions 2.0 connector
I probably wouldn’t have figured this out on my own.