You are on page 1of 8

Copyright Circuit Cellar Inc.

Reproduction of this publication in whole
or in part without written consent from Circuit Cellar, Inc. is


by Dan Beadle

Wireless Water Heater
Some people like to remotely start their cars when it’s cold outside. Dan took this idea one
step further by Internet-enabling his mountainside retreat’s hydronics system. The Airbornebased system allows him to warm the house well in advance of his arrival.


have built scores of embedded
devices ranging from banking terminals
to semiconductor fabrication controllers. These devices have used a variety of processors from 4 to 32 bits. The
nearly universal theme of these embedded devices has been communications.
Few devices exist as islands unto themselves. I have used RS-232, RS-422,
RS-485, LonWorks, Ethernet, and others. I am always on the lookout for a
better way of communicating.
Wireless communications always have
been attractive. Eliminating wires makes
the product look cleaner and simplifies
connecting. At one of my prior companies, we did some pioneering work
15 years ago networking VHF radios.
Those industrial products made it to market in spite of being slow and expensive
(approximately $1000 per node). This system helped me understand the issues and
complexities of the radio media. The
design problems—such as interference,
data dropouts, hidden nodes, and roaming
across access points—have not changed,
but they have been solved and standardized with 802.11. (Well, at least
802.11b 11 Mbps is stable.)
I have been enticed by some of the lowcost radio modems. Many of them work
in the 450-MHz industrial band. They are
attractive because of their low cost and
the fact that they are low power/unlicensed. But I always go back to the problems that we had with our VHF network:
to get a good, reliable system, we would
be inventing RF-friendly protocols that
deal with temporary interference recovery, frequency hopping (if supported by
the radio), and so on. Suddenly, my timesaver technology becomes a time-sink


Issue 163

February 2004

quagmire. So, I go back to tried-and-true
options like Ethernet and RS-232.

Technologies announced its Airborne
module at the Sensors Expo in
Anaheim, California last September, I
ordered an evaluation kit on the spot. I
believe that my purchase order, which
is written on the back of one of my
business cards, was their first order!
The Airborne evaluation kit arrived
promptly (see Photo 1). I was surprised
that it was completely turnkey. Even
though I have Wi-Fi in my office, they
assume the worst and provide a complete
package, which includes all the imaginable cables as well as a Netgear Wi-Fi
Gateway. Following the quick-start guide,
I had the demo up and running quickly.
The Airborne module is designed to
mount directly to my PCB. Although
it has a 36-pin connector, many of the
pins may be left open (see Figure 1).
Unlike the PC Card dumb radios,
the Airborne module is a complete
application processor that combines

802.11 MODULES
The price of PC card 802.11b modules has fallen through the floor. I
often see cards from reputable companies advertised for approximately $20.
This component price is attractive
and fits great into WinCE solutions.
Just add a PC card interface and go.
Unfortunately, most of my deeply
embedded designs are cost-sensitive.
Doing a WinCE design adds between $50
and $75 for bigger CPUs, more memory,
and a PC card socket. So, a $20 Wi-Fi
card really costs between $70 and $95
in my design. Consequently, I have not
jumped on using PC Card modules.

I had been looking for an embedded
RF solution for years, so when DPAC

128K × 3


512K × 3

Airborne wireless LAN node module

Web server
TCP/IP stack
Command interface
I/O support

802.11b Radio




2.5 V

2.5-V Ref

VDD 3.3 V





RF Status

Figure 1—The Airborne module includes everything needed for remote data acquisition and control.

