Using the Presence Detector

ravinrabbid edited this page Mar 30, 2012 · 2 revisions
Clone this wiki locally


The presence detector application can use any device (like a motion sensor or a switch) to detect presence in a room or house and broadcasts a message with EID 26 on a change. It keeps a detection for a given timespan after it is detected. Sensors can also be grouped, to monitor detections for different areas. The detection status can also be read out manually via EID 26.

What you need

  • 1 Device running the server application
  • 1 to x Devices running the client applications
  • 1 to y Devices to detect presence (Motions detectors, push buttons etc.)

All these things can be run on one hexabus device or distributed however you want.


in firmware/contiki-2.x/platform/Hexabus-Socket/hexabus_config.h set PRESENCE_DETECTOR_ENABLE to 1.

For the Client set PRESENCE_DETECTOR_CLIENT to 1, PRESENCE_DETECTOR_CLIENT_GROUP to something between 2 and 255 (e.g. all clients in the living room belong to group 2...) and PRESENCE_DETECTOR_CLIENT_KEEP_ALIVE to a value in seconds (the client repeats its broadcast all n seconds while presence is detected) or 0 (to disable the keep alive).

For the Server set PRESENCE_DETECTOR_SERVER to 1 and PRESENCE_DETECTOR_SERVER_TIMEOUT a value in minutes (the server will keep "Presence detected" on for n minutes after the last broadcast received from a client.

If both Client and Server are running on the same hexabus device, configure both these values on the same device.

State machines

On the Client you need a state machine which, if it gets a broadcast from the corresponding sensor, writes a value different from 0 and 1 to EID 26 if the sensor detected presence and a 0 if the sensor does not detect presence anymore.

On the Server you need a state machine which, if it gets a broadcast with EID 26 and the corresponding group id, writes a 1 to EID 26.

See Example state machines