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.
sary 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 net-
work number, which allows more
than one system to coexist. The base
unit reacts only to messages with a
matching network number and prop-
erly formatted data packet.
De
vType 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 sen-
sor type to be identified by the base
unit. Error is a “1” for a problem that
requires attention and a “0” other-
wise. 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.)
T
he
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.
IMPROVEMENTS
As usual, I thought of numerous
ways to improve this project even
before I finished. For instance, inte-
grating an Ethernet interface and
TCP/IP stack will allow for a web serv-
er that can be checked from anywhere
via an Internet connection. And since
text messages can be sent to some cell
phones by e-mail, this will allow
alerts to be sent right to a cell phone.
Additional sensors will greatly
expand the system’s capabilities. I
want to design a sensor that can
check the position of a deadbolt lock,
Comentarios a estos manuales