Reproduction of this publication in whole or in part without written consent from Circuit Cellar. I wantRESET ANT1 Wireless ed to use port F2.3. where I have server. it seemed generation prototype (see Figure 2). I decided that I wanted betvacationed for years. which sets the port direction antenna register to output. (And it was not at all feasible to remove the paneling. Its primary purpose tions processor and digital I/O appears to be for remote sensFigure 2—The heater water flow valves are controlled by a relay driven by the Airborne’s DIO port. eight analog making it a snap for the heater system down around 50°F to keep the pipes 10-bit ADC inputs with a built-in to keep warm. After a little fumbling to reread the directions (Who really does that?). www. and one high-speed heater. Prototyping LAN node G2 First. but it’s the firstphysical packaging to attach it to my the house with a fixed IP. But it does provide a simple their own. VPN into my desk computer and use it on a PCB with an RS-232 level shifter I had been thinking for a while about to access the Airborne web server and and a power supply. Interfaces hardware design trivial. include eight digital I/O ports Normally. the port must be set to output area module ANT2 with the IO-Dir F2 Out CLI comG3 External mand. I was browsing the Airborne server from my desktop via two wireless hops. All of this costs approximately $80.Copyright Circuit Cellar Inc. So. I can manage the start up the mountain. I arrive module to disable it. status of a medical infusion pump. an available GPIO. I decided to start with this simple solution in an Figure 3—The evaluation kit includes a prototyping area and headers to connect to all of the module pins for easy effort to protect against the possibility breadboarding. I considered using an X10 server does not allow me to directly thermostat. Then.) GETTING EMBEDDED Wireless makes the probThe Airborne module is lem a lot simpler: there are no designed for embedded appliwires to run. I plan to mount the module through the night. network settings. I have a small. is well insulated. is prohibited ter reliability. and I instantly will Internet-enabling the system. I would that design. I late and shiver in my jacket for three might drop below 50°F. More importantly. I have DSL at Kludgy? I guess. supply G1 radio settings. way to do it via telnet by issuing command line interpreter (CLI) commands. After CONNECT authentication. controlling RP-SMA the relay is as simple as IO-Write F2 1 Peripheral Mixed signal High-speed Communication I/O to set the relay on. was to turn on the heater before we a relay connected to a digital output. My first-cut strategy was 2. after a few of our WIRELESS HEATER CONTROL control the digital I/O from the web X10-enabled lights found a mind of My mountain home. like it would be a simple task to enable The first release of the Airborne web a thermostat. on the module make the ing and control. customer’s pump. For house. I started planning a cable from my office/DSL entry up to the logical thermostat CIRCUIT CELLAR® Issue 163 February 2004 61 . I/O Signals the radio and a 120-MIPS web server CPU into a small 1″ × 1. efficient from freezing. ISP and debug header POST Serial port To provide a basic layer of security. I set all of my thermostats (3. Inc.g. Then I procrastinated. but enough immediately incorporated Airborne or four hours until the house warms into a bid for a system to monitor the up—and that does not warm the entire heat will transfer from the other 50°F zones to keep it from freezing. it takes forever to to simply set the living room thermoserial port (up to 921. I have access to a rich RS-232 9-V set of CLI commands that let me conG0 Battery Power trol all aspects of the module (e. The idea turn on the living room thermostat via have an RS-232-to-Wi-Fi converter. Header for development access Although it isn’t perfect.and 5-V tolerant).5-V reference. LINK DB25F DB9F the Airborne server requires userPower TX RTS RX CTS Power WLN CFG jack name/password authentication. Then. and the applicacations. The living room with ideas about how to apply this. Typically. just the portion needed to get before going up the mountain. I could not bring myself to run the wires along the surface of my redwood paneling. but. My next thought was to use simple copper to do the hook-up.circuitcellar.6 kbps) warm the house from a 50°F standby stat to 70°F and then use the DPAC My imagination started running wild to a livable 68°F. In my case..5″ package. however. and therefore serial enable it to warm my house to 70°F. and RF ACT digital I/O settings).

