Tag: Hardware

Arduino, PowerSwitch Tail 2, humidifierMechatronics is described as the intersection between mechanical, electrical and computer engineering, and it covers just about anything that uses electronic signals to act on mechanical systems. It’s what I went to school for, and it’s where my hobby interests lie. The Arduino is a fantastic example of how people with limited experience can jump right into mechatronics projects. I’ve been tinkering with them for a few years, and decided to put the components I had to good use by taking a timid step to home automation.

Indoor humidity can affect the comfort level of a home pretty dramatically. Since warm air can hold far more moisture than cold air, the humidity inside during the winter falls dramatically. This drop can cause an increase in static electricity, sickness and dry, itchy skin. Too dry and a home can just feel downright uncomfortable. Too much humidity when the outside temperature is low can also cause condensation on the windows and mould growth. Some humidifiers have a built in control system to maintain the proper level of humidity, but what if yours doesn’t?

By combining an Arduino with a basic humidity sensor and relay, you can trigger your simple humidifier to only come on when needed.

Bill of Materials

With these pieces combined together, you can find the indoor temperature and humidity, and adjust the humidifier’s set point manually to achieve the proper moisture level.

Assembly

Complete breadboardHere are some links about connecting the different components that make up the system.

Additionally I have a few bonus status LEDs for displaying when the correct humidity has been reached (although you’ll be able to tell from whether the humidifier is on or off). The great part about the Arduino community is that most of the major components have libraries dedicated to their functions, so you can spend less time figuring out how the hardware works and more time thinking of projects.

Control System

The control system is the set of governing equations and parameters that determine what behaviour the system’s output should have. In this case, it takes in the current level of moisture in the air and tells the relay to switch the humidifier on or off. For that reason, it’s a type of control system called “closed-loop”, because turning the humidifier on will increase the sensor value and trigger it off.

There are many other different types of control systems but we’re fortunate that the main type in use here is called an “on-off controller” for its inability to adjust output values. Like a furnace, the humidifier can be either on or off, with the time in each state determining the magnitude of change. Compared to a PID controller, which uses error correction to maintain a system, the on-off controller is far simpler.

The complete source code is available to download below, but I’ll go through some of the important parts here.

Temperature and humidity outputEven in a relatively simple system such as this, it’s important to follow proper coding patterns. This means using the Model-View-Controller paradigm to retrieve sensor data and output to the screen and relay. In even simpler terms, it means storing the inputs as variables and refreshing the screen rapidly with those variables. For that, it’s a good idea to use something like a Timer class to handle running specific methods at an interval without blocking the main program.

With the button, I’m able to toggle between two states: normal and setting. Doing that is easy with enumerations.

Each time the button is clicked, the state of systemMode is changed, and the display is updated accordingly.

Toggling display modesThe ModeSetting value is where a new setpoint for the control system is entered. When TARGET is displayed on screen, the encoder LED flashes (again with another timer) and turning the encoder updates the value.

While the above links show a clear way of entering the new encoder value, here’s my function.

You only want to update the target value if the current mode is Setting and the new encoder value is different from the previous.

Whenever the system mode returns to normal, the controller checks if the current value is where it needs to be and updates the relay accordingly. However, it’s not as simple as turning the relay on when humidity is below the target and turning it off when it goes above. If that was the case, there would be far too much cycling. That means as the error approaches 0 (humidity reaches the target), the actual value could repeatedly go across the threshold and cause the humidifier to cycle on and off quickly. I’ve set the refresh rate to be 1 minute, but even that would be annoying if it cycled that quickly. To fix the problem, we need to introduce a control system property of hysteresis, which in simplified terms means making the humidifier stay on until it passes the target by a few percent, and not turning on until it’s a few points below the target. This way it cannot rapidly switch between the on and off states. In code, that might look something like this.

Here, the variable correct is the value of whether the system is currently at the desired level, and hysteresis is the percent of padding (2% here).

