Ryan Herbst

First Zigbee Sensor

by on Jan.17, 2012, under Home Automation

I just finished my first Zigbee radio project. The purpose of this project is to add a front entry gate sensor to my home automation system in addition to experimenting with Zigbee radios. The picture below shows the radio container to the left and a magnetic switch on the gate opening to the right.

The Zigbee radio is powered by two AAA batteries. The entire circutry is contained in a small black project box which shelters the radio and batteries from the elements. The circuit below shows how the radio is wired.

The normally open magnetic switch is connected to GND on one side and a 2K pullup to VCC on the other. When the gate opens the switch is closed pulling the resistor side of the switch to GND. The pullup side of the switch is connected to digital input 4 on the radio as well as the DTS signal. The input 4 connection allows the radio to read the current state of the gate while the DTS connection forces the radio to wake up and send a signal the moment the gate is opened.

In order to guarantee the longest possible battery life the radio is configured to sleep for 20 seconds and then wake up for 2 seconds. Each time the radio wakes up it polls the digital input at a 2hz rate resulting in four measurements each time the radio wakes up. When the gate is opened the de-assertion of the DTS signal wakes the radio up immediately. This ensures that a gate open-close cycle is not missed and will send a message alerting the moment the gate is opened.

The RF messages are received by the Zigbee radio attached to my Linux server. I use a modified version of the C++ Zigbee API. When a state transition on the gate is detected an XPL security.zone message will be generated on my XPL network which is then logged in my MySql database. If no transition is detected for 15 minutes a XPL status message will be generated when the next update from the Zigbee radio is received. This functions as a heartbeat to show that the radio is till functioning. Each time the radio reads the digital input state it also monitors the battery voltage and the measured value is recorded in the database. This allows me to monitor the battery life of the radio. One of the purposes of this project is to see how long a battery will last in this configuration.

A picture of the radio mounted in the top of the project box.

The antenna protruding through the top of the box along with the two sensor wires. Both are sealed with epoxy in place to keep the box water tight.

The break out board attached to the Zigbee radio. Minimal amount of wiring and a single passive 2K pullup resistor.

The receiver radio mounted in the upper part of the garage. My weather station receiver can be seen on the right.

End point Zigbee radio settings:

  • D4 = 3 : Set D4 as a digital input.
  • IR = 0x0258 : Poll input at 2Hz
  • SP = 0x07D0 : Set sleep period to 20 seconds
  • ST = 0x07D0 : Set sleep timeout to 2 seconds (wake time)
  • SN = 0x1 : Number of sleep cycles = 1
  • SM = 0x5 : Periodic sleep with pin wake
  • V+ = 0x0C0C : Report battery voltage when below a high threshold.

I am now working on two more Zigbee projects.

The first is a a sensor for the front car gate so I can know when it is open and closed. This sensor will include a relay driver to close or open the gate from my home automation system.

The second project is a Zigbee/Arduino based custom thermostat.

:, ,
No comments for this entry yet...

Comments are closed.

Amaroq Weather Station

Beresford Ave, Redwood City, CA
temp: 66.6 F (19.2 C) (19.2)
humidity: 65%
wind: Calm
pressure: 29.95" (1014.1 mb)
station: KCAREDWO4
hardware: WMR918
updated:August 23, 9:37 PM PDT
local forecast