Link to home
Start Free TrialLog in
Avatar of LarryZ
LarryZ

asked on

VB.Net to Read Serial Port Data from Temperature Monitor

Bought an inexpensive temperature monitor with 4 sensors. In HyperTerminal, I can connect to it on Com1 using 9600,N,8,1, and see that it generates a comma-delineated line at regular intervals that reveals the sensor data. I'd like to avoid HyperTerminal altogether and use VB.Net code to poll the port, write the data to a database, and send emails when out of range.

I need help with the serial communications part.

I tried to use system.io.ports to get the data generated on COM1 by device, but was unsuccessful.
Any code snippets would be helpful.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of fuzzymallets1
fuzzymallets1
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
have you determine the communication parameters of your device?
If not I suggest to use some Terminal application. Then you can start your serial port programming with confidence.
 
Have you determine the communications parameters of your serial device?
If not, I suggest to use some Terminal application. then you can start with the programming.
Avatar of LarryZ
LarryZ

ASKER

fuzzymallets1:
Dropped a SerialPort on the form, it's SerialPort1 by default. Dropped a ListBox on the form and named it LstTickets. When I run the program, the listbox does not populate. How can I tell I data is being received from SerialPort1?

jaime:
I told SerialPort1 that:
Baud Rate = 9600
Parity = none
DatBits = 8
StopBits = one
PortName = COM1
Not sure what to do about handshake.

I need a way to tell if data is received. Also, I'll try to open the serial port.
Oops That might help.

If SerialPort1.IsOpen Then
            SerialPort1.Close()
End If
 
Try
            SerialPort1.Open()
        Catch ex As Exception
End Try

Open in new window

Do that on the form load
Avatar of LarryZ

ASKER

Still no data to listbox, even if I press the ENTER key.  Can I somehow use a watch window, something like SerialPort1.Read or SerialPort1.ReadLine to see data from the serial port?
Avatar of LarryZ

ASKER

Changed SerialPort1's Handshake to "RequestToSend". Now I'm populating the ListBox, but line feeds
(line breaks) are not correct






















































































Avatar of LarryZ

ASKER

Works great with these simple changes to SerialPort1:
Handhake = none
RtsEnable = True
And this change to code:
.Items.Add(SerialPort1.ReadLine)

THANKS !!