What this block is essentially saying, then, is “if the humidity is currently above the desired value, don’t turn on again until the humidity is below target – 2” or “if the humidity is currently below the desired value, stay on until the humidity rises to target + 2”. In this way, the system won’t turn on and off in quick succession.

Connect the PowerSwitch relay pins to ground and an Arduino 5V output, and set the state of the pin according to correct. Then sit back and listen to the satisfying click of the relay as computers do your job for you.

Controller and humidifier together

What’s next?

Since this current version requires you to set the target point on the humidifier manually, it’d be nice to make that automatic, too. But how? The problem is that indoor humidity is linked to outside temperature, as I mentioned above, so that means you need to find out the local temperature and adjust the humidity accordingly. That can be done any number of ways, like adding a WiFi or ethernet shield to the Arduino.

This is something I’m planning on doing, but I’m going a slightly different route so that I can build on it for more advanced home automation. By building an Xbee network, I can make nodes that act as sensors or outputs and connect them all to a central computer. Since I already have Ubuntu server, that part is taken care of. I can log data to the server and have it request local weather and tell this Arduino whether the humidifier should be on or off.

But the fun wouldn’t even need to stop there. By designing the network right, suddenly you can add other components to do things like turn lights or appliances on or off or alert you when a window is left open at night. Where will you take it?

Tagged with: , , , ,


My Ubuntu file server is almost complete. With multiple terabyte hard drives in place, software for sharing files among computers on the network, it provides all the services a modern home network requires. However, one of the things it is missing is PVR functionality, which MythTV provides.

MythTV is one of the premier software packages to come out of the open-source movement. It has been developed by hundreds of individuals who work in their free time to generate software that useful to an even greater number of people. Built for the Linux platform, it is very robust and feature filled. This power comes at a price, however, and MythTV is famous for being stubborn to install and maintain. Originally I wanted to write a blog post about how I installed a TV tuner card and conquered MythTV to create an amazing home server package, but instead I need help.

After adding a Hauppauge HVR-1600 to a PCI port in my mid-tower, I installed the drivers and firmware and set about installing MythTV. This has proven impossible because I cannot run the setup program. As shown by the image at the top, whenever I run mythtv-setup through an Xserver session on my MacBook Pro, no video is output and the interface becomes unbearably slow. I’ve consulted with many different forums and no one has been able to offer advice, so now I want to get help from the internet at large. Has anyone see this while installing MythTV and knows how to solve it?

Here’s my hardware setup to clarify things.

  • OS Ubuntu 9.04 CLI
  • TV Tuner Hauppauge HVR-1600
  • Network Gigabit
  • Remote terminal OS Mac OS X 10.6.4
  • Remote terminal hardware MacBook Pro 13″ Dec 2009 GeForce 9400m
Tagged with: , , , , ,

After planning and building a Ubuntu-based fileserver, it’s time to add software to the mix, so that the computer does the work it was originally meant for. In the case with my command-line only server, the software I added was for file sharing and media serving.

The software I’m explaining here was all installed via the command line. To do any of this with the GUI of Ubuntu, simply open a terminal window.

Mediatomb

The priority of my project was that the media on the computer would be accessible on my PS3 via wireless network. To do that, I researched a number of software projects, and settled on MediaTomb because I had heard good things about it. MediaTomb has lots of great features including, but not limited to: web administration, daemon operation, transcoding and instantaneous library additions.

After finding an excellent tutorial on adding all the necessary and optional libraries to get every feature working, I had a good setup. I highly recommend reading that blog post and others on it to find out about all that MediaTomb can do. Essentially, the task involves downloading and compiling MediaTomb to use all the features. While initially the MediaTomb daemon did not run, I was able to fix the problem and got everything working. I’ll be sharing the process in an upcoming post.

Webmin

Using the command-line doesn’t really bother me, but I wanted another way to administer the server over the network and a browser. To do that, I used Webmin, which enables users to change many aspects of the system, without using the terminal.

