Skip navigation

I haven’t written here in a while, but that’s mostly because I haven’t done much with the code for a while, at least not much worth writing about – recently though (about 4 days ago by now), there’s been quite a few changes, that are big enough I feel I should mention them.

First off, I realized that I’ve been conflating two things – I’ve basically been thinking of the tempered program as an example program, but at the same time wanted it to be a useful utility. These things came to a head when I started wanting to add some more complex features (well, complex for example code anyway), yet wanted to keep it simple so people could use its code as an example. I decided that my best bet would be to split it out into separate programs, one useful utility and one or more examples.

So, I’ve now done this – wrote a few examples (mostly by copy-paste) in their own subdir, and added some features to the utility (including a proper options parser).

One of the first features added was the ability to just enumerate the found devices, without reading them – which allowed me to move the enumerate program to the examples dir, and remove it from the list of programs being installed. (I never really liked the name “enumerate” for an installed program, as it’s a bit too generic.)

Next up was the ability to show temperatures in different scales than Celcius – most importantly Fahrenheit, but also Kelvin and a couple others, in a way that should be easy to extend with new scales later, as necessary.

After that came calibration – the ability to adjust the measured temperature before displaying it. I think the way this was implemented makes it both easy to use for simple cases, and flexible enough for most of the more complex ones, but admit I can’t really know yet since it hasn’t seen much use yet (that I know of). For more information about this, see the wiki, where I’ve posted some information including examples.

Both of these latter features were put into a new utility library, along with some supporting code, that the tempered program then uses – as I figured they are features likely to be wanted by other programs using libtempered as well, but do not really belong in libtempered itself. Hence, libtempered-util was born.

The dew point calculation function was also moved to this new library, as it is similarly likely to be wanted by other programs – and I’ll probably add more later, when I come up with other similar features to add.

Come to think of it, I should probably update the readme file, and maybe add some examples for the util lib… Maybe add a readme for the examples… *adds to his TODO list*

Advertisements

