Receive data from COM port.

Harry Geda

Board Regular
Joined
Mar 4, 2010
Messages
153
Hello,

I have a temperature monitor that is connected to my computer
via RS232 to COM1.
(The actual connection is via a COM to USB cable.)

Small records of 10 charracters + Carriage-Return are sent per communication.

I can receive the data with Hyper Terminal program of XP on COM1.

If I could direct the data to EXCEL then I could resume with the data collection. :confused:

I can try to create a program to write the data in comma separated format in a file but that is not my intention.

Is this possible to do without programming?
What is the best way to do this?


Thank you,
Harry Geda
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
You could use VBA file I/O to read data from the COM port into Excel. The following example polls the COM5 port every 200 milliseconds for 30 seconds and displays the data received in the Immediate window. To make it work with COM1, just change the Open statement.
Code:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
.[/QUOTE]

Hi and thanks for this code, this something that could work for me.
I have a serial device connected to the PC via USB to Serial interface cable on COM5.
I copied the code into a module in Excel 2007 and ran the code, it's running but it also hangs and does not stop run until I pull out the USB to serial cable from the PC.
I changed the baud rate to 19200 as per the device setup but I cant get the transmission to work.
Any ideas what can go wrong here.
Really appreciate your thoughts

Regards

Rick
 
Upvote 0
I tried this and I get an error invalid procedure Opencomm, even though it clearly is there. Could this be a reference issue?
 
Upvote 0
I'm very sorry...I mentioned the wrong error message.
The error occurs here : Open"com5 , 2400,N,1,...."
Error File not found.

Sorry for the confusion.
 
Upvote 0
Does the computer have a COM5 port? If not, try changing the COM5 part to a different port.
 
Upvote 0
It is using Com 5. I verified this. I don't suppose I am missing a reference? I was under the impression this was direct read from the com port.
 
Upvote 0
Is there a way I could, after opening the Com Port, Send a line feed and then "Loop 1" to the Comm Port?
 
Upvote 0
Hello everybody,

first of all, thx to all people that helps other to learn how things works :-)

I have a question regarding the code in Post 2. since i need to do a similar recording like Harry Geda, i found this forum and his helpfull topics. so i tooked the code and after a little bit of playing with virtual ports and other smaller problems, i got the code work for me without any debug or path errors. but now... my problem... how can i get the received data stored in a xlsx file? should this already work with this code? if yes, where is the file?

My situation looks as follows:
Excel 2013 on Win7
made a new file called Book1.xlsm / xlsx on desktop
put in the code in a Module 1
paired COM3 and COM4 with virtual serial port driver v8.0
Writing data with com port data emulator & Traffic generator on Port 3
VBA Code opens port 4

I know that data is going to port 4 because i see that in the virtualization software and i double checked it with a other Programm (data logger suite)
and the virtualization software also tells me that port 4 is open when i start the vba code. but i cant see any data.

i'll hope that i provided you with all the needet information and that someone could help

thx all
 
Upvote 0

Forum statistics

Threads
1,223,270
Messages
6,171,102
Members
452,379
Latest member
IainTru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top