Saturday, September 25, 2010

How to combine Munin and TEMPer (USB Temperature Sensor) ?

Long long ago I always wrote about technical stuff in my computer experience.
It's about time to write something on that topic again and the story is about Munin (example) and TEMPer (USB Temperature Sensor).



I decided that I want to keep an eye on the room's temperature and I searched for the cheapest possible external (USB) Termal Sensor. That's how I get hands on one of these TEMPer termal sensors.
It turns out that the sensor is great for the job except it's installation under linux (Ubuntu) in my case.

So here are the steps for installing it under Ubuntu and adding a patched "sensors_" plugin for Munin.

First you need to install "temper_mon.pl"

1) sudo apt-get install libusb-dev
2) sudo cpan -fi ExtUtils::MakeMaker
3) sudo cpan -fi Inline::MakeMaker
4) sudo cpan -fi Device::USB
5) sudo cpan -fi Device::USB::PCSensor::HidTEMPer
6) wget -O temper_mon.pl http://www.svilen.com/temper_mon.pl.txt
(alternative: wget -O temper_mon.pl http://www.cs.unc.edu/~hays/dev/bash/temper/temper_mon.pl)

7) chmod a+x temper_mon.pl
8) run: sudo ./temper_mon.pl
(you should see temperature readings now)

9) sudo cp ./temper_mon.pl /usr/bin/
(this is needed for the Munin plugin)

10) sudo wget -O /etc/udev/rules.d/99-tempsensor.rules http://www.svilen.com/99-tempsensor.rules

or create file: /etc/udev/rules.d/99-tempsensor.rules
with this line inside:
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1130", ATTRS{idProduct}=="660c", MODE="666"

11) sudo /etc/init.d/udev restart

Now you should have fully running "temper_mon.pl" script which will give you readings from the USB Temper device.

Next step is to backup and replace Munin's "sensors_" plugin in /usr/share/munin/plugins

1) sudo mv /usr/share/munin/plugins/sensors_ /usr/share/munin/plugins/sensors_old
2) sudo wget -O /usr/share/munin/plugins/sensors_ http://www.svilen.com/sensors_.txt
3) service munin-node stop
4) service munin-node start

Now wait 5-10min and you should have reading in your Munin graphics.



Enjoy!

Home Made Surge Protector

After my Petzl Tikka upgrade I am continuing with the electro stuff (my new-old childhood hobby).

Two days ago a lightning stroke our neighbours, so it was time for all-in-the-house Surge Protectors so I went to the local hardware shop to buy some.
Unfortunately the cheapest ones costed 13-15$ which is pretty much for me as I needed at least 4 or 5. I already had connection-blocks and I had to add only the protection.

Why not do it myself? Of course I will and it costed around 2$ per piece. What a bargain? Huh?
Yes, that it 2$ per piece. All you need is a proper varistor (in my case 20N391K) and put it into a nice plug.

In short what you need is:
- a new Plug
- a varistor 250V, ~25ns (example: 20N391K)

1) All you need.

1) Initial setup on the varistor inside the Plug.

3) How I added this to a connection-block.

4) Plug is ready lets close it.



5) Plug is close and ready for some tests.

6) I decided to add some image so that I know which plugs are protected already.


Nice job!
3 hours, no more than 10$ and all home connection-blocks are protected from lightning.

Try it but be very careful.
You are working with 220V.
It can kill you if do not take precautions!