Computers

Automated Kitchen Lighting

0

Recently I decided to make some changes to the kitchen. It started off with a strip of warm white LEDs, and I thought “Wouldn’t it be cool if…”. I’ve now lost count of the number of guests asking how it works :-)

There’s a variety of components at play here. Firstly, there’s a Raspberry Pi, followed up by a simple IRF530 MOSFET, a PNP transistor to pull it low, a PIR sensor, and a strip of LEDs.

Kitchen Cabinet Lighting

Sensing

It’s a a PIR sensor from Seeedstudio that I bought on a whim a while back. It handily runs off of 5v, and returns a 3.3v TTL compatible signal upon detection of movement.

On the Raspberry Pi, I have my own Python app, mqtt-gpio-trigger, running. It continuously monitors pins that are defined in the config file, and in the event of a change of state of any of them it will publish a message to a predefined topic, with the pin number as the final component of the topic, and the message contains the state of the PIN. Simply subscribe to that topic to watch whatever pin on the Raspberry Pi.

Lighting

A strip of warm white LED lights are attached to pin 18 of the Raspberry Pi, via the IRF530 MOSFET. There’s a bog standard NPN transistor to help saturate the gate of the MOSFET, and it’s pin 18 as that’s the only pin on the Raspberry Pi that does hardware PWM. Using any of the other pins subjects you to vagaries of the CPU.

Controlling pin 18 is mqtt-pwm-lights, another one of my scripts. It simply sits and runs, and subscribes to yet another MQTT topic. When it receives a message with a value between 0 and 512, it fades the lights to that value. Due to the NPN transistor it’s inverted, so 512 is off, and 0 is on. A minor annoyance, but the home automation controller handles that.

In the middle

Producing the show is a small script that isn’t public. All it does is listen for MQTT events and reply with canned MQTT messages in return. It’s a stopgap measure until I find a better home automation controller. The main role of the script at the moment is to listen to events from the PIR, start a timer when triggered, and publish a lighting level request. When the timer expires, the lighting level returns to normal (ie, off)

So that’s it. Ambient automated lighting for the kitchen, and worktop lighting, all rolled into one.

Thinkpad X201S Fan Control

0

I noticed the other day (it was kind of hard to not notice, to be honest) that my laptop shut down abruptly when it overheated. This shouldn’t be the case, as the thermal controls on the mainboard should have spun up the fans.

After some poking around, I found that with the default ‘auto’ fan control, the top speed of ‘level 7′ only spins the fans around 4000RPM, even though when the feedback loop is disengaged (echo level disengaged > /proc/acpi/ibm/fan” they can spin up to 7000RPM, and bring the temperature down from the critical 100C mark.

This bug report suggests that something is completely amiss with the kernels thinkpad_acpi module, and nobody really knows why. The end result is that fans spin too slow on the Thinkpad range of laptops. This can, however, be resolved with a couple of edits and an additional package. The following instructions were tested on Ubuntu 12.10, most likely work exactly the same on all Debian versions and derivatives, and can be adapted for use on other Linux distros as well.

Firstly, enabled userland control of the Thinkpad fans with the following command -

echo options thinkpad_acpi fan_control=1 >> /etc/modprobe.d/thinkpad.conf
rmmod thinkpad_acpi
modprobe thinkpad_acpi

This will enable the new settings for your current session, and all future sessions too.

You should now be able to set the fan speed manually with commands such as –

echo level 0 > /proc/acpi/ibm/fan
echo level 7 > /proc/acpi/ibm/fan
echo level disengaged > /proc/acpi/ibm/fan
echo level auto > /proc/acpi/ibm/fan

The key bit here is to remember that ‘disengaged’ equates to ’127′ on the grand scale of speeds.

Next step is to install the thinkfan package, and enable automatic startup -

apt-get -y install thinkfan
sed -i s/START=no/START=yes/ /etc/default/thinkfan

Now, as above, the default fan speeds are too slow. So even if thinkfan commands a level 7 fan speed, it won’t be fast enough to keep your hardware cool. To make it run up to full speed, you have to disengage the feedback loop and let it run in failsafe mode. Don’t worry though, thinkfan will bring it back into ‘auto’ mode once temperatures are back to normal, so you can have normal battery life and normal noise levels once your compute process is complete.

Edit /etc/thinkfan.conf, and at the end adjust the endpoint for level 7, and insert a new line for fan speed 127. My thinkfan.conf is as below –

(0, 0, 55)
(1, 48, 60)
(2, 50, 61)
(3, 52, 63)
(4, 56, 65)
(5, 59, 66)
(7, 63, 66)
(127, 66, 32767)

Save thinkfan.conf, and start thinkfan with this

/etc/init.d/thinkfan start
Once 66C is passed, it will enter disengaged mode, and run at full speed until it reaches 66C or below again.

My aging quad core i7 2.13GHz laptop will happily run BOINC now, at 97C, so I say it’s working :-)

MQTT Republishing Itch

1

