Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1508

[VB6] TEMPer Gold USB HID Thermometer Class

$
0
0
Background

TEMPer is a series of products by PCsensor for measuring temperature (and in some cases humidity). There are many models on the market with varying capabilities. While some of the early units appear as USB Serial devices (COMx: ports) the newer ones are USB HID devices that use the standard Windows driver and don't require driver installation.

This Class (TEMPerGold.cls) is a Visual Basic 6.0 Class that works only with the TEMPer Gold product. It is a wrapper around the RDingUSB.dll that comes with the unit's software package. The software is a basic .Net application you may or may not find useful. There is basically ZERO documentation available on the companion mini-CD or online.

TEMPer Gold runs from about $9 to $20 USD (depending on where you shop) if you are curious.

In my case the product arrived in some limp baggies, perhaps returned by another customer? Everything was there, though the mini CD-R only seemed to have one unreadable session on it. The unreable disk might have been why it was returned. I downloaded the software package from PCsensor but never installed it since it requires .Net 2.0 on your machine.

I also never saw the "red" LED light up as described by PCsensor. But perhaps mine has a dummy LED where the LED would go, having been dropped to save costs - and because an "operating" LED is fairly useless here.


Basic Operation

If you plug in the TEMPer Gold without installing any software it "installs" in Windows as two HID devices: one a keyboard and the other a special function device.

As a "keyboard" you can make basic use of the TEMPer by opening Excel or even Notepad and then holding Caps Lock or Num Lock for 3 seconds, which makes it start "typing" readings until you hold down Caps Lock or Num Lock 3 seconds again.

Details on using the sample .Net applet can be found on the PCsensor web site (see link above). I didn't install it because I have too much .Net clutter here right now anyway, and did not want to risk the cruft a poorly constructed installer might leave behind even after uninstalling it.


Extracting RDingUSB.dll

Since my code requires this DLL you'll have to extract it in order to use TEMPerGold.cls yourself.

The easiest way is to locate the MSI package containing the PCsensor demo applet and do an "administrative install" to extract the installation files to a folder. Example:

Code:

msiexec /a "d:\work\temper\thepackage.msi" /qb TARGETDIR="d:\work\temper\packagefiles"

My Demo

The attached demo Project archive contains all of the files needed to build and run the VB6 demo. However for it to run you'll need to either put RDingUSB.dll in the Project folder yourself, or else place it where a normal system DLL Search will find it.

The demo as written manages the state of its UI to guide you through the right steps, but basically:
  • First you Open the device.
  • Then you can Get/Set the Calibration.
  • Then you can start taking sample readings.
  • Finally you Close the device.
Calibration is an offset ranging from -8 to +7°C, and it seems to be non-volatile. You only need to set it when you want to adjust it.


Oof!

This was a messy thing to track down and I had lots of false starts.

While written only for the TEMPer Gold you can probably modify it to work for other TEMPer devices that are USB HID devices. The USB COM-port type should be easier if you find one of those though the interaction back and forth seems quite different.

I found basically nothing useful online to help me write this class. There were a few spotty discussions on the older COM-port devices but that was about it for VB. The RDingUSB.dll is really a renamed SonixUSB.dll (based on a DUMPBIN of the file), which probably means the product uses some Sonix USB microcontroller to front-end the Fairchild FM75 temperature sensor inside.

I had to reverse-engineer the exported function calls by using Reflection to tear down the compiled .Net demo supplied.

If you've had a need for this same thing you've probably also been amused as well as frustrated. As I said there is little out there, but what you do find is a lot of hilarious (and mostly none too useful) posting by the Linux and Delphi communities. One can only wonder how they ever get anything to work. Then again to be fair, just look at so many posts here by both VBers and DotNetters.


Taking it Further

You could easily write a data logger application, charting application, etc. if you want one.

I'm thinking of adding it as optional functionality to my GossCam webcam server posted here in another thread.
Attached Images
   
Attached Files

Viewing all articles
Browse latest Browse all 1508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>