Write a simple program to read real time temperature from KMK USB Temperature Sensor Card with Microsoft Visual C# 2008 Express.

We are going to write a program to read the tact switches status, display it and do some responses on the computer screen. Please refer to KMK USB Temperature Sensor Card Manual for detail operations.


Step 1 - 2 need to do once on your computer. Just skip steps 1 - 2 if you have done it already, .

Step 1 Install Visual C# 2008 Express.

Step 2 USB Driver installation.

Step 3 Install KMK USB Temperature OCX for KMK USB Temperature Sensor card.

Step 4 Load KMK USB Temperature OCX into C#.


Step 5


Find the Serial Number and the Activated Code on the attached document (It comes with the package). You must have both of them in order to write the program for it. Make sure you have attached the KMK USB Temperature Sensor card and the OCX is on the form.


Step 6


We are going to write the code for automatically connecting the IO card while the program is started. Double click on the empty space of the form to enter into the code page. Type the code as below;


Step 7


We need a timer to scan the sensor status from time to time. This process is known as 'Polling'. From the tool box choose 'Timer' and drag it to the form. Change the property Enable to True.


Step 8


Put a TextBox on the form as below;


Step 9


We are going to write some simple code so the the temperature can be displayed on the TextBox. Double click on the Timer and enter the code below;


Step 10


Press F5 to run the program. When the program is running, a green light flash indicating the OCX is running.


Note: You can connect more KMK USB Temperature Sensor cards in order to read temperature from different locations. Of course you'll need same number of ocxs on the form to operate them.

Note: We can put If command to turn on electrical devices according to different temperature. We have samples for similar applications, please check the Program Samples page.