The system is kind of like the boiler/radiator system. Although my system was state-of-the-art when it was installed a few years ago. Reproduction of this publication in whole or in part without written consent from Circuit Cellar. Plastic PEX coils are placed in the floor. and even in the towel holders. but when I have a house full of guests. The rooms are well insulated and may only drop 1° per hour. The single boiler concept allows an extremely efficient heater to supply all of the house’s heating . I often run out of hot water.asmx over the ’Net to the ASPX server Communicating with Airborne server Web service (2) Interfaces to LAN via TCP/IP to Wi-Fi Data acquisition Airborne module (3) Acquires ADC Counts Heater. This seems really stupid. The lower temperature results in lower pressures.circuitcellar. it’s just heated to between 180° and 200°F and circulated to the various rooms. is prohibited Figure 4—The selected sensors interface directly to the Airborne’s ADC ports. of my system failing and the house freezing—not a pleasant thought.vb Table 1—In addition to listing the tasks. along the walls. I have found the 50-gallon water supply more than adequate for three or four people. The same hot water is circulated over and over throughout the house to rooms calling for heat. CIRCUIT CELLAR® www. which you may download from the Circuit Cellar ftp site. IN HOT WATER I have a hydronics system with a single boiler for both my space heating and water heating needs. but the hot water tank drops several degrees per minute. The cooler water refilling the holding tank explains some of this. I often find myself taking a cold shower in the morning. which allows heat radiators to be placed in creative ways.Copyright Circuit Cellar Inc.vb CLI.aspx HeaterController . except the water is not boiled. I’ve provided you with names of the appropriate files. Why bother heating four space zones when the water tank needs to heat my shower? My ultimate goal is to reduce the heating control system to an embedded processor bolted to the heater system in the basement. But I have speculated that most of the slow recovery in winter is because the energy from the combustion is going not only to the water tank but also to warm the rooms. For one thing. it is not without limitations. Inc. Before designing Task Server Comment Listing Data presentation ASPX Server (1) (see Figure 3) Focuses on the user experience Data server Web service (2) Wraps the data and presents it GetZones. The same recirculated water is fed to a 62 Issue 163 February 2004 heat exchanger/holding tank to supply hot water to the faucets in the house.

Inc. Reproduction of this publication in whole or in part without written consent from Circuit Cellar. is prohibited .Copyright Circuit Cellar Inc.

Copyright Circuit Cellar Inc. Reproduction of this publication in whole or in part without written consent from Circuit Cellar. Both sensors use the same I need to be able to access my heater these two sensors for their simple hook-up (see Figure 4). For now. I must have a degree of security. per 1°C for temperatures from –30° to .com . tain formulas converts counts back to transfer functions and to cover the The next step in the process of temperature. Furthermore. =  ADC Counts × × 1024 Counts  evaluation kit because I could directly used for ambient temperatures.4 mV per data I wanted is available count. which 1000 mV   10°C  − 600 mV  × connect the sensors (see Figure 3). exchanger efficiencies. Applying cerat the heater. I consider 64 Issue 163 February 2004 CIRCUIT CELLAR® www. More importantly. or area. I have been told that the next version of the DPAC system will let me directly view the temperatures and control the relays via Java Script. can reach to –15°C on occasion. understanding the system had to do The LM35DZ has a range from 0° to 2. I added VB.5-V reference. I selected 100°C.circuitcellar. . I don’t want hackers reprogramming my shower. counts rather than in So.5 V 1000 mV 10°C = ADC × × × each of the five zones (four space quate for the recirculation system.NET. the next step was data direct physical measgathering. To do that. With the release of . The cal data seemed to be Airborne module anamonitoring calls for heat log-to-digital convertfrom the various zones and er provides 210 steps of Photo 1a—T he Airborne evaluation kit comes with a Wi-Fi access point. The about 2. and a prototyping understanding the heat the 2. the complexities of the data acquisition system are hidden from the .5-V range of the analog-to-digi 2. The 0. Let’s dig into the key 1000-mV output is with. the data server can be anywhere. this sensor is ade2. For the LM35DZ: needed temperature ranges.NET to my tool kit. I elected to use the tal converter (ADC). cables. For instance.NET technology to build a simple. This small. The LM61CIZ is Temp. I have spent most of my career programming in C or C++.NET allows processing to be compartmentalized across servers and disciplines. I needed to connect 1°C. It proV mV   I chose a couple simple temperature vides a simple output of 600 mV + 10 mV sensors from National Semiconductor.NET WEB SERVER the LM35DZ and LM61CIZ. Because the water should nei1024 Counts V Temp.For the LM61CIZ: temperature sensors to the Airborne in the 2. with algorithms.5 V wireless module. system has several important benefits. Inc. The general topology is shown in Figure 5. Unlike prior versions of VB.aspx web programmer. but powerful.5 square inches. I have to issue Airborne CLI commands. I decided to use . however. I could do the output is in that faster on my desktop. and data acquisition and display are decoupled for simpler maintenance. is prohibited the system. not in my office. I Like most analoga) b) wanted to experiment to-digital converters.5 V 1000 mV × mV = ADC Counts × with monitoring temperatures coming 100°C. b—The DPAC module provides a complete Wi-Fi embedded processor in 1. Refer to Table 1 to see how I broke up the tasks of displaying the current temperatures. = mV × 10°C out of the boiler and returning from ther freeze nor boil. secure system to access the Airborne server. The most critiurements. It 1024 Counts V mV heating zones and one water heating provides a simple output of 10 mV per zone). controller over the ’Net for it to be useful.

