Tag Archives: tutorials

Modification to extend wireless range

Consumer Electronics Design not always beneficial if it retards the primary functions of a device. The internal antennas are such a design concept that cause a lot of headaches for tech guys like me. The primary function of a antenna is to transmit a signal, capture a signal or both. Since most modern equipments are manufactured with plastic casings (as opposed to metal), a lot of manufactures have opted for internal antennas. The advantage; now nothing is sticking out, they can make the equipment more desirable to mainstream consumers by making “beautiful” equipments boxes. I am on the other hand one of those people who would buy a device for its’ practical functionality over looks.

The following modification was made on my VeraLite (Vera3 variant) to remove dead-zones in my Z-wave network. However, using the same principles and steps, you can also extend the range of your WiFi network. I will add bits of information specific to WiFi extension on this article.

Vera3 and VeraLite controllers

The door locks on Z-wave networks almost always accept only secure authenticated signals. In order to operate the locks you must send the signal either directly from your Z-wave controller (in this case VeraLite) to the locks or use repeaters (or modules with secure repeaters) that are capable of secure signal handling. I found it is extremely hard to find such repeaters in Canada.

So I went with the second option; direct communication between the locks and the controller. However, my controller is in a locked cabinet far away from the locks. This causes reliability issues because unlike Z-wave light switches, door locks cannot take unsecured signals repeated from nearby low security switches.

Modification to the controller

Warning: This modification will void your manufactures’ warranty. Beware of the static charges. Static electricity could burn out your circuit board. Either use a grounded anti-static wrist strap or use extreme caution. Remove all power supply units (batteries & DC power unit) before opening the case.

Parts, tools and technical information

  • Antenna must be able to handle frequency range of the device (for this mod, 908 MHz)
  • U.fl/IPEX to RP-SMA Pigtail with at least 5 cm; 10 cm is too much; find happy medium) of wire length between the connection points
  • GSM antenna extension cable (optional and longer the cable, more problems arises)
  • Small needle nose pliers
  • Small Phillips screwdriver and a large slotted screwdriver or a flat plastic or mental piece
  • Small electric drill or a utility knife

It is very easy to take apart VeraLite unit. Only two screws and few plastic clips that holds the plastic casing. One of my readers (“Jack”) pointed out that the screws will not come out from the casing. In that case do not try to pull it out. Once the screws are lose, you do not have to take them out of the holes in order to separate the green cover from the case. Use a flat head screw driver or a flat object to pull the cover apart. Be careful to not to break the clips that holding the two parts.

Inside you will find the internal antenna attached to side of the box with a connection wire going to the Printed Circuit Board (PCB). Click on the the image below for more detailed information.

VeraLite PCB: A = Internal antenna, B = Cutout made for ext. antenna. C = Antenna connector
Figure 1: VeraLite PCB: A = Internal antenna, B = Cutout made for ext. antenna. C = Antenna connector

Disconnect the internal antenna wire from point C (refer to above image) by gently twisting and pulling on the connector. Do not pull from the wire because it will break the wire from the connector. I recommend using a small needle nose pliers.

Make a hole through the casing, either on the back or on the side. Make sure it is large enough to pass the SMA (SubMiniature version A) male connector but not its’ neck. I used a box cutter to be safe, but you can also use an electric drill. If you are using a large construction grade drill, please be careful to not to break the box. I found the utility knife to be the best option.

Creating a circular cutout to pass the male SMA end
Figure 2: Creating a circular cutout to pass the male SMA end

Take the U.fl/IPEX to RP-SMA Pigtail (Figure 3) and connect the U.fl side to the board. Then pass the SMA side from inside to outside. Then connect the other end to the point C (Figure 1) on the board.

U.fl/IPEX to RP-SMA Pigtail
Figure 3: U.fl/IPEX to RP-SMA Pigtail

Internal and external view of the final product.
Figure 4: Internal and external view of the final product.

Put the box back together and your done! For the external antenna now you have the option of adding it directly to the device shown in Figure 3 or you can add a antenna cable before adding the antenna itself. This is what most people do when they want to secure their devices in a cabinet. You can keep the network controller inside while antenna outside for greater coverage.

It is quite possible to salvage antenna and U.fl/IPEX to RP-SMA Pigtail connection wire from old devices such as wireless routers and GSM devices. But unfortunately most WiFi routers are on 2.4 GHz band while Z-wave is in 900 MHz band. For example, this particular model is at 908 MHz frequency. If you cannot find a GSM device to get an antenna, please buy one (~ $8 – $12 CAD) to take the full advantage out of this modification. Connection wire from a WiFi router is suitable for Z-wave broadcast.

Antenna length difference due to wavelength difference between 2.4 GHz vs 900 MHz
Antenna length difference due to wavelength difference between 2.4 GHz vs 900 MHz

If you would like to know more about how antennas work, try this site.

Modify WiFi Routers

Yes, you can modify your b/g/n/ac WiFi routers with built-in antenna(s) by following the same instructions. The only difference is now you can use any old 2.4 GHz or 5 GHz (not very popular) antennas for your project.

Modules associations

There are few different companies that manufacture modules for home automation. Even with products from same company, it can be difficult to find all in one solutions to consumers’ need. Through manipulating the behaviors of the modules through the controller, we can accomplish almost anything.

Let’s look at a situation where solution is not obvious. In my home, I have a separated garage with a conventional door opener and lights. To automate the door, I added a Z-wave inline module. It works great, but it often interferes with the built-in light of the opener. So I removed the light fixture from it. Now every time I come home the garage is dark because the other set of lights requires me to turn on separately. Solution is to combine two modules; the door open/close sensor and the light switch module.

I wrote down what I would like to have and what equipment I have to solve the problem. What I wrote is; Sensor is Armed –> Sensor is Connected/Disconnected –> Turn ON lights –> Wait 10 min –> Turn OFF lights. Then, being a good computer scientist I created a flow chart.

Flowchart: Garage Door Sensor associating with Light Switch
Flowchart: Garage Door Sensor associating with Light Switch
Now, I installed the Z-wave 2-way switch module by replacing the old switches. Then I used the association in Vera controller to make a relationship between the sensor and the light switch.

Here is an example video of an association (not the same one describe above).

You can resolve problems similar to this using associations in many other situations. Here are few example of typical problems that can be fixed using association method.

  • Turn on lights (switch module) when the motion senator (sensor module) is tripped if the time period is night.
  • Turn off the TV (plug-in module) if the motion sensor (sensor module) have not been tripped for over X hours in the entertainment room.
  • Turn on the sprinklers (plug-in module OR sprinkler controller module) if the light sensor (sensor module) detects low lights and it is at night.
  • If the light level (luminance sensor) is below 90 lux then turn on lights.
  • If the humidity level (humidity sensor) is below 40% turn on the humidifier and send an email.
  • If you install a multisensor, Boolean logic possibilities can be significantly increased.
  • …and many many more!

The key to a successful association type automation is proper planing and right equipment.

Improvised home automation

The ideal solutions for home automation devices are usually plug-and-play units or modules. They often require just powering the unit and adding to your main controller. I came across unique situation in which a Z-wave, x10 or Insteon modules does not exists, but a solution can be made by combining automation modules with types of electronic/electric units. It is technically an improvising what you can get on the market. However, it does not necessarily means the final outcome of these projects are lower in quality compared to plug-and-play solutions.

Electric shock alertPlease note that some modifications may result in voiding the manufactures’ warranty. Some project involves working with ~ 110/240 volts alternating current (AC). Even with the power cut offed, there is always a risk of electric shock.

Garage Door

Currently there are no manufactures or distributors in Canada that sells openers with automation as a built-in function. I have used a inline relay module between the traditional opener switch and power. If you are unfamiliar with what is an inline relay, check these items: Fortrezz MIMOLite Zwave Input Output Module and Evolve ZWave Inline Relay Module-LFM-20.

These relays acts as a human input to any device that has a ON/OFF type switch(es). Some of these may not work for devices that require continuous ON such as an electric heater. Make sure you read the manufacture’s datasheets before purchasing.

Door Opener

Yes, you can buy a automated door locks from companies like Kwikset, Schlage and Yale. But it will only allow you to either lock or unlock your door. What if you want to open the door remotely? To do that you need a motorized door opener. You can buy a door opener unit for either swing door or slide door type. They comes with an electric motor, mounting equipment, a switch and a remote. What lacks is any form of automation controlling unit (Z-wave, x10 or Insteon).

When you are purchasing a electric door opener, make sure it also has a push-button connection. You will replace this push-button with your inline module.

Again, we can use an inline module like MIMOLITE between the motorized door openers such as Skylink Otodor Automatic Swing Door Opener and its power supply. Then by adding the the module to network, you can open and close the doors with your computer or phone.

Security Cameras

There are several companies that produce high quality cheap security cameras. For indoor use, almost all of the reputed companies make great products that are simply plug-and-play modules. I also like the fact they are often independent standalone units. In other wards they can operate without a central controllers like Z-wave controllers.

In Canada, we run into one big problem; weather. Most wireless outdoor cameras are built to work between -20 to +40 degrees Celsius. In most parts of Canada (such as Calgary) we get temperatures as low as -40 oC during Winter months. You could buy a extreme weather cameras with a heated casing. But it will not only cost a lot for the unit, but also the subsequent costs for heating will add up over the years. Hence we must improvised with these cheap IP-Cameras if we want to use them outside.

Solution 1: Use indoor units

You can install a high grade indoor camera such as D-Link DCS-5222L close to a wide outside window (inside the house). Now by pointing the camera towards the outside, you can still surveils the outside without having a weather proof unit. The major drawdown is that the Infrared (IR) LEDs will bounce off the window at night causing distorted image. This can be overcome by turning off the IR mode and illuminating the outside area with a flood light.

Solution 2: Install on the other side

If you want to protect areas like your garage, you can install the camera inside instead of outside. In most situations this will provide adequate protection from weather. The darwdown is that if you have an enclosed area, you will not be able to see the outside. However, if someone breaks into the garage, that can be recorded.

Solution 3: Creating your own weather casing

This is really a improvised do-it-yourself project. You can create a metal or wooden box and add a HVAC pipe into the box from your house. So whenever the house is heated, the camera enclosure will also be heated. Please make sure that you are doing this according to the laws of your area. Some cities and countries would not allow you to use such methods due to safety reasons.

Last option is not really an improvise. You can just buy a Canadian outdoor weather reared camera. In December 2013, it will cost you around $300 to $2000 depend on the manufacture and the model.

When installing a wired outdoor camera (or anything else), make sure to use outdoor rated cables.

Plumbing

I would not buy a fully integrated taps or water controllers. This is because electric taps are often well-built. However, the electronics go into the automation can be unreliable. You do not want a leak after few years of use or unwanted turn on/offs. The solution is to buy an electric taps/water controllers with a push-button switch. Hence, the automation part will be added using a inline module that is independent of the water controller itself. Easy to install and easy to do maintenance work.

Electrical

I would not recommended improvising for anything to do with electrical. It not only pose a hazard to your health, but also could lead to criminal charges. But there are something you can do in your own home. Even the garage door and light switches automation involves electrical modifications.

Missing Common Wire

If you have a situation in which a Common Wire (“white wire) is not available in your house or the area in question, you have two options. One is to run a Common Wire from your main board to the location, and the second is to use a plug-in module. If you are not familiar with electrical work, I recommend the second option. You can connect lamps, electrical appliances, consumer electronics and many more to a plug-in module. Make sure you use the right module with proper rating. The module will plug-into the wall outlet and provide outlet with automation. The Evolve ZWave Plug-In modules are examples of such units.

LED dimmer causes flickering

This is a very common problem with LED dimmers and not the Z-wave module itself. Sometimes when the resistance, R on the circuit is extremely low and the current, I flow is also reduced through the dimmer, it will cause the LED lights to flicker. This happens when the dimmer at its lower illumination setting.

To resolve this we need to increase the resistance in the circuit. The best solution is to install at least five to eight LED light bulbs in a single circuit. You can try by adding one at a time until you no longer have this problem. If that is not viable solution, install a mixture of both LED and regular bulbs on the same circuit. However, I found by mixing manufactures of LED bulbs I was able to stop the flickering with just three LEDs.

Outdoor electrical modules

When working on an outdoor automation project, use outdoor approved electrical products. For example, GE ZWave Outdoor On/Off Module-45604 should be used when you are installing a sprinkler system. Do not try to save money by buying an indoor module to control an outdoor electrical products. There is a reason why outdoor units can be bit more expensive!

Please be aware that you may not be able to automate anything and everything. Use common sense and if you are not sure of something, do your research and/or ask an expert. Most manufactures and distributors also provide free support. Use them as a resource.

Advantages of Improvising

There are several advantages. I decided to list them so you can quickly glance through each one.

  • In-line modules can be from any manufactures and can be on any standard (Z-wave, x10, etc)
  • Most of the time, it is easy to install with improvised solutions (describe in the article)
  • If a unit/module fail, it is easy to replace as opposed to replacing an expensive and complicated unit
  • Parts can be easier to find (for example, an electric tap from Canadian Tire and a controller module from a Z-wave specialty store)
  • May be more reliable than having a single plug-and-play
  • Can be install on almost any house regardless of the age of the house or the electrical wiring/plumbing/door system
  • Provide much more expansion possibilities

Random Item from CMS Database

There are few ways to do this in WordPress CMS using the PHP web language. What I would say the “best way” involves editing either original or Child Theme functions.php file. Therefore it is bit risky and you could potentially take your side down in an event of an incorrect implementation. Let’s look at the fool safe “easy way” first.

By creating a page template

The advantage of this method is that we are not editing your original or Child PHP theme files. Instead, a separate PHP file is created (either directly on the server or outside then uploaded using FTP) as a template file. This may also potentially create coding conflicts but usually can be resolved by simply removing the newely created file from the server. This new template must be located in the templates folder of your WordPress theme files. Hence the location should be the same as the page.php file location. Usually it is in “themes” folder.

First, create a PHP file with a desired name. Let’s call this file “template-random.php” in this particular example.

<?php
/* Template Name: Random Item */
query_posts(array('orderby' => 'rand', 'showposts' => 1));
 if (have_posts()) :
   while (have_posts()) : the_post(); ?>
     <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
     <?php the_content(); ?>
   <?php endwhile;
 endif; ?>

After creating the template go to the Admin Panel of your WordPress and create a new page (let’s call it “random”). Choose the template we just uploaded as the template of the page. The template we just created should appear on the list of selectable templates under “Attributes” pane as “Random Item”. A random page/post will be generated every time this new random page is generated. For example, sanuja.com/blog/random will give you a random item from the database. Now you can use “a href” type links or buttons to direct users to random pages.

By updating the functions.php

Update the functions file in your main theme files or Child Theme files with the following code.

function le_random_post() {
if ( isset( $_GET['random'] ) && $_GET['random'] == 1 ) {
   $posts = get_posts( 'post_type=post&orderby=rand&numberposts=1' );
      foreach( $posts as $post ) {
      $link = get_permalink( $post );
      }
      wp_redirect( $link,307 );
   exit;
       }
}
add_action( 'template_redirect','le_random_post' );

Now you are done! Just use the appropriate URL to generate items from this script. For example, this will generate a random item as soon as the URL, http://sanuja.com/blog/?random=1 is requested.

Searching Multiple Documents

At work, at school or even at home, often we have to read though multiple files to find specific texts or objects. When there are more than one file to search, most users would open and search each file one at a time. But time is invaluable and most of us rather do anything but searching for information all night. Likely, there are simple solutions you can use to prevent repetitive search. The following article will briefly explain how to search large number of individual files on a Windows based computer.

Searching multiple PDF files

1) Open the Adobe PDF program (with or without a document file).

2) Now press CTRL + Shift + F to open the “advanced search” window shown here:

Text search in multiple PDF files
Text search in multiple PDF files

3) Select “All PDF Documents in” radio option under “Where would you like to search?” dialog.

4) If you prefer to search only a single folder containing multiple PDF files, choose from the folder tree under the drop down or choose “Browse for Locations…” from the list. It will give you a pop up for locations in your computer/network.

Locations options for PDF files search.
Locations options for PDF files search.

5) There are few other options including Case-Sensitive, entire phrase search, etc.

The following is an example of search results for all PDF-based lectures for Hydrology 401 class for the term “hydraulic gradient”. During final exams of Winter 2013, I have literary saved hundreds of hours searching for information in PDF materials using this method.

How the results will appear. By hovering over a result will provide page number.
How the results will appear. By hovering over a result will provide page number.

Searching Microsoft/OpenOffice

This is not an ideal solution. The results are often scattered across the computer and the data presentation is not as good ad the Adobe PDF search. But still this is better than looking for specific concepts using good-old flipping pages.

1) In Windows 8, go to the Start Screen and then simply type away… Files with your word phase should come up as soon as you type.

2) Click on search word/similar words list, which appears below if the items you are looking for does not appear under immediate files list.

3) Can search all types of documents. However, locked PDF and document files may not always get searched.

You may go to search settings on your computer to limit the type of files and the locations for the search.

Windows 8 computer-wide all file search results.
Windows 8 computer-wide all file search results. Click for larger image.

As you can see from the example above in which I searched “Phacopida”, the new Windows 8 redeisgned results page can be very informative. For some people like me, this is great since it also searches Wikipedia and images with that file name or meta tag. But for others this can be confusing. Microsoft have placed the results in panes (A to E on the image above) so that each search location is separated. Ideally, this is the best way to search multiple format (PDF, image, Office, etc) on Windows 8 computers.

The same function is available on all Windows computers from Windows 95 and upwards. The only difference is the results in older generation Windows units will display in the Folder format.

General Search in Windows 7
General Search in Windows 7

Problems with images and diagrams

Unless the images are saved as a PSD file, CorelDraw file, Excel/Word text-graphic file or image files with meta data, it will be harder for the computer to detect what you need. I would recommend encouraging your instructors to use modern tools when creating images/diagrams so that the texts included in them can be search by Windows and other Operating Systems. There are tools for image search, but these software will cost you an arm and a leg!