Click here to Skip to main content
13,055,958 members (55,663 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I want to develop an application in VB.Net that captures data (temperature and pressure) using USB port and displays the values on Screen.
The values may then be used to generate Graphs or for controlling other devices, again using USB Port.

However, I have not found any method in .Net for interfacing with USB Port.

How do I proceed?

Preetinder Singh

[edit]Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know - OriginalGriff[/edit]
Posted 19-May-11 19:49pm
Updated 19-May-11 20:55pm
Dalek Dave433.3K
Dalek Dave 20-May-11 2:55am
Edited for Grammar and Readability.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You treate the USB port as it is was a standard serial port. Create an instance of the SerialPort class[^], and handle the incoming data:
    SerialPort sensor = new SerialPort("COM6");
    sensor.BaudRate = 9600;
    sensor.Parity = Parity.None;
    sensor.StopBits = StopBits.One;
    sensor.DataBits = 8;
    sensor.Handshake = Handshake.None;
    sensor.DataReceived += new SerialDataReceivedEventHandler(Sensor_DataReceived);
    Console.WriteLine("Press any key to continue...");

private static void Sensor_DataReceived(object sender, SerialDataReceivedEventArgs e)
    SerialPort sensor = (SerialPort)sender;
    string data = sensor.ReadExisting();
Dalek Dave 20-May-11 2:55am
Good Answer.
Samuel_Tandibua 20-May-11 15:54pm
Member 3232428 5-Oct-15 1:50am
my printer uses USB001 NOT COM, and when I try to use that port it says: The given port name does not start with COM/com or does not resolve to a valid serial port. what should I do?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

That's because you're trying to treat the USB port as a port like you would a serial or parallel port. Look at what USB stands for: Universal Serial BUS. A USB is not a port, but a BUS, not unlike the expansion slots inside your computer.

You interface with the device attached to the port, not the port itself. How you do this depends on what interface the device exposes. It's entirely possible that the device exposes itself as serial port emulation and you can get at it just like any other serial port device using the SerialPort class.

However, if your device doesn't do that, you'll have to get an SDK from the manufacturer of the device to let your code interface with it. This is the case with Phidgets devices (

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 20 May 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100