You may download the complete listing for this file and all of the other files from the Circuit Cellar ftp site. This provides a rich wrapper around the lower-level Sockets class. Issue 163 February 2004 65 .NET class. One of the key features is its full support for object-oriented programming (OOP). a Wi-Fi access point.VB provides a TCP/IP link to the Wi-Fi bridge and ultimately access to the Airborne module (see Listing 1).Copyright Circuit Cellar Inc.NET a real language. CLI. Listing 1 shows the Class Inheritance for CLI and its subclass. inherits from Sockets.circuitcellar.NET built-in class TcpClient. I elected to dump them to the debug console and continue. As with the other routines. www. As you can see in Listing 1. Windows uses 2-byte Unicode characters. most of the code involves catching errors.NET. The Open routine is where the magic happens. HeaterController inherits these tools to do the real work of sending CLI commands to the Airborne controller and formatting the results (see Figure 6). HeaterController. Reproduction of this publication in whole or in part without written consent from Circuit Cellar. I find I program desktop applications much faster than in the past. there are only a couple of functions that I added in my CLI subclass: Open.NET AND INHERITANCE TCP/IP clients are extremely simple with . The ’Net is based on TcpClient. HeaterController Zone temperature Ambient temperature CLI Open Telnet connection Unicode read/send CR Tcp Client –Sockets wrapper Sockets –TCP/IP Routines Figure 6—The HeaterController borrows features from the TCPClient through inheritance. 1 ASPX Web server ’Net Web service server 2 C 3 Wi-Fi base station Figure 5—Serving up the current temperature involves several computers. is prohibited VB.VB CLI. Read. CLI further refines TcpClient to provide telnet connection setup and conversion between Unicode and ANSII. Inc. Finally. The inherited TcpClient Connect method is used to handle all of the details of establishing a telnet con- CIRCUIT CELLAR® nection with the host on port 23. They also use the socket stream underlying the TcpClient to perform the actual reads and writes from and to the network link. The CLI Class inherits from the . and SendCR. The bulk of the routines call the system encoding methods to convert between ASCII and Unicode. a built-in . . providing a programmer-friendly wrapper to Windows TCP/IP socket services. Read and Send routines perform similar functions. and the DPAC Airborne module.