14 Comments

  1. Hi,
    Many thanks for the work you and others have put into this.
    I ordered one recently from Tomtop and it is identified as a temper2v1.3 id is still 0C45:7401
    I’m using pcsensor 1.0.1 and it works. As I’m not that proficient at coding I compiled two versions of the code to read the internal and external sensors. This is running on a RaspberryPi so CPAN is not so good just yet.
    First output http://www.daisypie.com/rrd/

  2. I have the DX.com device 0c45:7402 and it works great on a Linux PC using your code. However, I want it to work with a RaspberryPi and I spent 12+ hours without success. The second post in this thread http://www.raspberrypi.org/phpBB3/viewtopic.php?f=37&t=19232 seems to refer to your project, but I can’t figure out how to make the change he’s calling for. Any help appreciated.

    • Assuming that what rtufty says works (seems odd that hidraw doesn’t, but I guess it’s a platform or version issue), there are two things you need to do.

      First, you have to compile the libusb variant of hidapi.

      Now, hidapi has changed their build system since I last looked much at it (time issues on my end), so I’m not 100% positive of how to do this using the current git master, but I think simply building and installing what’s in the libusb subdir should work. (You may have to install libusb-1.0-dev for this.)

      You shouldn’t need the parts in the linux subdir, as that’s the hidraw variant.

      Then, you need to configure tempered to use the libusb variant of hidapi instead of the hidraw variant.

      If only the libusb variant is available (built/installed), tempered’s build system should select it automatically, but if it doesn’t (or both are available), you can explicitly tell cmake to use it (and, if necessary, where to find it).

  3. Hello EdorFaus, and thanks for all the effort you’ve made to make these little gadgets more useful to the world. I’m hoping to use them for data logging in greenhouses, to help build a baseline of energy consumption, in order to help greenhouse owners make energy efficiency improvements. I’m not an engineer, though, as evidenced by my first mistake: I bought a bunch of the HID TEMPerHumiV1.1 devices without noticing they cannot run independently of a USB port. Duh. I really thought I’d found a cheap solution to temp data logging.

    Anyway, so now I’m reading like mad to figure out how to build an arduino or raspberry pi data logger using this device.

    That aside, from reading this blog I can’t really tell if you are still seeking additional samples of the TEMPer devices. If you are, I’d be pleased to send you a TEMPerHumiV1.1. (It’s the blue one, and I bought it from Chinavasion: http://www.chinavasion.com/b4w7/ ) I’ve got a bunch of them, and they’re all useless to me until I figure out the data logger. At least I’d know it would be in good hands with you, and a small token of my appreciation.

    Drop me an email if you’d like one.

    Thanks again for all your efforts!

    • Hi John,

      You’re welcome. 🙂 That sounds like a neat application of the sensors (though beware of calibration issues).

      I’ve not really looked that much at Arduino, and don’t have an RPi of my own, but from what I remember, the RPi might be the easiest of the two in this case – I believe some people have already gotten tempered to work on the RPi.

      However, with the RPi (and probably the Arduino as well), I figure that what you need for a data logger is probably just the sensor, the computer, a power source (maybe battery), and some software. For your use case you may also want a case, to avoid getting water on the device – but that depends more on the particulars of how you set it up, and you probably don’t want to enclose the sensor too much.

      Now, you already have the sensors, and the RPi is a ready-to-use computer (including storage for the data, I think), so that leaves the software and the power source (which mostly just depends on how/where you hope to place them – if AC is available, normal RPi-compatible power plugs would work, otherwise you’ll want a battery pack).

      With tempered, you already have code that can read the sensors, which leaves the logging aspect. Depending on how you want that to work, it can be as simple as running the read-repeat example (piping the output to a file), or a full solution with graphing and everything (I seem to recall the name “cactus” being related to that) – or something in between. If you know a little bit of programming, you could probably adapt the code to fit your use even better.

      You may want to take a look at rrdtool for this, even if you don’t end up using the tool itself, the format it uses might be useful to you (depending on the kind of data you need).

      As for the device sample, I’m definitely interested in samples of devices I don’t already have. In this case I suspect I might already have one though (or at least one with the same electronics, which is the important part for this). It’s a bit hard to tell, since that page doesn’t really give all the relevant details (shop pages very rarely do).

      If you run “tempered -e”, what does it recognize the device as? If it says it’s a TEMPer2HumiV1.x with USB IDs 0C45:7402, then I already have one (well, the Gold variant, but that’s close enough).

      Either way, thank you for offering!

  4. I also have the 0c45:7402 device and have successfully made it work on raspberry pi.
    What EdorFaus wrote works.

    Try this (it’s from memory, but this should do it)

    1. mkdir ~/git
    2. cd ~/git
    3. git clone git://github.com/signal11/hidapi.git
    4. cd hidapi
    5. apt-get install libudev-dev libusb-1.0.0-dev libfox-1.6-dev autoconf cmake
    6. ./bootstrap
    7. ./configure
    8. cd libusb
    9. make
    10. make install
    11. cd ~/git
    12. git clone git://github.com/edorfaus/TEMPered.git
    13. cd TEMPered
    14. mkdir build
    15. cd build
    16. cmake ..
    17. make
    18. cd utils
    19. sudo ./tempered
    20. sudo make install

    I also tried installing it (# 20), but when running it cannot find the shared libraries.
    Solved it by issuing:

    1. ln -s /usr/local/lib/arm-linux-gnueabihf/libtempered.so.0 /usr/lib/
    2. ln -s /usr/local/lib/arm-linux-gnueabihf/libtempered-util.so.0 /usr/lib/
    3. ln -s /usr/local/lib/libhidapi-libusb.so.0 /usr/lib/

    What did I miss?

    • Thank you for the clear step-by-step instructions! (though I think you may have skipped step “19.5. cd ..” – but I think you could instead drop 18 and replace 19 with “sudo ./utils/tempered”).

      Judging by the links that fixed it, it appears that your system doesn’t include /usr/local/lib in the library loading path (see /etc/ld.so.conf{,.d/*} ). Or maybe you just have to run ldconfig before it finds the new libraries?

      I’ll admit I haven’t really tried the install bits of the build system myself, as I’m a bit too fond of keeping my system clean (using apt/dpkg for all installed software), so I don’t really know how well it works. I should really set up a VM to test that stuff in sometime soon…

    • Thanks for the installation steps. My TEMPerHumiV1.1 is now working on my pi:)
      For info, I had to install “libtool” before step 6 to get it working. (sudo aptitude install libtool)

      • Very helpful. Running ldconfig does solve the lib not found issue, fwiw.

      • Yeah guys, you’re wonderful! I just got my little TEMPer2 V1.4 running! Yes! Thanks eg1l for your detailed solutions, and also thanks jorgen for the hint with libtool. And of course EdorFaus for your work!
        I am running a Ubuntu 12.04.2 with 3.2.0-41-generic-pae. dmesg says I have a “RDing TEMPer2V1.4” with the ID “0c45:7401”. That is, when running tempered, I got this:
        0003:0002:01 0: temperature 28.50 °C
        0003:0002:01 1: temperature 23.00 °C
        YES! So if your project is still alive, you can add this sensor to be correct implemented!
        Now I can update my scripts in order to feed MRTG 😉

  5. Well, the pi has /usr/local/lib as default library path.
    Adding /usr/local/lib/arm-linux-gnueabihf to /etc/ld.so.conf.d/libc.conf and running ldconfig is one way to solve it 🙂

    • Aaah, right… I didn’t notice that path element I guess. Judging by the additional info, that third symlink was unnecessary. 🙂

      I think your problem is simply an artifact of Debian’s multiarch support, which apparently is not quite done completely enough. I took a look at Raspbian’s root image (2012-12-16-wheezy), and noticed that ld.so.conf** includes [/usr]/lib/arm-linux-gnueabihf and /usr/local/lib but, as you say, not /usr/local/lib/arm-linux-gnueabihf – which seems incomplete to me.

      CMake, meanwhile, apparently does things like the docs say it should, and puts the libs in the prefix/lib/target directory, which here means the /usr/local/lib/arm-linux-gnueabihf directory where you found them.

      In my opinion, the correct fix is to add that directory to /etc/ld.so.conf.d/arm-linux-gnueabihf.conf (and the equivalent dir to all other arch’s files) – and that should, IMO, be done upstream in Debian.

  6. Noob question: Can I run “Tempered -e” on a mac (OSX) or PC (Win Vista)?

    • Well, if you can get it to build/compile on that platform, I don’t really see why not… One of the reasons I chose HIDAPI and CMake is that they’re supposed to be cross-platform, and I don’t think I’ve used any platform-specific things in my code… I’ve been trying to keep things cross-platform, especially in the library, but also in the programs.

      I’ve never actually tried it on those platforms though, so I don’t really know if it works, or which build environment (compiler etc) you’ll need to have (in addition to CMake). If you do try it, please let me know how it goes!

      Also, even if you can’t get tempered itself to compile, you might still be able to get some of the examples to compile, since they’re simpler. (Assuming you can get libtempered and HIDAPI to compile.)

      (By the way, I’m glad you specified in the parenthesis – because that’s kind of one of my pet peeves there. All of my (desk/laptop) PCs run various Linux distros, yet most people seem to equate “PC” with Windows…)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: