Afraid.org (DNS) Windows VB Script Update

Whilst very busy I host a handful of websites for friends and family from my garage fibre connection. The thing is my ISP doesn’t provide me an a static IP address. This is obviously an issue when hosting websites.

This can be solved in one of two ways
1. obtain a static IP address either by changing your ISP or plan (if possible)
2. change your A records when your public IP address changes.

I elected to go with option 2.

After evaluating providers our there I settled with Afraid. The clinching factor was the ability to change your A records via an API call over HTTP. Other providers lacked this feature and the 5 years now I have been using Afraid and they have been rock solid with no apparent outages.

Afraid provide multiple ways to update your A record via HTTP but really its more focussed around Linux and the examples other people have written are cumbersome batch files

With hosting multiple sites I wanted a better more streamlined way to update my A records. For that purpose I wrote a VBScript that can be scheduled in Windows.


' **************************************************
' * Author - Shane Baldacchino *
' * Version - 1.0 *
' * Email - shane@baldacchino.net *
' * File Name - DNS_Public.vbs *
' * Script Language - Microsoft VB Script *
' * Creation Date - Thursday 18th, September 2014 *
' * Modified Date - Thursday 18th, September 2014 *
' **************************************************

'---------------- EDIT BELOW THIS LINE --------------------------------
'Versions
ScriptVersion = 1.0

'Domain 1
Set objHTTP = CreateObject("Microsoft.XMLHTTP")
'Replace the GET URL to that of what is listed in Afraid.org for your domain
objHTTP.open "GET","http://freedns.afraid.org/dynamic/update.php?xxxxxxxxxxx", False
objHTTP.send
'Replace 'domain 1' with your domain name
wscript.echo now & " | domain 1 - " & objhttp.responsetext

'Cut and paste the above to add in multiple domains
'---------------- DO NOT EDIT BELOW THIS LINE -------------------------

Execution can be performed by using the cscript VB compiler.


cscript DNS_Public.vbs

Which yields the response in my case of


C:\Archive\Scripts>cscript DNS_Public.VBS
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

17/12/2014 1:36:35 PM | domain 1 - ERROR: Address 124.168.106.85 has not
changed.

17/12/2014 1:36:35 PM | domain 2 - ERROR: Address 124.168.106.85 h
as not changed.

17/12/2014 1:36:41 PM | domain 3 - ERROR: Address 124.168.106.85 has n
ot changed.

17/12/2014 1:36:42 PM | domain 4 - ERROR: Address 124.168.106.85 has n
ot changed.

17/12/2014 1:36:42 PM | domain 5 - ERROR: Address 124.168.106.85 has
not changed.

A copy of this VB script can be downloaded here

Shane Baldacchino

Installation And Integration Of Open Sprinkler and Homevision Pro

Before we started landscaping I had grand plans for irrigation for our house. It was borne out of two desires.
1. With a growing busy family I can’t guarantee that our plants and lawn can be watered
2. Because I can

What quickly became apparent on my home automation journey is that the more sensors I had connected to my Homevision Pro the more powerful my decision logic could be. It was for that reason alone I didn’t want another system separate to the Homevision Pro calling the shots.

I looked at using the Homevision Pro but didn’t really want to waste valuable output ports and upon reading a website I regular read I elected to use a product, . OpenSprinkler. What drew me to OpenSprinkler was that it was an irrigation controller that was TCP/IP enabled and after more investigation I figured I could make simple HTTP GET’s to control the system. Opensprinkler is a great product but it is also quite basic in its logic. It can water based on timers and a rain sensor. But it cant water based on more advanced weather conditions.
– If today is going to be 40C do we need to alter how much water is being dispersed and at what time
– If it rained 7mm of rain over night but isn’t raining when the cycle is set to start do I really need to water?

So whilst I am a big advocate of OpenSprinkler I decided to just use it as a ‘dumb’ TCP/IP irrigation controller and let Homevision Pro call all the shots.

Bill of Materials
– 1 x OpenSprinker ($180AUD)
– 1 x 24V AC PSU ($30AUD)