Read(Data. n) Console. which are all in a readable XML format. I have included three public properties: RelayState (r/w).ASPX file.. which inherits from CLI.Sockets ****************************************************************** // Heater Controller . With web pages.asmx provides a simple WebMethod wrapper around the HeaterController object (see Listing 2). 0.vb use inheritance to access Windows TCP sockets. SelectedUnits.Read() Dim i As Integer = R.Substring(i + 2) Return Val(R) End Function ' See Site for complete source End Class ****************************************************************** // TCP/IP Class to talk to Airborne module ****************************************************************** Public Class CLI Inherits TcpClient Dim Stream As NetworkStream ' The Socket stream ' Open Telnet Connection with remote host Overridable Sub Open(ByVal hostname As String) Try Me..vb and CLI.Net. Update simply fetches the temperatures for each zone and populates a text box.IndexOf("0x") ' replace 0x with &h If i >= 0 Then R = "&h" & R. but that would mean hosting the display page on my home server. It then closes the object to drop the telnet connection to the Airborne module. Other methods End Class CIRCUIT CELLAR® www.ToString()) System. I used one little trick to store the F/C state. The helper routine ADC(n) gets the counts for a given Airborne port by sending adc-read g followed by the port number. With . It then reads the response and converts the hex count string to an integer.Text.5 * 100 . One converts between Fahrenheit and Celsius.ASCII. AmbientTemp (ro). I prefer to use a web service that sits behind a firewall. n. ’Net controls automatically store their state from call to call. A cool thing about web services is how easy they are to test.GetString(Data.Connect(hostname. and so on. Note that the web service passes an array of floating-point temperatures.NET ’Net controls to display the data (see Listing 2).WriteLine("SocketException: {0}".aspx uses .Inherits from CLI and TcpClient // See HeaterController. I created HeaterController. So.NET.Threading. Imports System.. and ZoneTemp (ro). and the other forces an immediate update of the web page. e) End Try End Sub ' Read response from Airborne Function Read() As String Dim Data As Byte() = New [Byte](256) {} ' Read the first batch of the TcpServer response bytes. you had to perform a lot of tricks to store state information.SendCr("adc-read g" + Port. Reproduction of this publication in whole or in part without written consent from Circuit Cellar. Other private functions provide the interface to the Airborne analog-to-digital converters and perform the count-to-temperature calculations. Listing 1—These excerpts from HeaterController. I invoked the service directly from a web browser.vb on Circuit Cellar ftp site ****************************************************************** Public Class HeaterController Inherits CLI ReadOnly Property AmbientTemp() As Integer ' Ambient Temp in C Get Return LM65(2) ‘ Ambient is ADC port 2 End Get End Property ' ADC Conversion Routine for Ambient Private Function LM65(ByVal Port As Integer) As Integer ' Read LM65 Dim V As Single = ADC(Port) / 1024 * 2..Copyright Circuit Cellar Inc. Data. The Update routine does most of the work by creating a web services object and using it to access the Zones WebMethod running on a different 66 Issue 163 February 2004 (and firewalled) computer. SERVING UP THE ’NET Heater.Sleep(100) ' Wait for response Dim R As String = Me. The key CLI commands are listed in Table 2. I decided I needed more functionality.vb right in the . I decided to further subclass CLI to add new functionality. The Zones WebMethod builds an array and populates it by creating a HeaterController object and using it to get each ZoneTemp.Encoding. s) Return s End Function ' . Other than that trick. So. HeaterController’s job is to issue the actual CLI commands needed to manipulate the Airborne application layer. To keep things simple. Dim n As Int32 = Stream.Text.VB After getting the CLI layer debugged.Thread.circuitcellar.WriteLine("Telnet Connection Opened") Catch e As SocketException Console.Length) Dim s As String = System.5) End Function ' ADC Access Routine Private Function ADC(ByVal Port As Integer) As Integer Me. I decided to store the unit’s type in an invisible label. Instead. In the old days. is prohibited HeaterController. I don’t like that idea from a security standpoint. WEB SERVICE WRAPPER I could put the HeaterController. 0. each server query is an independent event. which inherits from TcpClient. the ASPX code is plain vanilla.WriteLine("Read {0}".60 Return Int(V + 0. 23) ' Open host on telnet port Stream = GetStream() ‘ Use inherited method Console. GetZones. Inc. Two buttons are .

