简体   繁体   中英

How to send data from Arduino Uno to PC using the USB port

I'm building an NFC project in which I have an Arduino Uno with a PN532 NFC shield that reads stored messages from tags. What I'm trying to achieve is to store/write the information to a .csv file, but I need to send the data over the USB cable through which the Uno is connected to on my PC.

Is there any way to write the data to .csv file onto the Arduino, then send the .csv file to the PC over the USB cable to a given directory, or write a program that reads the data being sent from the Uno through the USB cable, and then write the data on the PC to a .csv file? I'm aware I could get a breadboard with an SD card reader, and write the data to an SD card but I'm trying to avoid this solution if possible. Is there any way to send files or data over USB from Arduino to PC?

I would definitely have the Arduino send the values over the USB interface and have the host run a Python program that uses the CSV library to write a .csv file.

You could simply "print" the values from the Arduino to the USB interface and read them on the host using /dev/ttyUSBx. But at some point you might want to send control commands to the Arduino. And you might want to do some logging, catch errors, etc. If so, I suggest that you look at a full-fledged communication protocol. I realize you're not controlling a robot, but rosserial from Robot Operating System (ROS) would make this easy. It might feel like overkill but I think you'll appreciate the features once you start using it.

Do you need an example?

I found a solution using php. This way I can send and receive data from Arduino and PC. This is the link https://stackoverflow.com/a/64593069/1735122

enjoy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM