I'm new to using a RaspberryPi. Until now I was experimenting with an Arduino.
If I connect an Arduino by usb it is recognized as COM device and with the Arduino serial plot software it was easily possible to live plot sensor data.
For my next project I want to work with an Raspberry Pi Zero W and Python.
Is it possible to send serial data from a python script over the charging usb-cable like with the Arduino? If not, what would be the easiest way to send sensor data e.g. to matplotlib to plot the data directly?
It is possible. However I would not recommend using the USB serial port profile. While it works, it is severely limited in comparison to the alternative. Which is using one of the various ethernet gadget modes.
One tutorial for setting this up is e.g. http://www.circuitbasics.com/raspberry-pi-zero-ethernet-gadget/
The result of this is a full network interface that you can not only use to transfer data over a TCP/IP socket but at the same time run a SSH-connection to start and monitor your application. Even to develop by using a SSH-enabled editor such as Emacs. So the possibilities are much bigger than over the single-stream serial setup.
If it absolutely has to be serial, that's of course possible too - follow e.g. this tutorial: https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/serial-gadget
Related
In short, I have written a Python program to write a series of commands to a serial device I'm working with, and I want to make sure they're working in the way I want them to.
For sure, no device connected means no response/nothing to read...
Did you consider trying a serial port sniffer, if you google for serial port sniffer, you'll find more than you need.
Connect any serial device and sniff what you send.
I am designing an FPGA for a college project and we need to send data to an FPGA, so we wanted to use USB cords and a python program to manage sending/receiving/displaying information on the computer sending/receiving data from the FPGA.
I've never really written anything to send data to external devices other than when using putty and an atmel avr microcontroller for a previous class, so i'm not familiar with how USB works. If anyone knows how to do this in python, as well as any issues i need to be aware of that would be great. I'm using Python 3.7 and working on a windows 10 laptop.
Edit: some clarification on the project itself. We are using the FPGA as an encoder. The fpga will have modules that perform the encoding and other stuff, but the python program itself only needs to ask the user for an encoding method and get said data to be encoded, then append bits to the data that will allow the FPGA to identify the encoding method, then send the data out to a usb.
I have an RGB LED strip hooked to an Arduino Uno and I want to sync that LED strip to the effects currently sent from Razer Synapse to my keyboard/mouse on Windows 10.
Since Razer Synapse only sends RGB data to their hardware and 3rd party hardware (NZXT, Corsair, etc) my other options are to either snoop the RAM for the RGB data that is sent to the devices, or snoop the USB data sent by Synapse to the devices so I don't have to process animations since all will be done by Synapse.
I've tried to use Device Monitoring Studio to read USB data and I did manage to find what I wanted but I am not sure what kind of data that is and how to get the same data into Python programatically.
I've tried to use pywinusb and the raw_data.py example to read raw data from the keyboard itself but I don't get anything. Maybe I'm not using the proper library for my task.
How do I get that (assuming binary) data with Python to send it via serial to my Arduino ?
I am using a Beaglebone Black (BBB) with Python and pyserial to communicate with an OBD-II reader. I am essentially trying to build a customizable digital gauge panel. Ideally I would like to use Flash for the GUI. Sadly Linux support for Flash is pretty weak. I would like to be able to send data from the BBB using Python to a OSX host computer.
I am currently using terminal to shell into the BBB to run code. I would need to be able to send data from the BBB via a USB/serial interface to the OSX computer running Flash. What would be the best method of accomplishing this?
I have not used beaglebone. I have worked with arduino's serial I/O. But this post says you have multiple serial I/O ports on BBB. Find appropriate connectors/convertors for serial to USB.
Then use the pyserial python module.
On OSX, you will find your device when connected on a path like /dev/ttyo1 where dev is my system name and ttyo1 or something similar will be your device.
import serial as s
device = "/dev/tty01"
bbb = s.Serial(device, 4800) #the second param is baudrate
while(True):
bbb.readline()
# do what you want with the output.
bbb.write('input')
This will read till the end of line character and give you a string. and then write "input" to the serial io on bbb. You will need a similar program running on BBB to read this input and do what you want to do with it.
So there will be two python programs. One on the OSX and the other on the BBB
That way you can give commands from OSX.py, let your BBB.py process and send a response. Which the OSX.py will read and do what is to be done.
You will have to design the input/output cycle properly.
Also if flash is not really necessary you can check out pyside.
For the mapping of the obstacles in a region, I was planning on using Sharp IR range finders connected with an Arduino Mega and then trying to plot it in real time on a polar histogram type map using python and matplotlib. I was a bit confused about how to proceed through the interfacing of the Arduino and python over the serial connection.
Any help would be great.
Thanks
This might be a good start: Arduino and Python. Summary: use pySerial and read from/write to /dev/tty.usbserial.
See also:
How to send a value from Arduino to Python and then use that value
Receive multiple values via pyserial and display in Python GUI
If you are ok with skipping Python you can do the same thing in Processing. If you just manage to send the data wirelessly over for examble xbee or bluetooth then it would be a piece of cake to connect it to a plotting software like this http://sebastiannilsson.com/en/k/projekt/realtime-plotter/