Skip to content

Communication protocol

Stanislav Șcerbatiuc edited this page Feb 9, 2016 · 1 revision

The communication protocol

Represent the rules of gathering and sending the required information to the server, which is responsible for analyzing the received data. In order to minimize the data sent by the Arduino Board, which is the device with the least amount of hardware capabilities, the protocol used for communication should be the most simple possible, but also to leave room for later sensibility, as for example, adding new sensors to the board and differentiate them.

Protocol structure

The String being sent by the Arduino Board contains the following information:

  • Light sensor value (in lux) prefixed by the uppercase L (ex: L 123)
  • PIR sensor value, which can be only 0 or 1 because of sensor's hardware capabilities, prefixed with the uppercase letter P (ex: P 0 - in case there is no movement detected or P 1 - in case there is movement)
  • Heartbit message indicator, prefixed by the uppercase letter H. Basically, the Arduino Board sends messages about sensors' state when this state changes. When there is no change, meaning there is no movement in the room, nor the light levels have changed, there is no sign of the system actually working. To ensure this, every 60 seconds, the Arduino Board will send one message, no matter if there is an actual change in sensor's state. This message is called heartbeat message.

The full structure

Every portion of this information is divided using "|" character. Every sensor state value's prefix is divided of the actual value by one space. A full example of typical message sent by the Arduino Board has this form: H 0|L 123|P 1, which signifies that it is not a heartbeat message, there is ~123 lux of light captured by the sensor and there is movement detected in the room.

Clone this wiki locally