This is only a preview of the December 2009 issue of Silicon Chip. You can view 34 of the 112 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "Voltage Interceptor For Cars With ECUs":
Items relevant to "One-Of-Nine Switch Position Indicator":
Items relevant to "Capacitor Leakage Meter With LCD Readout":
Items relevant to "WIB: Web Server In A Box, Pt.2":
Purchase a printed copy of this issue for $10.00. |
WI B
Pt.2: By MAURO GRASSI
Web S erver I n a B ox
Last month, we introduced our new Web
Server In A Box (WIB) and gave the full
construction details. This month, we show
you how to connect it to your modem/
router and guide you step-by-step through
the set-up details. We also show you how
to activate a dynamic DNS service, so that
you can access the WIB via the Internet.
82 Silicon Chip
siliconchip.com.au
I
N ORDER TO ACCESS the WIB over the internet, you must have an account with an ISP
(eg, Telstra, TPG, Optus, etc). You must also have a router connected to the modem or
you can use a combined modem/router. In fact, this is the most common set-up where you
have more than one device sharing your Internet connection.
In summary, the set-up procedure involves the following eight steps:
Step 1: Physically connecting the WIB to your network (this involves connecting it via
an ethernet cable to your router or modem/router).
Step 2: Changing the DHCP range of your modem/router (ie, the range of IP addresses
it can automatically assign to other devices on the network) to prevent conflicts
with the static IP assigned to the WIB.
Step 3: Enabling port forwarding (or virtual server) in your modem/router for the HTTP
and FTP servers.
Step 4: Directly copying the provided website and configuration files onto the WIB’s
memory card using a PC.
Step 5: Modifying the settings.txt file so that you can connect to the WIB via the local
network using your web browser.
Step 6: Configuring each module in turn by changing the settings via the browser. These
modules are:
(a) the HTTP (web) server;
(b) the SNTP client (for network time);
(c) the FTP server (to allow files to be uploaded or downloaded);
(d) the SMTP email client (for email notifications); and
(e) dynamic DNS (domain name server) to allow access via the Internet.
Step 7: Setting up the analog variables, so that you can monitor the analog sensors (eg,
for temperature).
Step 8: Creating new default values once the set-up is finished.
Step 1: Connecting The WIB To Your Modem/Router
T
HERE ARE several ways of connecting this device to your local
network.
First, if you have combined modem/router with a spare ethernet
port, then it’s simply a matter of connecting the WIB to it using a straightthrough ethernet cable as shown in
Fig.9(a). Alternatively, if the router
is separate, then the WIB should
be plugged into this along with the
modem as shown in Fig.9(b).
If you don’t have a spare ethernet
port on your modem/router, then the
connection will have to be made via
a network hub. This situation will
typically arise if you only have one
port on a combined modem/router
siliconchip.com.au
192.168.0.34
ETHERNET
PORT
WIB
(FIXED IP ADDRESS)
MODEM/
ROUTER
INTERNET
DYNAMIC
IP ADDRESS
ETHERNET
PORT
PC
(DYNAMIC IP ADDRESS)
A
FIXED LOCAL IP ADDRESS
(EG, 192.168.0.1)
MODEM/ROUTER WITH AVAILABLE ETHERNET PORT
Fig.9(a): here’s how to connect the WIB to your local network if you have a
combined modem/router (be sure to use straight-through ethernet cable). If
your modem/router uses a 10.x.x.x fixed IP address, then you will have to
change the IP address of the WIB accordingly (eg, if the modem,router uses
10.0.0.1, then change the WIB’s address to 10.0.0.34).
December 2009 83
Step 1 CONTINUED . . .
ETHERNET
PORT
DYNAMIC
MODEM
IP ADDRESS
Fig.9(c) (below): this is the scheme to
use if your modem/router has only
one ethernet port but that’s normally
taken by your PC or some other device.
In that case, you need to connect both
the PC and the WIB to separate ports
on a hub. The modem/router is then
connected to another port. The WIB’s
IP address should normally be outside
the DHCP range (see text).
INTERNET
FIXED LOCAL IP ADDRESS
(EG, 192.168.1.1)
MODEM PORT
(EG, 192.168.1.2)
192.168.0.34
ETHERNET
PORT (LAN)
WIB
(FIXED IP ADDRESS)
ETHERNET
PORT
ROUTER
B
FIXED LOCAL IP ADDRESS
(EG, 192.168.0.1)
SEPARATE MODEM & ROUTER
WIB
(FIXED IP ADDRESS)
Fig.9(b) (above): if the modem and router are
separate, then connect the WIB as shown here.
As before, use straight-through ethernet cable
to make the connections and change the WIB’s
IP to suit the network if the inward facing
(local) IP of the router uses a 10.x.x.x address
or some other addressing scheme.
but that’s already used to connect
your PC. In that case, the PC will
have to be disconnected from the
modem/router and both it and the
WIB connected via a hub as shown
in Fig.9(c).
INTERNET
ETHERNET
PORT
ETHERNET
PORT
192.168.0.34
(DYNAMIC IP ADDRESS)
DYNAMIC
IP ADDRESS
FIXED LOCAL IP ADDRESS
(EG, 192.168.0.1)
ETHERNET
PORT (LAN)
PC
MODEM/
ROUTER
HUB
ETHERNET
PORT
PC
(DYNAMIC IP ADDRESS)
C
MODEM/ROUTER WITH A SINGLE ETHERNET PORT
Note that, in all cases, we’re assuming that the PC is assigned a
dynamic IP address by the DHCP
server in the router. Alternatively,
it can be configured with a static IP.
The default static IP of 192.168.0.34
for the WIB is also shown but this
can be changed to suit the network
if necessary, as we shall see later.
Note that all the connections are
made using straight-through ethernet cable (usually blue).
Step 2: CHANGING THE MODEM/ROUTER’s DHCP RANGE
I
N MOST NETWORKS, a DHCP
server in the modem/router is
used to hand out dynamic IP addresses to any devices on that
network. By contrast, the WIB uses
a fixed IP address. As a result, the
DHCP range must be restricted
to avoid this address, to prevent
conflicts.
Alternatively, you can reserve
a fixed (static) IP address for the
WIB within the DHCP server range.
Again, this prevents it from handing
out the WIB’s IP address to some
other device on the network.
If you leave the WIB’s IP at the
default 192.168.0.34, the easiest approach in most cases is to restrict the
DHCP range so that is covers from
192.168.0.2 to 192.168.0.33. Alterna84 Silicon Chip
tively, or you can specify that DHCP
addresses start from 192.168.0.35.
The first step is to log into your
router using a web browser. Your
router has a fixed IP address on
the network (192.168.0.1 is a common default) and this is often (but
not necessarily) the address that’s
also used to access its set-up pages
(this can be checked in the router’s
manual). You will also need the
username and the password for the
modem/router.
In the case of a D-Link DI-524, for
example, the set-up address is the
same as the LAN address and it’s
just a matter of entering 192.168.0.1
in the browser, followed by the
username and password at the login prompt. The default username
and password differ according to
the manufacturer but in any case,
you should have changed these for
security reasons when you first set
up your modem/router.
Once logged in, you then navigate
to the DHCP set-up page and set
up the DHCP address range. Make
sure that the IP address of the WIB
falls outside this range, to avoid any
conflicts. You will need to specify
a big enough address range to accommodate all the devices on your
network that rely on DHCP.
You then save the settings and
reboot your modem/router to make
the settings stick. An example screen
grab using a D-Link DI-524 router is
shown in Fig.10, while Fig.11 shows
the settings for a Motorola SBG900
siliconchip.com.au
Fig.10: configuring the DHCP server range in the D-Link
DI-524 modem/router. Note that, for most modem/
routers, the WIB’s address should be outside this range.
cable modem/router. Note that the latter has a fixed
network address of 192.168.0.1 but its set-up is accessed
using 192.168.100.1.
For the Motorola SBG900, it’s a matter of navigating
to Gateway – LAN – DHCP Server Config and entering in the starting IP address and the number of DHCP
users (see Fig.11). Unlike most other modem/routers
though, the DHCP range here must include the WIB’s
IP address otherwise you will not be able to configure
port forwarding later on (see below). You must then
reserve a fixed IP address for the WIB and for any other
device with a fixed IP that falls within the DHCP range.
That’s done by associating an IP address with the
MAC address of each such device – see Fig.12. You can
discover the MAC address of each device on a network
by entering ipconfig /all at a command prompt. The
MAC address of the WIB is also indicated on its Basic
Settings page – just enter 192.168.0.34/basic.cgi in a
web browser and log in (admin and pass are the default
username and password entries respectively).
Don’t forget to reboot the modem after making these
changes, so that the settings take effect.
Fig.11: the DHCP server configuration for the Motorola
SBG900 cable modem/router. Unlike the set-up for most
other units, the DHCP range in this case must include
the WIB’s IP address to allow port forwarding. The
WIB’s static IP address is then reserved – see below.
Fig.12: the WIB’s static IP address (along with the fixed
IP of any other device) is reserved in the SBG900 as
shown here. It’s done by assigning a fixed IP to the MAC
address of each device – see text.
Step 3: CONFIGURING Port Forwarding & THE Firewall
T
HE ADDRESS assigned to the
modem by your ISP is known as
the “public IP address”. This is the
address that’s presented to the Internet. At the same time, the modem
(or modem/router) also has a private
(inward facing) IP address which it
siliconchip.com.au
presents to the home network – see
Figs.9(a), 9(b) & 9(c).
In operation, the router stores
information on the outgoing packets and then uses this information
to determine where to route the
response on the home network. This
is called Network Address Translation or NAT.
NAT also acts as a kind of firewall,
since any unsolicited requests from
outside are dropped by the router.
However, in this case, we want
HTTP and FTP requests directed at
December 2009 85
Step 3 CONTINUED . . .
Fig.13: port forwarding set-up on the Motorola SBG900
modem/router. Unlike the D-Link DI-524, it allows you
to specify a port range.
Fig.12: virtual server set-up in the D-Link DI-524. Ports
80, 20 & 21 (all TCP protocol) must be forwarded to the
WIB’s IP address and these ports, along with ports 25
(TCP) & 123 (UDP), must also be open in the firewall.
the public IP address (ie, from the Internet) to be forwarded to the WIB’s private IP address. This is where
“port forwarding” comes in.
Port forwarding is a way of making your router redirect incoming traffic on a particular port to a private IP
address on your home network. In this case, to access
the WIB’s website from the Internet, we need to redirect
incoming traffic on HTTP port 80 to the WIB’s static IP
address. In addition, you also need to redirect traffic on
the common FTP ports (20, 21) to provide FTP access
from the Internet.
Port forwarding goes under different names and
some routers may call it “virtual server” instead. You
will need to log into your router using a web browser
to change the port forwarding settings. For web access,
you need to enable forward port 80 to 192.168.0.34
while to enable FTP access, you need to forward ports
20 & 21 to the address.
Example set-ups
Let’s take a look at a couple of example set-ups, the
first being for a D-Link DI-524 router (the procedure for
your modem/router will be similar).
As explained previously, the DI-524’s set-up pages
are accessed by entering 192.168.0.1 (ie, the same as its
private IP address) into a web browser. You then enter
the username and password to log in.
Once logged in, it’s then just a matter of clicking
the Virtual Server button and defining entries to portforward TCP port 80 (for HTTP) and TCP ports 20 &
86 Silicon Chip
Fig.14: setting up port forwarding automatically adjusts
the firewall settings on some modem/routers but this
must be done manually in the SBG900. Ports 20, 21 &
80 (TCP) must be opened in both directions, while ports
25 (TCP) & 123 (UDP) must be opened in the outbound
direction only.
siliconchip.com.au
21 (for FTP) – see Fig.12. In each
case, they should be forwarded to
the static IP address of the WIB (eg,
192.168.0.34).
Note that FTP ports 20 & 21 have
to be defined separately here. Alternatively, some modem/routers let
you define a port range.
Once port forwarding has been
enabled for HTTP and FTP you will
probably have to reboot the router
for the changes to take effect.
Fig.13 shows the corresponding
port forwarding settings for the Motorola SBG900 cable modem. Unlike
the D-Link DI-524, this modem lets
you define a port range, so we only
need a single entry for FTP (ie, port
range 20-21).
Note that if you have a separate
modem and router, you will have to
turn on port forwarding (or change
the virtual server settings) for each.
It won’t work if you only do it for
the modem, for example, since the
router would then drop any incoming requests.
For example, let’s say that you
have a modem with an internal IP
address of 10.0.0.1 and a router
with a matching external address of
10.0.0.3 (ie, on its modem port) and
an internal address of 192.168.0.1.
In that case, you configure the modem to forward ports 20, 21 & 80
to 192.168.0.1. The router is then
configured to forward these ports to
the WIB’s private IP address (eg, to
192.168.0.34).
Check the firewall
Once you’ve turned on port forwarding, you also need to make sure
that the relevant ports are opened
in the firewall. On some modem/
routers, this happens automatically
when port forwarding is enabled (eg,
D-Link DI-524). By contrast, on the
Motorola SBG900, you have to open
the relevant ports yourself.
The protocol to use for both HTTP
and FTP is TCP and you have to allow traffic in both directions. In addition, you have to open port 123 to
allow NTP (or SNTP) requests to an
Internet time server. In this case, the
allowed protocol must be UDP and
you only need to allow outbound
requests – see Fig.14.
You will have to do this, regardless as to what type of modem/router
you have. Check also that port 25
(SMTP) is open for outgoing TCP
packets, otherwise the WIB will not
be able to send email (this port will
already be open if you are successfully using a PC to send email).
As with port forwarding, if you
have a separate modem and router,
you have to configure the firewall on
each. Alternatively, turn one of the
firewalls off – you don’t need both.
Step 4: Copying Files To The Memory Card
T
HIS STEP involves copying the
provided website files and the
default settings file to the memory
card. You will need a compatible
memory card and a card reader so
that you can read and write to the
card using a PC.
Many laptops are equipped with
card readers as standard or you can
use an external card reader with a
USB interface like those shown last
month. You can use any MMC, SD or
SDHC memory card to store the files,
since all three types are compatible
with the WIB.
The memory card must be formatted to the FAT/FAT32 file system.
If it uses some other file system,
then it will have to be reformatted
(just right-click the drive and click
“Format”). Note that you may want
to back up whatever was on the card
before you do this, because formatting will erase everything that’s on
it.
Next, download the file ewswebsite.zip from the December 2009
download section on the SILICON
CHIP website. Unzip this file’s contents and then copy all the unzipped
files directly to the memory card’s
siliconchip.com.au
Fig.15: the WIB’s website files must be downloaded (in ewswebsite.zip) from
the SILICON CHIP website and copied to the memory card.
root folder. After this is done, your
memory card’s root folder should
look like the screen grab shown in
Fig.15.
December 2009 87
Step 5: Configuring Minimal Settings
H
AVING COPIED the files to the
memory card, the next step is
to open the settings.txt file in a text
editor and enter in a few basic (or
minimal) settings. These are the
settings that are necessary for you to
access the WIB using a web browser
(ie, when the card is installed in
the WIB).
First, you need to determine the
gateway address of your network.
This is the LAN (local area network)
IP address of your router. Typically,
this will be either 192.168.0.1 or
192.168.1.1 but other numbers are
also commonly used (eg, 10.0.0.1),
depending on the router.
The default IP will be listed in
the router’s manual and can also be
checked by accessing the router’s
set-up pages. It can also be discovered by entering the command
ipconfig /all in a Command Prompt
window on your PC.
The resulting dialog will show not
only the gateway address but also the
IP addresses of other devices on the
network, the subnet mask, the device
MAC addresses and the addresses of
your ISP’s DNS servers.
As a minimum, the WIB must be
provided with the following information to get it working on your
home network:
•
IP Address: this is the address of
the WIB and should be an unused
address on your home network. As
stated previously, the default value
is 192.168.0.34 but change this to
suit your network if necessary (eg,
if you are using 10.x.x.x network IP
addresses).
If your network uses DHCP to
hand out IP addresses, then you
must follow the procedure described
in Step 2 to restrict the DHCP range
or to reserve a static (or fixed) IP
addresses for the WIB, to avoid conflicts. Alternatively, you can reserve
a range of fixed addresses and any
address in this range can be then be
used for the WIB.
• Gateway Address: this is the IP
address that the WIB uses to communicate with the Internet. This is
simply the LAN IP address of your
router (typically 192.168.0.1) and
can be checked as described above.
• Subnet Mask: this is the mask that
determines your home network’s
subnet. This will typically be set to
255.255.255.0 (the default) but some
networks might require 255.255.0.0.
• Primary DNS Server: this can usually
simply be set to the IP address of the
router (ie, the same as the Gateway
Address). In some cases though, it
may be necessary to enter in the
Fig.17: the WIB’s home page displays the analog input values and lets you
toggle the digital outputs on or off. You can also send data to the serial port.
88 Silicon Chip
Fig.16: the log-in dialog box for the
WIB’s website. Be sure to change the
default username and password.
address of your ISP’s primary DNS
server, as some routers don’t function as DNS relays. In particular, if
the WIB fails to pick up network
time later on, try entering your ISP’s
primary DNS server address here.
Once again, use the command
ipconfig /all to discover the DNS
addresses if necessary.
• Username: this is the username
that’s used to log into the WIB’s
HTTP server (and also to log into the
FTP server). The default is “admin”.
• Password: this is the password
that’s used to log in to the WIB. The
default is “pass”.
The settings are each entered on a
separate line and it should look like
this (default values shown):
IP Address = 192.168.0.34
Gateway = 192.168.0.1
Subnet Mask= 255.255.255.0
Primary DNS = 192.168.0.1
User = admin
Password = pass
Replace the values as appropriate
using a text editor on your PC and
save the changes to the memory card.
As a minimum, you should replace
the default “user” and “password”
values. The security of the WIB
depends on the username and password not being easy to guess, otherwise you could get an unwanted
guest logging in and inspecting your
email set-up details.
Once you’ve modified the above
parameters in the settings.txt file,
eject the memory card from the reader and insert it into the WIB (it can
only go in one way). The remaining
entries in the settings.txt file are left
as they are, since further changes are
now made by accessing the WIB using your web browser. The resulting
siliconchip.com.au
changes are then saved in a separate
binary file called values.dat.
With the memory card now in
place (and the unit connected to
your router), apply power and check
the orange and green front panel
LEDs. These should both light for
a few seconds and then the green
LED should go out while the orange
LED should flash at a 0.5s rate (ie,
twice a second), indicating that the
unit has “booted”. The green LED
inside the RJ45 connector should be
lit (indicating a valid ethernet link)
and you should also occasionally
see the yellow LED in the RJ45 connector light (ie, when data is being
transferred).
If it all checks out so far, launch
your web browser (Internet Explorer,
Opera, Firefox, Safari, Chrome, etc),
type 192.168.0.34/home.cgi in the
address bar and press Enter (note: be
sure to use the correct IP address for
the WIB if you’ve changed it from the
default IP). A login window should
now appear – see Fig.16.
Next, enter your username and
password and click OK. The WIB’s
home page should now appear
(Fig.17). This shows the values of
the four analog inputs and the state
of the four digital outputs. The latter are all off (logic 0) by default but
you can toggle then by clicking the
Toggle buttons.
You now use the WIB’s website
to change all the other settings and
we’re going to do that right now.
Step 6: Configuring The Modules
T
HIS STEP involves configuring
each module of the TCP/IP stack
in turn, beginning with the Basic
Settings.
Before we start though, note that
each time you change an entry
here, you must click its associated “Change” button to store the
value in the values.dat file. The WIB
must also then be restarted for any
changes to take effect (ie. by clicking
the “Master Reset” button.
•
Basic Settings: begin by clicking
on the Basic link to bring up the page
shown in Fig.18. This should show
all the settings you entered at Step 5,
so there should be little (if anything)
to do here. However, you may wish
to set a secondary DNS server (to
act as a backup if the primary DNS
server is temporarily out).
To do this, simply enter its IP
address and click the “Change Secondary DNS” button. Don’t forget
to reboot the WIB for the setting to
take effect.
•
HTTP Settings: Fig.19 shows
the HTTP Settings page. However,
before going further, we should
emphasise that the default values
will be suitable for most users and
can be left just as they are.
The HTTP file extension and permission settings should be modified
only by advanced users who wish
to customise the behaviour of the
WIB. If necessary, you can change
the HTTP port number (default 80)
and the file extensions, contents and
siliconchip.com.au
Fig.18: the Basic Settings page should show all the settings you entered into
the settings.txt file in Step 5 but you can make further changes here.
permissions to determine whether
files are available for public or private access.
Basically, each file that is served
by the WIB is treated differently,
according to its extension. If the
file has one of the 12 user-defined
extensions, it’s assigned the corresponding user-defined file permissions and content type. If not, it’s
given the default content type and
file permission.
The content type is specified in
the HTTP header and is known as a
“MIME-file” extension. This allows
non-html files to be opened in a web
browser, eg, pdf and gif files. Basically, the content type affects how
the browser opens, transfers and
displays the file.
Note that the file permissions
allocated to a particular file extension apply to all files with that file
extension.
There are three file permissions
and these are as follows:
December 2009 89
Step 6 CONTINUED . . .
(1) Public/Private: this determines
whether or not a user needs to log
in to access a particular file type on
the WIB.
If a file type is public, then anyone can access those files without
logging in. For example, if pdf files
are public and there’s a file on the
WIB called report.pdf, then that file
can be accessed simply by entering
IPaddress/report.pdf in the address bar
of a web browser. In this case, IPaddress is either the public IP address
of the modem if the user is accessing the WIB via the Internet or the
fixed IP address of the WIB itself if
access is via the local network (ie,
192.168.0.34/report.pdf).
Note that because the file type is
public, no log-in would be required.
Similarly, if a hostname has been
assigned (as described in the Dynamic DNS section below), then the
user would simply enter hostname/
report.pdf in the address bar.
Conversely, if a file type is private,
then the user will be required to
log in order to gain access. In fact,
special system files should be made
private so as to not compromise the
system’s security. These include the
settings.txt file, the log.txt file and
the values.dat file. All three contain
password information that should
not be public.
So, as a minimum, the “txt” and
“dat” extensions should be private
(ie, you should leave them at the
default settings).
Note that cgi files are also made
private by default. This setting
should be left as it is if you intend
using the website cgi files we have
provided for the WIB. Alternatively,
you might want to make cgi files
public if you create your own web
pages with active content.
As shown in Fig.19, quite a number of file types are made public by
default, including pdf, jpg, gif and
wav. However, you might want to
change all these file types to private,
so that no pages are accessible unless
the user logs in using a username
and password.
(2) Static/Dynamic: this file permission determines whether the
page contains dynamic content or
fixed content. This affects whether
the web server replaces dynamic
content references or only serves a
static page (we’ll explain this next
month in Pt.3).
(3) Executable/Non-executable: this
permission specifies whether or not
you can execute the commands on
html forms. This should be set to
Executable for file extensions that
contain (modified) CGI command
references – see Pt.3 next month for
an explanation of how commands
are implemented. Once again, the
default settings will be suitable in
nearly all cases.
•
In order for the SNTP client to
work, you must have a valid DNS
server address entered in the Basic
Settings. You can usually just use the
Gateway Address (eg, 192.168.0.1)
here but if the NTP client fails to
pick up the correct time, use your
ISP’s DNS server address.
Begin by clicking on the SNTP
link to bring up the page shown in
Fig.20. The default time server value
is pool.ntp.org but there are lots of
other NTP servers on the Internet
and you can change the default server to any of these. The default port
number is 123. This will only need
to be changed in rare circumstances
and then only if you have advanced
knowledge of port forwarding.
Note that the time obtained by
SNTP is UTC (Coordinated Universal Time) time. This means that
Fig.19: the HTTP Settings page lets you set the file permissions. Do not modify
the default values unless you know exactly what you are doing.
SNTP Settings: this page sets up
the SNTP client so that it accesses
an Internet time server (eg, to timestamp logging entries).
The “epoch time” is the reference
for SNTP and the 32-bit number
returned as a result of a time query
is the number of seconds that have
elapsed since this reference time.
For a typical NTP server, this is set
at 00:00 on January 1, 1970.
90 Silicon Chip
siliconchip.com.au
you need to specify an offset value,
depending on your geographical
location, to convert to local time.
The east coast of Australia (Sydney, Brisbane, Melbourne) is 36,000
seconds (ie, 10 hours) ahead of UTC
and so 36000 is the default value
here. Adelaide and Darwin are 9.5
hours ahead of UTC, so the value to
use is 34200. The offset for Perth is
25200 (ie, 7 x 60 x 60).
In practice, it’s just a matter of
checking how far your region is
ahead of UTC time and entering the
value in seconds accordingly. Note
that if you live in a part of the world
that is behind UTC (eg, Canada & the
US), you have to specify a negative
number. For example, if you are
four hours behind UTC, you would
specify an offset value of -14400.
Finally, the NTP page has provision for you to enter in the start and
Fig.20: the default NTP server and port values will be suitable in most cases.
Enter in an offset value to suit your time zone and the daylight saving details.
end dates for daylight saving, so that
the time automatically adjusts. You
also need to enter the daylight sav-
ing offset (eg, 3600 seconds for one
hour). Setting this offset to “0” turns
daylight saving off.
•
FTP Settings: clicking the FTP
link brings up the page shown in
Fig.21. The default port values
shown here for the FTP server (ie,
20 & 21) should generally be left as
they are but some advanced users
might want to change them under
certain circumstances.
The timeout is the amount of time
that is allowed to elapse without
activity before the client is disconnected. This is an automatic logout
in case you forget to do so. The
default is 600s (10 minutes).
There are many FTP client programs for Windows and other operating systems but many of these
won’t work with the WIB because
it doesn’t implement the full FTP
command set. The way around this
is to use a command line program
called ftp. You invoke it from a
command prompt simply by typing
“ftp x.x.x.x” where x.x.x.x is the IP
address of the WIB.
If the IP address is valid, you will
be prompted for the log-in username
and password.
As stated, the WIB’s FTP server
only implements a subset of the full
FTP command set. However, the
main commands such as get, put,
cd, pwd, dir, delete, user and pass
are all available, as are the macro
commands mget and mput (batch
siliconchip.com.au
Fig.21: the default FTP setting can usually be left as they are.
Table 1: FTP Commands
CD: change directory.
PWD: show the current directory.
DELETE: delete a file.
DIR: show the files in the current directory
and the file sizes.
LS: show only the name of the files in the
current directory.
PUT: send a file to the ethernet web server.
GET: retrieve a file from the WIB.
get and put commands respectively).
In particular, the mput command
is useful for uploading an entire
website to the WIB if you don’t wish
to transfer the files directly using a
MGET: retrieve a collection of files from
the WIB.
MPUT: send a collection of files to the
ethernet web server.
USER: specify the username for login.
PASS: specify the password for login.
OPEN: open an FTP connection to a
remote server.
QUIT: exit the current FTP session.
PC and a memory card reader.
Table 1 sets out the available FTP
server commands. We’ll give an
example FTP session in Pt.3 next
month.
December 2009 91
Step 6 CONTINUED . . .
Fig.22: the SMTP Settings page. Click the “Email Test” button after entering in
all the details, to verify that it works.
•
SMTP (Email) Settings: clicking
this link brings up the dialog shown
in Fig.22. This is where you enter
your email settings, so that the WIB
can send emails.
The SMTP port can be left at its
default of 25, so start by entering in
the address that you want the WIB
to send emails to. That done, enter
in the hostname of your ISP’s SMTP
server. For example, the Bigpond
SMTP server is at mail.bigpond.com
while the Optus SMTP server is at
mail.optusnet.com.au
Note that the SMTP server will be
specified in your usual email client
(eg, Outlook Express), so it’s easy
to check. Alternatively, check your
ISP’s website for the hostname of
their SMTP server.
Next, fill in the “Email From”
field. This will typically be your
name or your email address but you
can also use any other name.
Finally, enter your email username (usually your full email address) and your email server pass
word. Don’t forget to click the cor-
responding “Change” button as each
field is completed.
Now click the Email Test button.
This allows you to check that your
SMTP configuration is valid. If all is
well, a test email will be sent each
time you click this button and you
can verify this by clicking the Basic
link and scrolling to the bottom of
the system log on that page (note:
you may have to reload the page to
update the log file from the version
cached by your browser).
If it doesn’t work, try resetting
the WIB after changing the SMTP
settings to ensure that the changes
have taken effect. This is done by
clicking the “Master Reset” button
on the Basic page or you can restart
the WIB by switching it off and on.
Note that an error code is returned
on each failed email attempt and this
is useful for debugging.
Once you’ve got it working, the
WIB will start sending email notifications as follows:
(a) each time a master reset is performed;
(b) when the IP address of the WIB
is changed;
(c) when an analog input breaches
its set limits; and
(d) periodically (if enabled) when
the required number of log entries
is reached.
•
Dynamic DNS Settings: although
the IP address of the WIB itself is
fixed (eg, to 192.168.0.34), its public IP address (ie, that presented to
the outside world by your modem)
may change. This is because most
ISPs assign dynamic IP addresses
for specific “lease” periods (eg, 12
hours) rather than hand out static
addresses. This is a way of making
the most of the limited range of IP addresses assigned to a particular ISP.
Because the public IP address
assigned by your ISP may change,
and since this address must be used
to access the WIB from anywhere
outside your home network, we
need a way to automatically keep
track of any address changes. A common method for doing this is called
“Dynamic DNS” (Dynamic Domain
Name System).
This is a service that keeps track of
a dynamic IP address by associating
92 Silicon Chip
Fig.23: the Dynamic DNS Settings page requires entries for the public IP
server and the dynamic DNS server.
it to a static hostname. For example,
you could associate the hostname
silchip.redirectme.net to your current
dynamic IP address and the system
siliconchip.com.au
Fig.24: you can set up a dynamic DNS service for the
WIB by pointing your web browser to www.no-ip.com
will then automatically track any
future changes.
This is exactly what we need
for the WIB so that it can be accessed from the Internet by using
its hostname rather than its public
IP address.
Dynamic DNS will work with a
static IP address too. However, in
this case, it would not have to keep
track of any IP address changes.
Instead, you would use the DNS service simply for the convenience of
being able to use a hostname rather
than an IP address.
A dynamic DNS client is built into
the WIB, so setting up the service is
straightforward. The first step is to
set up an account with a dynamic
DNS provider at either www.no-ip.
com or www.dyndns.com. You will
need to sign up to a free account at
one of these.
Once that is done, the WIB will
automatically log in to your account
on a regular basis. It will then update
its public IP address on the service if
it detects it has changed. There may
be a delay of up to 10 minutes until
the changes are fully propagated but
once they are, you will be able to
again access the WIB using its fixed
hostname.
Note that many modem/routers
also include a dynamic DNS client. In practice, you could use this
siliconchip.com.au
Fig.25: once you’ve created an account, log go to www.noip.com/members and click the “Add A Host” button.
instead of the one in the WIB but
we’ll assume here that you’ll be using the latter.
OK, let’s take a look at how you
would go about setting up an account at www.no-ip.com
Begin by pointing your web browser to http://www.no-ip.com and click
the green No-IP Free button – see
Fig.24. Type in your email address
and click the “Sign Up Now” button,
then follow the prompts to create
your account. Once you’ve created
your account, log in by going to www.
no-ip.com/members
Your home page will look something like Fig.25.
Now click on the “Add A Host”
button, type in a hostname of your
liking and choose a domain from the
list of available names. For example,
we chose silchip for the name and
redirectme.net for the domain to get
the hostname silchip.redirectme.net
Now click on the “Create Host”
button to complete setting up the
dynamic DNS host.
Having created the host account,
the WIB must now be set up to log
into this account when it detects
a change in its public IP address.
This is done by first clicking on the
Dynamic DNS link to bring up the
page shown in Fig.23.
A number of settings now need to
be entered in the Dynamic DNS Settings page, beginning with the public
IP server. This is basically an HTTP
server that allows you to determine
your current public IP address (ie,
as assigned by your ISP).
A suitable public IP server is at
checkip.dyndns.com and this is the
default (note: IP servers that return
a full html page, such as whatismyip.
com, can not be used).
Do You Really Need Dynamic DNS?
It’s not always necessary to set up a dynamic DNS service. In particular,
if you have been assigned a static IP address by your ISP, then the WIB
can always be accessed over the Internet using this fixed public address.
Similarly, if you have a dynamic IP address, this is unlikely to change if the
modem is permanently powered up. And even if the modem is switched off
for a short time or there is a power interruption, it will be assigned its previous
IP address provided it is within the lease period. So again, depending on
you application, you might not want to bother setting up a dynamic DNS.
December 2009 93
Step 6 CONTINUED . . .
To check this, enter checkip.
dyndns.com in the address field of
your browser. You should receive a
simple html file response containing
your public IP address. It will look
like this:
Current IP Address: 165.221.92.134
except the IP address will almost
certainly be different (ie, it will show
your current public IP address).
So that’s how the WIB determines
its public IP address. This discovered address is displayed on the
Dynamic DNS Settings page (Fig.23).
The public IP server port should
be set to 80, which again is the default (it can be changed if necessary
by advanced users).
For the Dynamic DNS server, you
have to enter the hostname of the
server for the particular account
you’ve just created. If you are using
the service at www.no-ip.com, enter
dynupdate.no-ip.com as the server.
Alternatively, if you are using the
service at www.dyndns.com, you
should enter members.dyndns.org
The dynamic DNS server port
should normally be left at 80 (the default). You should set force updates
Step 7: Configuring The ANALOG VARIABLES
Fig.26: the Variables set-up page allows you to define and set up the various
parameters (including minimum & maximum limits) for the four analog
inputs. In this case, we have set up a temperature sensor on Variable 0.
F
IG.26 SHOWS the analog variables set-up page. This has fields
for each of the four analog inputs
(ie, Variable 0 to Variable 3). You
only have to enter data for the sensors used. For example, if you have
a temperature sensor connected to
input AN0 (pin 9 of CON3), then
you only have to enter data into the
Variable 0 fields.
Before going further though, we’ll
make it easy for you. If you are using
the AD22103 temperature sensor,
enter a value of 0.11663409 into
the Gradient field and -8.928571429
94 Silicon Chip
into the Y-intercept field. It’s then
just a matter of entering the number
of decimal points, the minimum and
maximum limits for email notification (see below), the logging period
and the number of logging entries.
Let’s look at all this in greater detail. The Raw Value is the digitised
ADC (analog-to-digital converter)
value. This value will be between 0
and 1023 (inclusive), as this is a 10bit conversion. Remember that the
voltage range will be from 0V (GND)
to 3.3V (ie, the 3.3V rail voltage).
If the sensor has an output voltage
to 1 and then enter the username
and password to log into the account
you created with your dynamic DNS
provider.
That completes the dynamic DNS
set-up. You should now be able to
use the hostname to browse the
website on the memory card from
anywhere on the Internet. In our
case, we chose silchip.redirectme.net
as the hostname, so the home page
can now be accessed from the Internet by entering silchip.redirectme.net/
home.cgi in a browser and logging in.
That’s easier to remember than
using 165.221.92.134/home.cgi to access the WIB.
range greater than this, you will need
to add a voltage divider (consisting
of two resistors) to bring the voltage
fed to the WIB’s input back within
the 0-3.3V range. This is then taken
into account when “calibrating” the
sensor by setting the gradient and
y-intercept values in the WIB.
From the raw value, the actual value of the input variable is calculated
using the gradient and y-intercept
values as follows:
value = gradient x raw + y-intercept
This means that, in order for readings to be accurate, you will need
to enter the correct gradient and
y-intercept values for the particular
sensor being used (note: we are assuming that the sensor has a linear
response).
Let’s consider the AD22103 temperature sensor, for example. This
can measure temperatures ranging
from 0-100°C and its output is “ratio
metric”.
From the data sheet, its output
voltage (Vo) is given by the formula:
Vo = (Vs/3.3) x (0.25 + 0.028 x T) . . . (1)
where Vs is the actual supply voltage
to the sensor (slightly less that 3.3V
because of the series 110Ω resistor)
and T is the temperature (0-100°C).
As stated, the raw value is the
ADC value and is determined by
the equation;
raw = (Vo/Vdd) x 1023 . . . (2)
where Vdd is the actual voltage of
the 3.3V supply rail.
Rearranging and plugging this into
siliconchip.com.au
equation 1 gives the temperature as
a function of the raw value:
T = (3.3 x Vdd)/(Vs x 1023 x 0.028) x
raw – (0.25/0.028)
or
T = (0.1152073733 x Vdd/Vs) x raw
- 8.928571429
In practice, Vs will be about 3.23V,
while Vdd will be about 3.27V.
Therefore, the correct values for
the gradient and Y-intercept for this
temperature sensor are:
(1) Gradient = 0.11663409; and
(2) Y-intercept = -8.928571429
These values must be entered in
the Variable 0 gradient and Y-intercept fields respectively (assuming
the sensor is connected to AN0).
You can also enter in minimum
and maximum limits for the sensor.
When these limits are breached, an
email is sent automatically. If the
measured value drops below the
minimum limit, the file var0min.
txt appears in the email body. Conversely, if the maximum limit is
exceeded, var0max.txt is included.
For Variable #1, the corresponding
files are var1min.txt and var1max.
txt and so on.
Note that a 10% limit value hys-
teresis is included in the firmware to
prevent too many emails from being
sent in a short time, eg, if the temperature is fluctuating about a limit.
You can also enter the name of the
variable being monitored. For example, if you have a temperature sensor
connected to Variable #0 (AN0), you
can give it the name “Temperature”.
This name will then be used in the
log file and will also be referred to in
any limit condition email messages.
The Log Period field lets you
enter a number that sets the logging
interval in minutes (0 = logging off).
The system adds to the log until the
number of log entries reaches the
number entered in “Set Log Size”
field. At this point, the log file is
automatically emailed to the specified email address and then cleared,
ready for the next logging cycle.
For example, suppose the Log
Period is set to 10 minutes and the
Log Size is set to 144. In this case,
the input value will be logged every
10 minutes (along with the time
of day) and after 144 such entries
the whole log will be emailed and
then cleared. As a result, an email
containing the logged entries will be
sent once every 24 hours.
Similarly, setting the Log Period
Step 8: CREATE THE NEW DEFAULTS
T
HIS FINAL STEP is short and
sweet! Once you’ve made all
the changes to the settings, go to the
Basic page of the supplied website
and click on the Create Defaults button. This will make your settings the
new defaults and create a new set-
tings.txt file with these new defaults.
That completes the set-up of the
WIB. Next month, we’ll describe the
special system files that make up the
website and also briefly describe
how to design your own website
with active content.
to 10 minutes and the Log Size to 12
will result in the log being emailed
every two hours.
Finally, you can edit the text in
the various “.txt” files to suit your
application and the content is dynamic, ie, a number of variables can
be included. When the email is sent,
the system replaces these variables
with the relevant information.
For example, the content of var0
max.txt is as follows:
The ~1E is currently at ~D0 which
is above the set maximum of ~1C!
This is an automatically generated
message, created on ~E2.
In this case, 1E is the name of Variable #0 (“Temperature” in our case),
D0 is the current value of Variable
#0, 1C is the maximum limit set for
Variable #0 and E2 is the current
time. So, for example, the actual
message that’s sent could be:
The temperature is currently
at 31.0 which is above the set
maximum of 30.0!
This is an automatically generated
message, created on Fri 28 August
2009 17:00:00.
We’ll describe this in greater detail
next month and post a table listing
the dynamic page content codes on
our website.
Network Addresses
If your modem/router uses a 10.x.x.x
private (ie, inwards facing) IP address,
then you should change the IP address
of the WIB to suit this network – eg,
to 10.0.0.34 if the network is 10.0.0.x.
That’s done by editing the settings.txt
file on the memory card as described in
Step 5. All other settings including the
DHCP range, the Gateway address and
the primary DNS address should also
be changed accordingly.
Accessing The WIB’s Website From The Internet
Inside your home network, you can
access the WIB home page simply by
entering 192.168.0.34/home.cgi in the
address field of your web browser and
then logging in.
Accessing the WIB’s website is just as
easy from anywhere on the Internet. First,
you can access it by using its public IP
address; eg, 165.221.92.134/home.cgi
Alternatively, if you’ve set up dynamic DNS
siliconchip.com.au
as described in Step 6, you will be able to
access it by using the hostname defined in
your dynamic DNS account. In our case,
the hostname is silchip.redirectme.net
and so we can access the WIB using the
address silchip.redirectme.net/home.cgi
Alternatively, you can go to another page
(not necessarily in the root folder) by using a forward slash and the filename. For
example, if we want to access a file named
mydocument.doc in a sub-folder called
documents, we enter silchip.redirectme.
net/documents/mydocument.doc in the
address field of the browser.
Of course, this also works inside
your local network, ie, we would enter
192.168.0.34/documents/mydocument.
doc into the browser. Note that you can
not access the WIB using the hostname
SC
from inside the network.
December 2009 95
|