Total Cost = $210AUD

Tools used
– Soldering Iron
– Pliers
– Screw Driver
– Multimeter

Step 1: Mount and Connect to Network / Valves
Being a small unit I elected to mount OpenSprinkler inside my Homevision Pro enclosure. There was just enough space inside this enclosure for a nice neat snug fit. Ethernet, power and valves were all connected to OpenSprinkler. That’s about all there is to do for physical installation. The rest of this is in the logic.

Step 2: Figure out how OpenSprinkler works
OpenSprinkler is simple to use. The thing is I want to make calls to it that my browser or smartphone application makes. I used Firebug which an excellent Firefox plugin and this showed the following structure

GET http://OpenSprinkler_IP + Station Name + Status ON / OFF + seconds

which translates to

GET http://OpenSprinkler_IP/sn1=1+120

The above GET will cause station number 1 to turn on for 120 seconds. It is a simple as that.

Shane Baldacchino

Controlling Bathroom Exhaust Fans With Honeywell Humidity Sensors

Whilst having automatic lights in my bathrooms is great, having to manually turn on the fan is less than ideal. This article describes how I am interfacing a humidity sensor with a Homevision Pro automation controller to automatically turn on the exhaust fans when humidity reaches a per-defined level. It does not cover all of the programming and smarts around the installation and this this article will provide guidance for any automation system. This is probably one of the easiest tasks I have performed at our house.

Bill of Materials
– 1 x Honeywell HIH-4030 humidity sensor ($19 AUD)
– 1 x Length of heat shrink ($3 AUD)
– 1 x 20m (enough cable to run between automation controller and sensor) of cable. ($10 AUD)
– 1 x automation module to control exhaust fan ($27 AUD)

Total Cost = $59 AUD

Tools used
– Soldering Iron
– Pliers
– Screw Driver
– Multimeter

Step 1: Figure Out How The Sensor Works
Probably the most obvious step here for any automation task. Before we can start controlling the exhaust fan we need to figure out how this sensor works. This sensor was the first analogue sensor I had dealt with and to be honest they are very simple. The HIH-4030 measures relative humidity (%RH) and delivers it as an analog output voltage in near linear form. More details can be found here and if you don’t have time to read this this document it can be summarised with the following image.

This sensor has three pins.

5V – 5V DC
GND – Ground for 5V DC
OUT – A return voltage (DC) which will be relative to the humidity it is reading.

To test how the sensor operates you will need your multimeter and a DC power supply. Supply power to the sensor by connecting 5V and GND to the sensor. Now setting your multimeter to DC volts measure between GND and OUT. The reading you receive will now be relative to the humidity. As humidity changes so will be the voltage detected.

Step 2: Make The Connections
Now since I have tested this it is time to connect to the Homevision Pro. When I built this house I ran an overkill of Ethernet throughout the house. Rather than running a new cable I decided to use CAT 6 as my transport medium. As Cat 6 has 8 cores I have used 2 cores for GND, 3 cores for 5V and 3 cores for OUT. The Honeywell HIH-4030 will require you to solder your cable to the sensor.


Step 3: Program And Test
With everything physically connected it is now time to program, tune and test. The sensor has an operating range which required me to set a gain and offset value.

From the datasheet’s graph(above), it shows that at 0% RH you get a voltage of around 0.8V, at 100% RH you get 3.8V, and there is a near linear relationship between relative humidity and voltage. The Homevision Pro can apply a gain and offset value to the analog values it measures which works well for a linear relationship. According to my calculations, using a gain of 0.65 and offset to -26, the analog port value you obtain via the “VAR = Value of analog input” command will be a pretty good approximation of the relative humidity.

This equation could be expressed via the following

255 * 0.8 / 5 * 0.65 – 26 = 0.52

Testing is accomplished by turning on the hot water in the shower and waiting. I have the exhaust fans controlled by an X10 appliance module. I again use a multimeter to tune. For my needs I turn on the fan when the relative humidity reaches 70% and off again when the relative humidity stays below 70% for more than 5 minutes.

Shane Baldacchino