Installing Webmin is quite easy, because it is included in the Ubuntu repositories. Simply open a terminal window and type

sudo apt-get install webmin

Enter your admin password when prompted, and Webmin will be downloaded and installed automatically. Once it is installed, open a new browser window and navigate to https://ip_of_server:10000 then enter your user credentials. Once logged in, you can do many operations without using the terminal. I have found the best benefit so far to be local disk management — after all, mess that up, and your data vanishes.

ffmpeg

Ffmpeg is a suite of libraries and applications for operating on videos and multimedia. Once installed with all the add-ons, nearly every type of video can be modified and converted. Once again, the blog of Julien Simon has an excellent tutorial about making the program work with Ubuntu. Following his instructions, you’ll have a fully operational ffmpeg installation for other applications to use.

The only thing I’ll add to his tutorial is a fix for ffmpegthumbnailer, which is necessary for MediaTomb thumbnails. Install ffmpegthumbnailer by running

sudo apt-get install libffmpegthumbnailer2

then make an addition to the ffmpeg configure code. Add the text --enable-libffmpegthumbnailer2 to the configure stage, and you should see ffmpegthumbnailer — yes when the configuration has finished.

Netatalk

Netatalk is an open-source file server that can be configured to use the Apple File Protocol. To do this, I followed these instructions, and was up and running in no time. Once installed, Netatalk is very easy to administer from the command line. I was able to create multiple shares for guest and user access and can now access my files from any Mac in the house.

To enable guest access, an additional element must be added to the /etc/netatalk/afpd.conf file. Add the following text

uams_guest.so

so that the entire line is

- -transall -uamlist uams_randnum.so,uams_dhx.so,uams_guest.so - nosavepassword -advertise_ssh

This will enable you to access shares without entering a password, provided the shares themselves are open to the use nobody.

rtorrent + screen

Torrents are a convenient way to download large files like Linux distributions, and a media server is a perfect platform for unattended downloads. rTorrent is a powerful but easy to use command line client that can be customized for any situation. On its own, rTorrent will not run as a daemon, but coupled with screen, it can run in the background.

Install rTorrent and screen by executing the following commands in the Terminal.

sudo apt-get install rtorrent
sudo apt-get install screen

Once installed, start screen and attach rTorrent to it.

screen -S torrents
rtorrent

Detach the screen session by pressing ctrl + a, d and you’ll be back to the main prompt. Now rtorrent will remain running even when you disconnect from SSH.

To rejoin the rTorrent session, you must attach to it.

screen -r torrents

avidemux

Avidemux is set of audio/video tools for the command line that can do many operations. So far I’ve used it to shift audio inside video tracks. Like most other programs, it simply requires a few arguments to do whichever job you need.

sudo apt-get install avidemux

mencoder

Slightly different than ffmpeg, mencoder is another suite of video conversion for a variety of formats. This is an excellent tool to use for converting MKV or OGM files to AVI (video does not need to be converted). Again, it requires basic command line arguments, and can be used in a screen session to work in the background.

sudo apt-get install mencoder

lm-sensors

An important part of running a headless media server is making sure the hardware is operating within its temperature restraints. A tool do monitor that is called lm-sensors and must be set up with the specific hardware in your computer. I could explain the system, but a post on the Ubuntu forums does a much better job. Once installed, simply issue the command sensors to see the temperature of various compontents, and — if your motherboard supports it — the chassis fan speed.

Of course, this only begins to scratch the surface of possible software for a Ubuntu fileserver, but I think the applications shown are important for running a system without local input. Set them up, and enjoy central storage for all the computers in your house.

Tagged with: , , , ,

As home networks become larger and larger, new technology will be required to get gadgets connected that are sprinkled around the house. D-Link, along with other manufacturers, has recognized that many electronics now require internet connectivity, but are either not wireless, or located next to an ethernet plug.