if there is a small spread between the desired and actual temperature but <System.NET calls this “consuming a Issue 163 February 2004 67 . It then invokes the Zones method to return the array of single precision temperatures. and motion (the latter two to help preprogrammed 2004/163.circuitcellar..WiFiHeater ' create link to WebService on Dan Dim Z() As Single = Ws.” The web page’s Load routine simply creates a WS object to connect to the web service provider Wi-FiHeater on server dan.Web.ToShortTimeString() End Sub End Class www. I have decided to <WebMethod()> _ go ahead and add a microcontroller to Public Function Zones() As Single() Dim Z(6) As Single ' Array of floats manage the valves.Text = "Last Updated " & Now. (800) 642-4477 www.Load Dim Ws As New dan. and they will display current temperature and target temperature. the ultimate Wi-Fi heater controller! I Z(5) = Heater.WebService(Namespace:="http://tempuri. Reproduction of this publication in whole or in part without written consent from Circuit Cellar.ZoneTemp(5) Heater. but it will also integrate ' Local Address the outside sensors.national. I simply format them into a text box and mark the update time. For examImports System.Web.EventArgs) Handles MyBase.dpactech. The controller will do ' Create Object to access WiFi server all the things that typical zone setback Dim Heater As New HeaterController("192. in Physics from UC Irvine and an M.A. You may contact him at dan.Close() Heater. for sure.Text = "" ' Clear out the text box For i = 1 To 5 ' display temp for each zone TextBox1. from Pepperdine University.Copyright Circuit Cellar Inc.A.Text += "Zone " & i. He has a B. SOURCES Airborne evaluation kit and Airborne module DPAC Technologies Corp. PROJECT FILES To download the code.circuitcellar. In addition to using these sensors in the rooms.Services. Inc.168.UI. Furthermore. go to ple.WebService These will report to the heater controller in the basement.ToString & ": " & Units(Z(i)) + vbCrLf Next lblUpdated. ***************************************************************** // Heater Web ASPX web page (DotNet) ***************************************************************** Public Class WebForm1 Inherits System. I am off to build the ultimate temperature management system. ByVal e As System.B. Private Sub Page_Load(ByVal sender As the sun is shining. HeaterService/Service1")> _ Public Class WiFiHeater or wait for nature? Inherits System.60") thermostats do.. Listing 2—Web services wrap the HeaterController object and convert to XML—all behind the scenes. Dan has been developing embedded systems for more than 20 years. it will Z(0) = 5 ' Zones(0) holds number of real zones Z(1) = Heater. they room will monitor temperature. . lightwill provide the option of overriding ing. From there. is prohibited For obvious reasons. Sensors in each detect occupancy).beadle@inclinesoftworks. And. Note that Airborne requires lowercase commands.ZoneTemp(1) give priority to my shower! Stay tuned for . I plan to put them outside ****************************************************************** to monitor outside air temperature so I Excerpts from HeaterService ****************************************************************** can make better decisions.Dispose() Return Z End Function End Class Listing 3—These excerpts from Web Client demonstrate the consuming of a web service.Web. WHERE FROM HERE? CLI Command Function Example Auth io-write adc-read Authenticate (log in) Write to port bit Read ADC counts auth user pw io-write g0 1 adc-read g2 Table 2—CLI commands are necessary for manipulating the Airborne Now that I am capturapplication layer. Listing 3 gives a skeleton for using the HeaterService web service. (800) 272-9959 LM35DZ and LM61CIZ Temperature sensors National Semiconductor Corp. should I heat now. this public view of my page does not expose the relay control. ing data.Web.Page ‘ Page Load Routine .111.Zones()' Zones returns array of temperatures Dim i As Integer CIRCUIT CELLAR® Dan Beadle leads a contract product development company that takes products from concept to production.first time loaded.