NoobithOfRasberia
Posts: 4
Joined: Sun Jun 01, 2014 9:09 pm

Raspberry Pi sensor data with Windows?

Thu Jan 23, 2020 7:09 pm

Hello!
For a robot I'm building, I would like to keep programming on my laptop instead of using ssh or vnc. I want to get sensor data on the pi and for the pi to receive commands (give me data from sensors ____, ___, and ___; set pins 4, 5, and 6 to _, _, and _; get encoder position; etc), so I need to implement some kind of fast 2-way communication between pyserial on my windows machine, and whatever solution the raspberry pi would use...
Before anyone suggests this (I say this because I would suggest this), I've tried to use an arduino to do this, but the only way to send data between a PC and a pi is usb, which is slow when you have to send data back and forth in near-realtime.
Does anyone have any suggestions on how I can do this?
To summarize, my goal is to have a Raspberry Pi I can plug into my Windows PC and get sensor data and send command data fast enough for applications such as PID control and sensor output.

I realize this whole thing can be solved by simply programming on the Raspberry Pi, but the issue is that I hate developing using the pi's interface (atom is a lot nicer for me). I was thinking for functioning autonomous code, I can just github that to the board when I want it to run by itself, but for developing, however, I want to use python on my PC to run graphics, debug, etc.

[encoder, gyro, camera data (all on Pi)] --> [Windows machine gets and interprets this data]
[motors, servos, etc (on pi)] <-- [Windows machine controls them based on this data]

I think I got my whole problem down... let me know if I need to clarify anything!!
Thanks for any help!!

User avatar
thagrol
Posts: 4207
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Raspberry Pi sensor data with Windows?

Fri Jan 24, 2020 12:40 am

NoobithOfRasberia wrote:
Thu Jan 23, 2020 7:09 pm
Hello!
For a robot I'm building, I would like to keep programming on my laptop instead of using ssh or vnc. I want to get sensor data on the pi and for the pi to receive commands (give me data from sensors ____, ___, and ___; set pins 4, 5, and 6 to _, _, and _; get encoder position; etc), so I need to implement some kind of fast 2-way communication between pyserial on my windows machine, and whatever solution the raspberry pi would use...
Are you restricted to a serial link or can you use other technologies e.g. ethernet, WiFi, Bluetooth (bluetooth has a serial profile).
Before anyone suggests this (I say this because I would suggest this), I've tried to use an arduino to do this, but the only way to send data between a PC and a pi is usb, which is slow when you have to send data back and forth in near-realtime.
USB is a lot faster than straight serial so I doubt USB was the bottleneck.
Does anyone have any suggestions on how I can do this?
Several:
  • Ditch the arduino and use a USB to 3.3v TTL serial dongle to connect the PC to the Pi. USB at the PC end, connect to the TX, RX, and ground pins on the gpio header at the Pi end.
  • Set up a network link between the PC and the Pi (ethernet, WiFi, bluetooth, TCP over serial, etc) then use MQTT
  • Set up a network link between the PC and the Pi (ethernet, WiFi, bluetooth, TCP over serial, etc) then use the remote GPIO feature of the pigpio library (http://abyz.me.uk/rpi/pigpio/)
  • Set up a network link between the PC and the Pi (ethernet, WiFi, bluetooth, TCP over serial, etc) then use a virtual serial link over that with your existing serial based code. The netcat tool may help here.
  • Set up a network link between the PC and the Pi (ethernet, WiFi, bluetooth, TCP over serial, etc) then write your own protocol over a TCP socket.
Detailed instructions on the above left as an exercise for the reader :)
Arguing with strangers on the internet since 1993.

All advice given is based on my experience. it worked for me, it may not work for you.
All GPIO pin numbers are BCM numbers.

NoobithOfRasberia
Posts: 4
Joined: Sun Jun 01, 2014 9:09 pm

Re: Raspberry Pi sensor data with Windows?

Fri Jan 24, 2020 7:53 pm

to answer your questions:
I don't really care how the communication happens, though wireless would be nice
I guess I don't know the difference between USB and serial... :shock:

Thanks for your help! I'll look into your suggestions :)

Return to “Automation, sensing and robotics”