So, I had an itch. A variety of data coming in from a variety of sources, all over different protocols and methods, with different names, heirarchies, and paths. For a while I’d been pushing the data into MySQL, but this seemed a bit of a hack, and it still didn’t really cure the problem as it was more of a historical record than an attempt at mapping between the source and the destination, as it were.

I’d been fiddling with MQTT for a while, and had started publishing data over it via my personal broker. And then I read Roberts post over at http://blog.hekkers.net/2012/09/18/mqtt-about-dumb-sensors-topics-and-clean-code/ about republishing it in a logical way.

So simple! So, I wrote a republisher. It’s very simple, and it scratches my itch (and hopefully Roberts too). Data comes in via whatever naming scheme or topic you like, and it gets republished in whatever fashion you want. The map is maintained in map.csv, and items are separated by commas. The MQTT spec doesn’t reserve any characters for the topic name, so I’ve used a comma out of CSV convenience.

The code is over at https://github.com/kylegordon/mqtt-republisher

Accessing Novell Groupwise from Ubuntu, Mint, etc

0

We use Groupwise at work, and up until recently Groupwise support was available in Evolution. I don’t know why it was dropped, but it’s fairly easy to reinstate it again if you’re prepared to build from source.

These are the steps I used to build it on two Linux Mint installations, although it should work on Ubuntu and Debian too.

Edit /etc/apt/sources.list and ensure you have deb-src equivalents for all your main, universe and multiverse repositories

sudo apt-get update
sudo apt-get install libedata-book1.2-dev libedata-cal1.2-dev evolution-dev libdb5.1-dev libcamel1.2-dev
sudo apt-build dep evolution

All being well, a big bunch of build dependencies will be installed

cd ~/src/
git clone http://git.gnome.org/browse/evolution-groupwise/
git checkout -b 3.2.0-patch EVOLUTION_GROUPWISE_3_2_0
# This is the patch for the SOAP port bug
git cherry-pick 3aae80f55d5fd565274f19210564e74d5350a66c
./autogen.sh

All being well, ./autogen.sh will finish and tell you to run make to compile it.

make ; sudo make install

Now, the makefile doesn’t seem to copy over some UI elements, which means the Proxy login feature destroys Evolution if you try to use it. A quick workaround is to copy them from your source tree to your system.

sudo cp src/plugins/*.ui /usr/share/evolution/3.2/ui/

Kill any existing Evolution components…

ps waux | grep -i evolutio[n] | awk {'print $2'} | xargs kill -9

Run evolution from the command line

evolution

Epson SX235W on Linux

5

Recently my parents purchased an Epson Stylus SX235W for use with their Linux laptops. It’s a combined inkjet printer and flatbed scanner with wireless network support, all for a decent price.

My dad uses Ubuntu Lucid, my own choice back when Lucid was current, and it was also conveniently on Long Term Support (which it still is) – this shouldn’t be too bad.

Printing
Out the box, CUPS does not support the SX235W printer. This was easily resolvable by heading to Epsons website and following through the various procedures to get Linux support. The download center at http://download.ebz.epson.net/dsc/search/01/search/searchModule seems blissfully unaware of the SX235W printer that they gleefully sell, but it does know it under the model SX235. Select that option, and grab the version of epson-inkjet-printer-201108w that’s applicable for your architecture.

Once you install the package, the standard ‘Add Printer’ tools in Ubuntu will be able to find the printer on the network. A word of warning though – be patient. It will take up to a minute for the printer to be discovered on the network. Once found, you can add the printer, let it search for and find the driver, and then you’ll be off and running.

Scanning
Scanning was a slightly different matter. This is supported through the use of the iscan package, along with the iscan-network-nt plugin. The key here is that unlike the printer driver which uses DNS-SD to find the printer, SANE has to be configured to look at the correct network address of the scanner before it will allow anything to be done. My parents router is a nice little TP-Link TP-WR841N running OpenWRT, so a quick delve into /etc/config/dhcp to give the printer a static lease had the printer on a readily discoverable IP address within a couple of minutes.

Once the printer was on a dedicated IP address, installation of the iscan and SANE packages followed. For SANE, just ‘apt-get install sane-utils’. For iscan head back to the Epson Driver Download Center mentioned above, and download both the “core package&data package” and the “network plugin package” package for your architecture. Bear in mind that as Lucid uses libltdl7, you’ll need to grab the version suitable for libtdl7 or later. Make sure you download and install the iscan-data package first, before trying to install the core package. Once those two are installed, the network plugin package can be installed.

Remember previously where we set the printer/scanner up with a static DHCP lease? This is where it comes in important. Edit /etc/sane.d/epkowa.conf and down in the network section put in ‘net 192.168.1.50′, and substitute the correct IP address.

All sorted. Execute ‘iscan’ at the command line or “Image Scan! for Linux” from the Ubuntu menu, and it should detect your scanner and offer to scan. Job done :-)

Go to Top
  • Flickr Recent Photos

    Kitchen Cabinet LightingIMG_20130126_134311IMG_20130126_135556IMG_20130126_135001IMG_20130126_135607