Start System
Overview Installation
& Operation Garage
Door Module Water
Level Module Temperature
Module Hardware
Design Garage
Door Sensor Water
Level Sensor Temperature
Sensor Software
Design Improvements Peace
of Mind Sources
and PDF
SOFTWARE
DESIGN
For
software development, I used the Metrowerks Codewarrior
development environment that came with the contest
kit. Freescale’s Simple MAC software provided
everything necessary to get data flying between
the sensors and base unit. All I had to worry
about was the data format to transmit the sensor
information.
I
decided on the data packet format shown in Figure
4. NetNum is the network number, which allows
more than one system to coexist. The base unit
reacts only to messages with a matching network
number and properly formatted data packet.

(Click
here to enlarge) |
Figure
4—Take a look at the wireless data packet
format. Twelve bytes carry the network number,
device type, device number, error code, and
data. All but the data have 48 added to push
them into printable ASCII characters. The
letters between fields allow the detection
of a valid packet. With the <CR><LF>,
they make debugging easy by dumping packets
to a terminal window. |
DevType
identifies the sensor type. For example, the garage
door sensor was assigned a device type of 1. DevNum
allows more than one of the same sensor type to
be identified by the base unit. Error is a “1”
for a problem that requires attention and a “0”
otherwise. Data is the actual sensor data.
The
letters between fields and the CRLF allow for
the detection of a properly formatted data packet.
They make debugging easier by allowing the raw
packets to be dumped out the serial port and read
with a terminal program. (The first four fields
are bytes, and 48 is added to transmit in readable
ASCII characters.)
The
remainder of the software for the remote sensors
is simple set-up and calibration code. It’s followed
by a loop that periodically wakes up, checks the
sensor, transmits the data, and goes back to sleep.
The remainder of the base unit software is the
set-up code followed by code to monitor the sensor
data (and react appropriately) and to monitor
and process incoming telephone calls.