send data from Arduino Uno to computer

I am a beginner of developing a arduino project. I only got an arduino uno board and small ultrasonic sensor. I want to store the sensor’s data to my database in compuster with USB connection, and then I can work on showing those data on webs or apps, is that possible to do it?
Thank you.

The Uno USB port is only for uploading programs so the answer to your question is no.

You would want an Ethernet shield on the Uno to to communicate with a database.

The Uno USB port is only for uploading programs so the answer to your question is no

The USB port is also a serial bridge to the PC, so other programs on the PC can read and write data to the Arduino via the serial port.

Having said that, ethernet or wifi shields are more convenient as they untether your arduino from the need to be connected to a PC.

You can use the serial port on any Arduino, including one with a USB connection, to send data to a computer running a terminal program like Putty, Hyperterm, TeraTerm, etc. and "log" the data to a file.

You will have to first upload your program, close the Arduino IDE, then open the terminal program and connect to the same serial (COM) port, at the same baud rate.

If you separate several numbers on each line with commas, then the file can be imported into a spreadsheet as a CSV file.

And note that, if you use a kosher terminal programme, you can even add a timestamp using the PC clock, thereby absolving you from providing your own. It is even possible to feed direct to Excel, yes via USB cable, and have a live graphic display.

I submit that about the only time

avr_fred:
You would want an Ethernet shield on the Uno

Is when you want to

davidrh:
untether your arduino from the need to be connected to a PC.

Nick_Pyner:
And note that, if you use a kosher terminal programme, you can even add a timestamp using the PC clock, thereby absolving you from providing your own. It is even possible to feed direct to Excel, yes via USB cable, and have a live graphic display.

I submit that about the only timeIs when you want to

This would be very helpful! I am unfamiliar with what terminal programs might be kosher and which are not. Would you be able to share resources/tutorial for how this would be done?

I use Tera Term.

PuTTy and TeraTerm both work for me.

You can also send data directly to an Excel spreadsheet on a Windows machine, using PLX-DAQ version 2.

You can use Python to collect data from your Arduino and do further processing with the data (i.e. host a webpage).

This is made easy using the compatible libraries: pySerialTransfer and SerialTransfer.h.

pySerialTransfer is pip-installable and cross-platform compatible. SerialTransfer.h runs on the Arduino platform and can be installed through the Arduino IDE’s Libraries Manager.

Both of these libraries have highly efficient and robust packetizing/parsing algorithms with easy to use APIs.

Example Python Script:

from time import sleep
from pySerialTransfer import pySerialTransfer as txfer

if __name__ == '__main__':
    try:
        link = txfer.SerialTransfer('COM13')
        
        link.open()
        sleep(2) # allow some time for the Arduino to completely reset
    
        link.txBuff[0] = 'h'
        link.txBuff[1] = 'i'
        link.txBuff[2] = '\n'
        
        link.send(3)
        
        while not link.available():
            if link.status < 0:
                print('ERROR: {}'.format(link.status))
            
        print('Response received:')
        
        response = ''
        for index in range(link.bytesRead):
            response += chr(link.rxBuff[index])
        
        print(response)
        link.close()
        
    except KeyboardInterrupt:
        link.close()

Example Arduino Sketch:

#include "SerialTransfer.h"

SerialTransfer myTransfer;

void setup()
{
  Serial.begin(115200);
  Serial1.begin(115200);
  myTransfer.begin(Serial1);
}

void loop()
{
  myTransfer.txBuff[0] = 'h';
  myTransfer.txBuff[1] = 'i';
  myTransfer.txBuff[2] = '\n';
  
  myTransfer.sendData(3);
  delay(100);

  if(myTransfer.available())
  {
    Serial.println("New Data");
    for(byte i = 0; i < myTransfer.bytesRead; i++)
      Serial.write(myTransfer.rxBuff[i]);
    Serial.println();
  }
  else if(myTransfer.status < 0)
  {
    Serial.print("ERROR: ");
    Serial.println(myTransfer.status);
  }
}

creativefusebox:
Would you be able to share resources/tutorial for how this would be done?

I used RealTerm. I had a personal preference for it, but I can't remember what it was. It and the others mentioned above are really much the same and all are freebies. But note particularly my lyrical waxing, and reply #7. If you really want to do this, I think PLX is the way to do it. The only exception may be if you want the link via Bluetooth.