A possible solution to this problem is network adapters that work over existing electrical wires embedded in walls. There are multiple technologies in the market now, and many do not work together, but most work in the same way. An adapter is plugged into the wall socket, with an ethernet cable connected to a device, then another adapter is plugged into a socket and wired router. Now the device is connected to the network, and can enjoy (theoretical) speeds of 200 Mbps.

Setup

In terms of installation, I don’t think I’ve used a network product with an easier setup. With an adapter connected to my router, and another connected to my Playstation 3, I had internet within seconds. The adapters are small enough to fit in convenient places, and the LEDs provide feedback about device status and network connectivity.

Performance

I bought a set of these adapters to connect my PS3 to my network and enjoy media shared on my computer. After the setup and a quick connectivity test, I was excited to try a movie. Sadly, this was where the set fell short.

D-Link says that under ideal conditions, these adapters can provide up to 200 Mbps throughput (which is about 25 MB/s). In my house, I achieved about 3 MB/s. This was found by using my MacBook to transfer files over ethernet. Disappointed but not defeated, I moved the second adapter through my house to test the transfer speeds. Speeds ranged from 768 KB/s on the opposite side of the house to 6 MB/s in the same room as the router. This was about the same as my previous solution, so I decided to return the adapters.

Conclusions

I can’t say I’m all that surprised about the performance, as wiring varies from house to house. My house was especially tough because the router room is on a different subsystem than the living room. This product would probably work best in a fairly new house, with sockets in basically the same area.

If you’re planning on purchasing a set of PowerLine adapters, be sure to check your supplier’s return policy. Test them immediately in a variety of locations and configurations, and look at alternative solutions if they don’t perform close to the manufacturer’s estimation.

Tagged with: , , ,

With the planning of a new computer done, it’s time to begin the process of buying and assembling the parts together. The more you read about compatibility and user satisfaction, the better your final product will be. I highly suggest perusing Newegg.com (or .ca in Canada) to read about other users’ experiences with a prospective part. I used this site to read about parts, then sourced them locally to get instant gratification.

The components

While I won’t talk about physically assembling the computer (there are hundreds of articles like that across the web for that), I will explain what parts are necessary and which ones I bought.

The Choices

I purchased these parts because each met very specific needs for a fileserver. The case includes 4 internal 3.5″ drive bays, with 3 5.25″ and 2 3.5″ external bays. This leaves plenty of space for expansion. Additionally, the case includes a 120 mm chassis fan, meaning it will blow a lot of air, but will remain quiet. The cooling and noise factor is especially important for computers that will be on constantly.

The Intel E5200 was picked because the 45nm manufacturing process means it will require less power and cooling that comparable processors. The fairly high clock speed is just a bonus, but one that allows this computer to work as a video processing station. Remember, a few extra dollars spent at the outset means your system will likely satisfy your needs for much longer.

The hard drive choice is largely a matter of budget and ambitions, but I highly recommend a separate drive for the OS and main storage. Originally I didn’t really want a 500 GB boot drive, but my local store had a sale. The separate drives mean you can upgrade or even replace the operating system without touching your media files. It also means you can create filesystems like RAID or LVM without modifying your home folder.

The motherboard is perhaps the most important component in the build, and requires the most research. As previously mentioned in the planning post, the motherboard will make or break the connectivity of your machine, both to internal components and the network. The ASUS unit I chose has 4 SATA connectors and Gigabit Ethernet. It was one of the few — if not the only — motherboard I found that has both of these features and a MicroATX form factor. The gigabit connection means I can transfer data across the network at speeds of 40 MB/s!

A central storage database can make using multiple computers much simpler and convenient, and with properly chosen components, it can be built with a fairly small investment.

Disclosure
Newegg provides a small affiliate payout for items purchased through these links. I recommend Newegg because of their rapid shipping, low prices and excellent customer service.
Tagged with: , , ,