Saturday, January 26, 2008

Taking advantage of your TEMPer 1.0 USB device

I recently purchased a TEMPer (http://www.usbfever.com/index_eproduct_view.php?products_id=257) device to assist me in yet another time wasting home improvement project and was shocked to see all the wasted potential in this device. After being blinded by the .NET application that came with the device, I decided to take it upon myself to write something better. I had heard about Reflector (http://www.aisto.com/roeder/dotnet/) but had never actually used it for anything.. man was I impressed.. dropping TEMPer.exe into Reflector gave nicely formatted source code for literally every method required to use the TEMPer device. So here it is folks, a .NET (C#) dell you can use to access your TEMPer device (the download link is at the bottom).



using System;
using TEMPer.Communication;

namespace TEMPerDemo
{
class Program
{
const String m_CallNumFormat = "000000";
const String m_TempFormat = "00.0000";

static void Main(string[] args)
{
double TempC;
double TempF;
int i;

String[] ComPorts = TEMPerInterface.FindDevices();
if (ComPorts.Length == 0) return;

TEMPerInterface[] Devices = new TEMPerInterface[ComPorts.Length];

for (i = 0; i < ComPorts.Length; i++)
Devices[i] = new TEMPerInterface(ComPorts[i]);

for (int CallNum = 1; CallNum <= 1000; CallNum++)
{
for(i = 0; i < Devices.Length; i++)
{
TempC = Devices[i].ReadTEMP();
TempF = TEMPerInterface.CtoF(TempC);

Console.WriteLine(" "
+ CallNum.ToString(m_CallNumFormat)
+ " - "
+ Devices[i].PortName
+ " - "
+ TempC.ToString(m_TempFormat) + " C"
+ " - "
+ TempF.ToString(m_TempFormat) + " F");
}
}
}
}
}


The results:


000001 - COM19 - 22.3750 C - 72.2750 F
000002 - COM19 - 22.3750 C - 72.2750 F
000003 - COM19 - 22.3750 C - 72.2750 F
000004 - COM19 - 22.3750 C - 72.2750 F
....
000049 - COM19 - 22.5000 C - 72.5000 F
000050 - COM19 - 22.5000 C - 72.5000 F

Requirements:
As of version 2008.01.29.1, the DLL no longer requires USBRDXP.DLL (thanks to Bob for the code that removed this dependency).

Notes:
The device speaks Celsius.. and as such only returns degrees in 0.1250 increments.
If you decide to use this library or the above code, please feel free to contact me with questions (not that I completely understand everything their original code is doing.. trust me, the decompiled code lacks a lot of context) or comments.. but please understand that I'm not responsible for any problems/issues that might crop up as a result of using this library.

The library only does a few things:
1. Reads the registry to list the system's com ports
2. Queries each COM port to find those that have a TEMPer device
3. Reads/writes to the COM port to get temperature data

That's it.. there's no other magic or trickery going on inside the library.

Download the DLL: TEMPer.Communication.dll (v. 2008.02.23.1)
Download the source code: TEMPer.cs (v. 2008.02.23.1)

Changes
------------
v.1
- Initial release

v.2008.01.29.1
- Removed static reference to SerialPort (I suspect this is why reading from multiple devices would fail when multiple instances were created. I'll have to wait for my new devices to arrive before I can verify this).
- Removed the dependency on the TEMPer driver/dll. Thanks to Bob (see comments below) for the C++ code to implement the TEMPer device verification manually. The code below was ported to C# to make things a bit easier on my end.
- Added a version to the DLL

v.2008.02.23.1
- GetPortNames() now uses the managed SerialPort.GetPortNames() instead of querying the windows registry.
- I experimented with the idea of making ReadTemp a static call (removing the need to create an instance of the TEMPerInterface class) but the overhead for initializing the device added more than 1 second to each read call (something I was not willing to live with). Instead, I cleaned up a bit of the code I borrowed form the original TEMPer exe which shaved a few hundred milliseconds off of each call.
- The SerialPort is only kept open for the initialization of the device and for each ReadTemp (previously, the SerialPort was not being closed at the end of every ReadTemp call). Leaving the SerialPort open (eliminating the overhead of opening/closing the SerialPort each time) caused major freezing issues on my Vista laptop. The performance gain was insignificant, so the SerialPort is now closed at the end of each ReadTemp call. As the SerialPort is closed at the end of each read, there is no longer a need to manually call the Close function on the TEMPerInterface class (therefore that function has been removed).

100 comments:

  1. Hi,

    Not used C# before but I'm getting the following error when trying to add your dll to my C# console project as a resource in MS Visual Studio 2003.

    "A referance to 'C:\...\TEMPer.Communication.dll' could not be added. This is not a valid assembly or COM component. Only assemblies with extension 'dll' and COM components can be referenced. Please make sure that the file is accessible, and that its a valid assembly or COM component.'

    Any ideas?

    Thanks,
    bob

    ReplyDelete
  2. Hi again,

    I finnally got it working in VS2005!

    Any way to debug and step through the dll to compare values? I'm doing my projetc in C++ and just need to verify some values. but the step through just goes over the dll and back out :(

    Cheers,
    bob (m3ga@hotmail.com)

    ReplyDelete
  3. Bob,

    Glad to hear you were able to get the DLL up and running.

    I developed the DLL using Visual Studio 2008 on Windows Vista 32-bit. I developed/compiled the DLL using .NET 2.0 .. sorry to leave your Visual Studio 2003 out in the cold.

    On to business...

    The DLL I posted was the Release version and lacks the debug information you would need.

    I can provide you with the source (or a .NET project) if you like.. but unless you're going to debug their COM communication, I don't really know how much use you'll get out of it. If you still think you'd like to be able to step into the DLL, let me now and I'll post some additional code/files.

    It's a bit old school.. but you could always try comparing the readings from your project to that of the application that came with the TEMPer device (assuming of course your version isn't the same flawed one I had).

    ReplyDelete
  4. Hi,

    I spent some time and finally got the code from the dll and put it into the main app and got everything working including debugging.

    Yes, I'm mainly looking at the serial communications, as I don't use .net (Borland C++) I'm having a few issues replacing .net functions with their borland equivalents to get the same results.

    Your dll has helped a lot!

    Thanks
    bob

    ReplyDelete
  5. If you want to drop linking to the USBRDXP.DLL you can use the follwoing functions, they are in C++ though so you may need to update them to suit your project

    bool CH341PtHandleIsCH341(HANDLE iPortHandle)
    {
    struct _COMMPROP CommProp;

    return iPortHandle
    && iPortHandle != (HANDLE)-1
    && (CommProp.dwProvSpec2 = 0, CommProp.wPacketLength = 64, CommProp.dwProvSpec1 = -415435474, GetCommProperties(iPortHandle, &CommProp))
    && (CommProp.dwProvSpec2 == 1128813859 || CommProp.dwProvSpec2 == 1128813842);
    }


    signed int CH341PtNameIsCH341(LPCSTR lpFileName)
    {
    HANDLE v1;
    void *v2;

    if ( lpFileName )
    {
    v1 = CreateFileA(lpFileName, 0xC0000000u, 3u, 0, 3u, 0x80u, 0);
    v2 = v1;
    if ( v1 != (HANDLE)-1 )
    {
    if ( CH341PtHandleIsCH341(v1) )
    {
    CloseHandle(v2);
    return 1;
    }
    CloseHandle(v2);
    }
    }
    return 0;
    }

    bob

    BYW, have you tried to have 2 of these units connected at the same time and run 2 different apps to get the values? I did but couldn't open the second port, even forcing the port name and not searching for it. Little disappointed at that :(

    ReplyDelete
  6. Bob,

    Thank you for the device verification code. I've added it to the library and uploaded new version that should be completely independent.

    I also noticed that I had left a static keyword on the SerialPort object (which means every instance of the TEMPer communication class would share that single instance). This would certainly break things if you tried to use more than one class instance.

    Thanks for the code and feedback!

    ReplyDelete
  7. Hey Alex,

    I'm only getting values in .250 differences, the temper v6 gives more precision. What version did you decompile to generate your Bin2Dec function?

    I can send you on v6 if you like, I think v6 can go to .125?

    Regards,
    bob

    ReplyDelete
  8. Bob,

    I decompiled 6.2 to get the current version of the library.

    Here is the output I just created using the latest version of the library:

    000423 - 21.5000 C - 70.7000 F
    000424 - 21.6250 C - 70.9250 F
    000425 - 21.6250 C - 70.9250 F
    000426 - 21.6250 C - 70.9250 F
    000427 - 21.6250 C - 70.9250 F
    000428 - 21.6250 C - 70.9250 F
    000429 - 21.6250 C - 70.9250 F
    000430 - 21.7500 C - 71.1500 F
    000431 - 21.6250 C - 70.9250 F
    000432 - 21.6250 C - 70.9250 F
    000433 - 21.7500 C - 71.1500 F
    000434 - 21.7500 C - 71.1500 F
    000435 - 21.7500 C - 71.1500 F
    000436 - 21.7500 C - 71.1500 F
    000437 - 21.8750 C - 71.3750 F
    000438 - 21.8750 C - 71.3750 F
    000439 - 21.8750 C - 71.3750 F


    something to note: the 0.1250 precision is 'approximate'.. I've seen it be very inconsistent. Also, that precision is for the original Celsius value.. when you convert an imprecise Celsius value to Fahrenheit.. you'll be even more imprecise. Can you provide a bit more information to help me understand where the problem might be?

    Also, did you get a chance to try the new version of the library with multiple devices?

    ReplyDelete
  9. Hi Bob,

    I also have one of these devices, and I'm not happy with the software. I tried your routine to check whether Temper device is connected or not in a given port, and it worked perfectly. It take me just 5 minutes to get the code working. Thank you.

    I was wondering whether you can also share a working function (C++) to acctually read the thermometer and retrieve a temperature measurement. Initially, I prefer C++ code better than the DLL (Indeed, I was unable to link Arden dll to my project).

    I initially though that temper will be posting data continously, but it seems this is not the case. How the device actually work?. Should I sent to it a "data request"?. I would greatly appreciate if you can explain to me

    ReplyDelete
  10. I managed to get another TEMPer device and I verified that the second version of the DLL works perfectly fine with multiple devices. I'll update the sample and DLL (I made a few improvements) some time soon.

    ReplyDelete
  11. Hi,
    I'm looking for documentation about how to get the temperature from the device. I use Linux so Windows software is not usable to me. I can get the device to be recognised as a serial port (/dev/ttyUSB0) but I do not know what to write to the port the get the temperature and which speed the port should be set. Anyone who can help ?

    thanks,

    Michel

    ReplyDelete
  12. Michael,

    To communicate with the TEMPer device, I simply use the .NET SerialPort class (http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport.aspx), without changing any of the defaults. If you look at the members of that class (http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport.aspx), you should be able check the various defaults that might help you get up and running (http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport.baudrate.aspx).

    As far as what to send and when.. that's still all a black box to me. I wish it were as simple as polling the device for data.. but it's not.. there is a lot of switching DTR and RTS as well as the initial writing of a few mystery bytes.

    If you're fairly familiar with serial communications (which I'm actually not), the TEMPer.Communication.dll source might make sense to you. I've been meaning to put it up here in one form or another, so if it might be of interest to you, let me know and I'll make it available.

    ReplyDelete
  13. Made a little app for my tray. Thanks for the DLL Alex.

    http://www.brightblueplanet.com/temp/weatherio.jpg

    ReplyDelete
  14. I'm interested also in making this device work in linux, so if you could post the DLL source I'd be very appreciative!

    ReplyDelete
  15. Thank you very much for your library!

    Right now, there seems to be something weird because using your library in my own little program, I'm only getting .5 Celcius variations...

    Any idea?

    ReplyDelete
  16. Hi there,

    Does the current DLL works in .NET 2005 because i always get a very large value when I readTEMP (-1.797...E+308. Any ideas?

    Thx in advance

    ReplyDelete
  17. Greetings,

    To all of you who have asked for the source and/or *nix support.. please take a look above as I've provided a link to the TEMPer library source. While I have a fair amount of linux experience, I don't have the time (nor at present - the motivation) to port this over to linux... but that's not to say I don't fully support those of you who do!

    Anonymous user who asked about the large negative number:

    I use double.MinValue as my error state (mainly because it's well beyond any temp that TEMPer might ever be able to read). If you're getting this value, then I would suspect that you're either passing in the wrong port name or some other exception is happening inside that code (I didn't list "you don't have a device connected" as it has always annoyed me that people would even ask that). If you're using TEMPerInterface.FindDevices to grab your port name, I would suspect that there's some error happening within the TEMPer library. Download the source and either step through the code (possibly a waste of time) or turn on the Thrown exception handling in Visual Studio (Debug --> Exceptions --> check everything under the Thrown column --> OK) so you can see where things blow up.

    A quite note about my coding style (not that any of you really care): I hate exception driven code. I would much rather fail to check a return value and get strange data than watch my application crash in front of a customer.

    Customers don't mind hearing about bugs as much as they care about seeing them.

    Anyways, try debugging via the source and let me know how things turn out for you.

    ReplyDelete
  18. This comment has been removed by a blog administrator.

    ReplyDelete
  19. Hi,

    I am very new in using DLL functions in Delphi. Can anybody help me how to insert these DLL functions in a Delphi programm?

    I tried to initialize a test function by:

    function FindDevices: string; external DLLNAME;

    DLLNAME is the name of the TemperDLL.

    But when I tried to read the string by s:=FindDevices;, Delphi returns an error message... Can anybody provide some help? I would appriciate it very much, because I use vista 64 and Temper doesn't work with it. So I would like to write my own programm with the help of your DLL.

    Johannes

    ReplyDelete
  20. how can i do to call all functions from temper.communication.dll?
    I am newer and i don't know...
    I'll need all string, included all parameters to pass dll.

    Thanks...

    P.D.: sorry for my poor english

    ReplyDelete
  21. i only need know how read the temperature data in celsius.
    The declaration string my be in visual basic?

    Thanks..

    ReplyDelete
  22. SOrry, but i 'm desesperated. I need urgently know how use temper.communication.dll from visual basic 6 because own software of usbtemper is much limitations.

    ReplyDelete
  23. Great lib. Saves me a lot of time figuring out what's happening on that port. Thanks.

    ReplyDelete
  24. hi,
    try wtih:

    Public Class
    Dim aComPort$() = TEMPer.Communication.TEMPerInterface.FindDevices()
    Dim ti As New TEMPer.Communication.TEMPerInterface(aComPort$(0))



    and for read temp:
    ti.ReadTEMP()

    ReplyDelete
  25. thank you for your effords but this don't work in visual basic 6.
    I'll have to try another options.

    THank you very much

    ReplyDelete
  26. Thanks for the software. What I am curious about is the device itself.

    I would like to leave the device on my dining room table while I am at work and come back later and find out what the temperature was in the dining room during the day.

    Does this device log temperatures when not attached to a PC?

    Thanks

    ReplyDelete
  27. The TEMPer device doesn't do any internal loggging. Coding a logging app would take 10 minutes at most.. but of course does requires the device to be attached to a computer.

    ReplyDelete
  28. Guys,, you've helped no end.
    saved me a lot of time, having to decompile.
    cheers
    D

    ReplyDelete
  29. This rocks. Got it all up and running in no time at all, and dare I say it the application I have written works better than what came with the device! :-)

    ReplyDelete
  30. Hi
    Thanks for posting this...its exactly what I need. But it doesnt seem to be working for me :-(

    The code recognises the correct COM port (COM3) but the readings are:

    000049 - COM3 - -1797693134862320000000000000000000000000000
    00000000000000000000000000000000000000000000000000000000000000000000000000000000
    00000000000000000000000000000000000000000000000000000000000000000000000000000000
    00000000000000000000000000000000000000000000000000000000000000000000000000000000
    00000000000000000000000000.0000 C - -Infinity F

    Have you seen this before?

    Thanks
    N

    ReplyDelete
  31. Hi

    I have a slightly different model, the TEMPer HUM , Temperature and Humidity, this code doesnt work with this model, does anyone have
    an update.

    I was really pleased to find this code, I'll see if I can get it working for the TEMPer HUM

    Thanks

    ReplyDelete
  32. I got the TEMPer HUM working with C#, I can upload the code if anyone needs it.

    000043 - COM2 - 22.99 C - 51.972662 rH - 18.5875997989333 dewPoint
    000044 - COM2 - 22.93 C - 51.9647228 rH - 18.5299630333391 dewPoint
    000045 - COM2 - 22.71 C - 52.0646652 rH - 18.3582115702814 dewPoint
    000046 - COM2 - 22.77 C - 52.0080988 rH - 18.3960801616906 dewPoint
    000047 - COM2 - 22.69 C - 52.0620124 rH - 18.3389945237084 dewPoint
    000048 - COM2 - 22.63 C - 51.9895516 rH - 18.2615814559304 dewPoint
    000049 - COM2 - 22.79 C - 51.81703 rH - 18.3557660372284 dewPoint
    000050 - COM2 - 22.77 C - 51.81439 rH - 18.3365604580002 dewPoint
    000051 - COM2 - 22.63 C - 51.8604796 rH - 18.2219714640152 dewPoint
    000052 - COM2 - 22.65 C - 51.8631228 rH - 18.2411794086644 dewPoint
    000053 - COM2 - 22.63 C - 51.79591 rH - 18.202123766002 dewPoint

    ReplyDelete
    Replies
    1. Please email me the project code. I am using Visual Studio 2010. My email is tayyab@siswa.um.edu.my

      Delete
  33. Nice work. I'm glad to hear you were able to modify the library for your needs. If you'd like to send me the code, I'd me more than happy to post it here.

    ReplyDelete
  34. Hi
    I dont think your email address is public....but I uploaded the C# Source Code for TEMPerHum to here

    Had to decompile it again, it changed quite a bit for Temperature and Humidity.

    Your Blog did help out a lot so thanks for posting, glad that I can share this back with you in return.

    Output:
    COM2 - 19.99 C - 58.37 rH - 11.58 dewPoint - 19.07 minT - 19.99 maxT
    COM2 - 20.17 C - 58.15 rH - 11.69 dewPoint - 19.07 minT - 20.17 maxT
    COM2 - 20.57 C - 57.78 rH - 11.96 dewPoint - 19.07 minT - 20.57 maxT
    COM2 - 20.39 C - 57.38 rH - 11.69 dewPoint - 19.07 minT - 20.57 maxT
    COM2 - 20.43 C - 57.07 rH - 11.65 dewPoint - 19.07 minT - 20.57 maxT
    COM2 - 20.59 C - 56.84 rH - 11.74 dewPoint - 19.07 minT - 20.59 maxT
    COM2 - 20.61 C - 56.66 rH - 11.71 dewPoint - 19.07 minT - 20.61 maxT
    COM2 - 20.61 C - 56.54 rH - 11.67 dewPoint - 19.07 minT - 20.61 maxT


    :-)

    ReplyDelete
  35. Being that I'm not entirely familiar with using DLL in VB 2008, I'm having difficulty with this.

    I've added the DLL, but when I run the program I get an exception error telling me that the file cannot be found, yet it finds the methods.

    Can anyone point me in the right direction? Does anyone have any VB source working that I might borrow to see how it all fits together?

    Thanks.

    ReplyDelete
  36. Does anybody have the TEMPer Hum working on Vista x64?

    ReplyDelete
  37. Does your source compile in linux? Could you post it?

    ReplyDelete
  38. I have the TEMPerNTC (internal/external temperature). Does anyone have sample code that will work with this device (TEMPerHUM does not). The version is 2.7.

    Thanks!

    ReplyDelete
  39. Hello tout le monde

    I'm also looking for a working dll for the inner/outer TemperNtc.
    I promise that i will post all my source code when all will be done.
    Thanks for help
    Patrick Sody

    ReplyDelete
  40. Hello i asked the manufactur for the TemperNtc and he give me the dll and also a programm written in c# but i only work with vb. Is somebody able to make a dll for vb, i can send all the information. sodyprof@swing.be
    Thanks
    Patrick sody

    ReplyDelete
  41. Got this working yesterday with the old Communication.dll (got TEMPerNTC with v2.7 of the original software)

    My problem now is that when I plugged the TEMPer-unit back in today, I get false readings...

    Anyone know how to "reset" the unit, or calibrate it?

    I'm also interested in any type of code/dll also giving me the reading of in/out temp and humidity. All I got now is the inside-temp.

    ReplyDelete
  42. I also have the TEMPerNTC version and it doesnt work for me. Anyone have a solution? It is getting some response tho...

    with the follow code in VB:

    Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim aComPort$() = TEMPer.Communication.TEMPerInterface.FindDevices()
    Dim ti As New TEMPer.Communication.TEMPerInterface(aComPort$(0))


    MsgBox(ti.ReadTEMP())


    End Class

    I get the value of: -1,79769313486232E+308

    I really need this to work... Anyone have any idea?

    ReplyDelete
  43. Thats just the first reading from the unit.. try using READtemp more than once.. should give you other results.

    My problem is not that it's not reading the temps, cause it does, but the unit itself is getting HOT, and the temp-reading goes to 38 degrees celcius (and something...)

    The outside temp says -38 degrees (and something...) even if the outside sensor sits 2cm away from the inside sensor on my table....

    So something is clearly wrong, but at least I get some readings..

    ReplyDelete
  44. Can anyone upload a .exe file that reads the TEMPerNTC and outputs values? The supplied software crashes for me.

    ReplyDelete
  45. Hi All,

    Chenmer sent me the dll for communicating with the TEMPerNTC.
    I've written a small application to read the data in VB.NET 2008.

    You can download it here :

    http://www.dstartv.com/temper.zip

    It includes the full source code (and dll's required)

    Regards

    John

    gm7hhb at dstartv.com

    ReplyDelete
  46. Hello!

    I have TEMPerNTC for monitor Temperatures DataCenter. The original software don't work. Not save configs and don't sending e-mails only over-limit.

    Version is TEMPerNTC 3.1

    Please. I need monitor for e-mail if over-limit is high.

    Thanks Advanced...

    ReplyDelete
  47. @John

    Thanks for your program! It works great. The only problem I have now that I want to be able to use 3 sensors....

    With the above code you can select a comport, so its quite easy to select a sensor. But I cant seem to figure out how to get the same result with your code.

    Could you, or anyone else help me?

    ReplyDelete
  48. Hi,
    i use visual studio 2005 and c#.
    I have included in my project last dll TEMPer comunication.
    When i read temp with TEMPer producer software all is ok(temperature is readed correctly)

    when I readTEMP with my application(on port com18) double resulted from device.readTemp()is(-1.797...E+308).
    Port com is readed correctly from my program,but the double resulted is -1.797...E+308.......please help me.
    Tnx

    ReplyDelete
  49. Hi,
    Just to let you know I got your code working really quickly. The only problem was the TEMPer application was already running and that was preventing access to the COM port. Once I stopped that, I got the results as expected.
    Thanks for a well written project. Its not every code download that works straight away.

    Lens

    ReplyDelete
  50. Anyone who has working code for linux?

    ReplyDelete
  51. Hi Jen,

    You might try checking the comments on the original thread where the TEMPer library discussion started (http://funponsel.com/blog/hardware-and-peripheral/temper-usb-thermometer-for-laboratorians.html). I know there have been one or two linux solutions posted that work for some but not for everyone (because of kernel compatability most likely). Either way, I'm sorry I couldn't provide more information. Good luck.

    ReplyDelete
  52. Ok so the drivers that came with the thermometer blue screen my system everytime any program (bundled or one built on this DLL). Have you encountered this? I guess I'm pretty much screwed if their driver doesn't work for me, eh?

    TIA

    ReplyDelete
  53. shaun-a-m,

    The bundled DLL and the one attached to this post share common functionality in that they both talk directly to the USB device via a pseudo serial port. If you're computer blue screens when this happens, there's not a whole lot anyone (in the development community) can do for you until you have fixed that issue.

    Sorry I couldn't provide more insight.

    ReplyDelete
  54. Yeah, I had a feeling. It's definitely a driver issue. It seems to work if I uninstall the device driver, plug the unit into a different USB slot, reinstall the driver and then launch the program. If I close the program, the whole process needs to be repeated :P Funtimes with drivers in Windows.

    Thanks :)

    ReplyDelete
  55. Hello!

    I am using the TEMPerNTC with indoor and outdoor temperature.
    After a while of using the outdoor temperature is 1000. Which is wrong.
    A program restart or pc restart do not fix the problem. After a while the temperature gets okay again.

    Is this problem recognized by someone else?

    BR

    ReplyDelete
  56. Hi!

    I have developed a simple C code that reads TEMPer (only 12 bit: -40ºC~+120ºC) using exclusively kernel32 functions: EscapeCommFunction and GetCommModemStatus. You don't need to link to any DLL, you don't need to have .net runtime installed. So far, you have to manually select the port where TEMPer is installed. A problem is that know is a bit mixed: english and spanish, but not big deal. I think the code is self-explained. It works in winxp with both the winchiphead and the usbrdxp drivers, I tested. I would appreciate feedback:
    jmortizz At fis Dot ucm dOt es

    For download:
    http://pc8-termo.fis.ucm.es/~josechu/mitemper.zip

    BTW: Mi compiler is visual c++ 6.0, but the code should work with any other: Borland or even freeware

    ReplyDelete
  57. I need help please. I am having trouble compiling it. It just simply would not compile. It spits out two errors:
    1). The type or namespace name 'CompilerServices' does not exist in the namespace 'Microsoft.VisualBasic' (are you missing an assembly reference?)
    2). The name 'Strings' does not exist in the current context
    I am doing it in VS2008 C#. Anybody has any ideas please?

    ReplyDelete
  58. I have working source code I wrote in vb6. it works with the 2.x version of the temper device. I'm not sure what is different in 1.x or the temperhum. email me if you'd like some of my code matt at mattsoft dot net

    ReplyDelete
  59. Thank you Jose, from your source I was able to port it to Delphi 7. I still don't know how to read the external sensor, but the internal one is reading fine.

    Anyone have information on how to read the external sensor?

    ReplyDelete
  60. EXCELLENT! Many many thanks for this. Worked perfectly with VS 2008.

    ReplyDelete
  61. **Anyone have information on how to read the external sensor?**

    Heres a working, open source, project that supports the NTC's external sensor. Written in C#, but should give people the basic idea of how it works.
    http://www.alsgh.com/utac/

    ReplyDelete
  62. Linux Python Source for the TemperNTC (both internal and external sensor) can be found here:
    http://duskeren.dk/nyheder/temperntc-p-linux
    Page is in danish, but the source is in the buttom of the page. Default reads internal sensor, can be changed to read external. Both sensors needs to be calibrated.

    ReplyDelete
  63. Anybody got any of these devices working on Windows 7 64-bit?

    I have the TEMPer Hum but it _appears_ that it only comes with a 32-bit driver and not a 64-bit driver. Thus, when I plug in the device and run C#TEMPerHum (thanks Levanter30 for the post), it fails the CreateFile call in the CheckCOMPort function with an invalid file handle of -1. In Device Manager, I see the device yellow-banged-out with a name of "USB-SER!".

    ReplyDelete
  64. I'm try to implement dll in VS 2008 and I had a problem when run application can't find any device, my SO is W7 64bit... somebody can help me?

    ReplyDelete
  65. Perhaps this is too much to ask, but is there anyway I can get this to work with a java app?

    ReplyDelete
  66. I was really pleased to find this code.Thanks

    ReplyDelete
  67. I've been unable to get this to work in my environment, using this exact method.

    Whatever I do, ComPorts.Length is always returns 0 (Zero).

    I'm using .Net v4, VS 2010, and Windows 7 (32-bit).

    The HID TEMPer application that ships on the CD-ROM works just fine.....

    Anyone with the same problems?

    Sample code - that didn't work:

    using System;
    using System.Windows.Forms;
    using TEMPer.Communication;

    namespace PCTemperWindows
    {
    public partial class TempForm : Form
    {
    int i;
    String[] ComPorts;
    TEMPerInterface[] Devices;

    public TempForm()
    {
    InitializeComponent();
    ComPorts = TEMPerInterface.FindDevices();

    Devices = new TEMPerInterface[ComPorts.Length];

    for (i = 0; i < ComPorts.Length; i++)
    Devices[i] = new TEMPerInterface(ComPorts[i]);
    }

    private void GetTemp_Click(object sender, EventArgs e)
    {
    if (ComPorts.Length==0)
    {
    MessageBox.Show("No Units detected!");
    return;
    }
    Tempbox.Text = Devices[0].ReadTEMP().ToString();
    }
    }
    }

    ReplyDelete
  68. Hi Anonymous,

    I haven't touched this code in a while (especially since the newer TEMPer devices seemed to be a bit unreliable and problematic) but if you're having issues accessing your COM ports, I'd try this:

    1. Close Visual Studio
    2. Right click on your Visual Studio shortcut and click 'Run as administrator'
    3. Try the code again

    Under Vista, Windows 7 and Windows 2008 (all of which now have UAC), Visual Studio will not necessarily have full access to your system's hardware. As opposed to disabling UAC, try the run as administrator trick.

    Good luck.

    ReplyDelete
  69. Hello,

    I have also the same problem... ComPorts.Length returns Zero.

    I ran it with full access but without success.

    OS: Windows 7 64-bit

    ReplyDelete
  70. I have the original (gray) TEMPer on windows 7 x64 and it doesn't work. Tried compatibility modes and run as administrator.

    ReplyDelete
  71. Ok. This library did not work for me under Windows 7 x64 using my recently-purchased TEMPer1 USB thermometer. Apparently other people are having the same issue.

    So, I decompiled the software from the included CD and have written a very dramatically simple library to access the TEMPer.

    I've already posted an initial version of this on my website (yes - the rest of the website is unrelated). I intend to improve, polish, and test this library in the upcoming days and weeks, and I will post updates there (I will not be checking the comments on this blog).

    Here is the URL where I have posted the library: http://minecraftam.com/TEMPer.aspx

    ReplyDelete
  72. Hi, please does anybody know, how to get values from HID TEMPerHUM, at the best in MS Visual C#?

    PedroKV

    ReplyDelete
  73. Did anyone get this working Win7 x64 yet (the driver)?

    ReplyDelete
  74. Who knows where to find information on how to communicate with the current TEMPer device (2.22) in Delphi?

    ReplyDelete
  75. Does the library work with Temper version 2?

    ReplyDelete
  76. I dont get this work for me - "No Units detected" - the dll searches for com-ports but the device connected to usb ? i dont understand - do i have to map the usb internally to a com port ?
    Thanx Cashi

    ReplyDelete
  77. same issue as above posts, I am using a TEMPerNTC... maybe the library doesn't support it?

    ReplyDelete
  78. "Who knows where to find information on how to communicate with the current TEMPer device (2.22) in Delphi?"

    I have written a DLL that can be used with Delphi. It works with the recent version of TEMPer. It is only 41 KB and you don't need other support files. Try it yourself:

    http://www.homesecuritysoftware.nl/Delphi/TEMPerDll.zip

    ReplyDelete
  79. In the meantime I have also created a DLL that works with the current version of TEMPerHUM.
    It is only 42 KB and you don't need other support files.

    http://www.homesecuritysoftware.nl/Delphi/TEMPerHumDll.zip

    ReplyDelete
  80. I have just got the TEMPer, but it does not work with the TEMPerHumDll.zip or the TEMPerDLL.zip :-(
    When try reading, I only get "No sensor" and "Plugin USB sensor". Reading temp or humidity results in "-200.00"
    It would have been nice to get this working!
    How do I behave to get rid of the nag-screen?

    ReplyDelete
  81. Hi again!
    Sorry for reporting that both dlls were not working. This is not correct, as the TEMPerDll works nice, but the TEMPerHumDll is not working. I'm not sure, but it's possible that the TEMPerHumDll is only working on the Temp/Hum unit and not on the Temp only unit. Anyway, I'm well satisfied to get the TEMPer working!

    ReplyDelete
  82. TEMPerDll = for TEMPer
    TEMPerHumDll = for TEMPerHum!

    The PIDs (Product IDs) are different, so this is the reason that the device is not recognised.

    If you want to get rid of the nag screen, drop me a line. The mail address is shown in the window that you see after initializing the DLL routines.

    By the way: http://www.homesecuritysoftware.nl/Delphi/TEMPerHumDll1.zip is a DLL that works with both TEMPer AND TEMPerHum. A demo (source and exe) is included.

    ReplyDelete
  83. Just released a new DLL (version 1.1) that supports the following TEMPer devices:

    - Temper (internal temperature sensor)
    - Temper1 (external temperature sensor)
    - Temper2 (internal and external temperature sensor)
    - TemperNTC II (internal and two external temperature sensors)
    - TemperHum (temperature and humidity sensor)

    The DLL can be used with the current devices that work with Rding32USB.dll.
    Older versions that use HidFTDll.dll are NOT supported!
    The DLL size is 45 KB and you don't need other support files. (Rding32USB.dll is not needed for your own applications!)
    You can download the file from

    http://www.homesecuritysoftware.nl/Delphi/TemperHumDll2.zip.

    File size is 245 KB. Examples in Delphi and VB6 are included. (Source and .exe) Happy programming!.

    ReplyDelete
  84. Just released a new DLL (version 1.1) that supports the following TEMPer devices:

    - Temper (internal temperature sensor)
    - Temper1 (external temperature sensor)
    - Temper2 (internal and external temperature sensor)
    - TemperNTC II (internal and two external temperature sensors)
    - TemperHum (temperature and humidity sensor)

    The DLL can be used with the current devices that work with Rding32USB.dll.
    Older versions that use HidFTDll.dll are NOT supported!
    The DLL size is 45 KB and you don't need other support files. (Rding32.dll is not needed for your own applications!)
    You can download the file from this location:

    http://www.homesecuritysoftware.nl/Delphi/TemperHumDll2.zip

    File size is 245 KB. Examples in Delphi and VB6 are included. (Source and .exe) Happy programming!

    ReplyDelete
    Replies
    1. I have a 2 Temper1 devices and I am trying to integrate them into my python program, will your .dll work with any language?

      Delete
  85. The DLL will work with all programming languages that support the 'stdcall' calling convention for DLL's. You can try it yourself!

    Just released version 1.3 of the DLL.
    New features:
    - Support for Temper_1K2 thermocouple
    - Improved support for multiple devices in a single application
    - Temperature returned for TemperHum was incorrect, fixed
    - Some small fixes
    - New 'simple' demo added

    Try it yourself: http://www.homesecuritysoftware.nl/Delphi/TemperHumDll3.zip
    (Filesize 820 KB)

    ReplyDelete
  86. Just added a new demo application: a logger for multiple TEMPer devices.
    Selectable intervals, can measure in Celcius and Fahrenheit.
    Source (in Delphi and VB6) is included.
    Try it yourself: http://www.homesecuritysoftware.nl/Delphi/TemperHumDll3.zip

    ReplyDelete
  87. HELP PLEASE!!

    My Device is TEMPER1 and i downloaded the source code.. but when i run the program, it can't detect the ComPort! please help..

    ReplyDelete
  88. I just downloaded your DLL and included it in a Real Basic program.

    As soon as I call the InitTemper function I get the following message:

    Can not initialize!
    Demo time is expired.

    Please contact:

    xxxxxxxxxx (your email)

    to get the full version.

    --------------------------------------

    It's the first time I install your software on my computer and the demo is already expired! Not very useful for testing!

    So, is there an alternative to test your library?

    Thanks

    ReplyDelete
  89. How to communicate or get temperature readings from the TEMPer1 using VB.Net

    I found that if I downloaded the HIDLibrary from Mike O'Brien

    https://github.com/mikeobrien/HidLibrary

    on the above page there is a link to the zip file:

    https://github.com/mikeobrien/HidLibrary/archive/master.zip

    In this zip file you will find a Visual Studio C# project called:

    HidLibrary.csproj

    You'll want to include this project in your Visual Studio solution. Make your VB.Net project dependent on this HIDLibrary project.

    Right click on your project in Solution Explorer and choose Project Dependencies... On the Dependencies tab check the HIDLibrary checkbox.

    Also set a reference in your VB.Net project to HIDLibrary
    Right click on your project in Solution Explorer and choose Add Reference... On the Projects tab click on HIDLibrary.

    Put this line of code at the top of your .vb file:

    Imports HidLibrary

    Use the following code to find the TEMPer1:
    Dim TempPerDevice As HidDevice
    Dim devices As System.Collections.Generic.IEnumerable(Of HidLibrary.HidDevice) = HidDevices.Enumerate(&HC45, &H7401)
    Dim deviceCounter As Integer = 0
    For Each TempPerDevice In devices
    deviceCounter += 1
    Next
    If deviceCounter < 2 Then
    status &= ", no TEMPer1"
    End If
    Here's the function to read temperature from the TEMPer1 you discovered above:

    Function getTempFromTEMPer() As Single
    TempPerDevice.Write({&H0, &H1, &H80, &H33, 1, 0, 0, 0, 0})
    Dim hdd As HidDeviceData = TempPerDevice.Read()
    getTempFromTEMPer = 0
    If hdd.Status = HidDeviceData.ReadStatus.Success Then
    getTempFromTEMPer = (((hdd.Data(3) * 16) + (hdd.Data(4) / 16)) * 0.1125) + 32
    End If
    TempPerDevice.CloseDevice()
    End Function

    ReplyDelete
    Replies
    1. using your example and got it running by add reference (add dll) then import that ref. having trouble in choosing the temp probe / device when more than one device attached. i tried changing the line: getTempFromTEMPer = 0, getTempFromTEMPer = 1, ect but didnt work
      any sugestions?

      Delete
    2. Thank you. Worked perfectly in Win 8.1 & VS 2010. You are appreciated.

      Delete
  90. "It's the first time I install your software on my computer and the demo is already expired! Not very useful for testing!"

    The ONLY reason that you can get this message, is that you have installed our application before, or that you have modified settings in the Windows registry manually. In fact you are the only person who has experienced this 'problem'.

    In the meantime a new version of the TemperHumDLL (1.5) has been released.
    It contains some small bugfixes (better compatibility with VB, measurement result for TEMPer(Gold) sensors below 0 degrees C. corrected)
    Also there are 4 new routines: TemperGetAllIDs, TemperSetDeviceByIndex, TemperCount and TemperReset.
    You can download the evaluation version here:

    http://www.homesecuritysoftware.nl/Delphi/TemperHumDll5.zip

    (And yes, also people who evaluated an earlier version can use it! ;) )





    ReplyDelete
  91. Hello I'm interesting to buy your dll/software and I try to contact you by mail, but I received only Mail delivery service; could you fix your email problem?

    Thanks

    ReplyDelete
  92. New download location: http://www.vansteenissoftware.nl/Delphi/TemperHumDll5.zip

    ReplyDelete
    Replies
    1. Hi, Avast! antivirus blocked this download, it claims that the file "Project1.exe" has infected by "Win32:Evo-gen".

      Delete
    2. Sorry for that other message, after some googling it appears like an "Avast! false positive":

      https://www.virustotal.com/pt/url/9e575be96e3ee1c2da58c36304e73986ed63b87522cd603450fe97ba54453135/analysis/1365349194/

      Delete
  93. Hi.
    Tried this code, but it does not find my device. It is the TEMPer1 usb device. Can anyone point me in the right direction?

    ReplyDelete
  94. Hi Boblehai

    Take a look at my message above, dated May 6, 2009 at 4:04 AM

    Jose

    ReplyDelete