Smarthome control center with ArduiTouch part 2 - the data protocol

of This contribution to the principle of messages transfer between the Central and the remote devices (in the following simply called devices) explain. Since the devices should be easily built and, if possible, no manual settings should require, was designed by the following principle.

  • A device uses its MAC address to identify
  • A new device must be active on the Central register
  • So that a device with the Central data exchange may need it once manually on the Central register.

Structure of a message is:

struct ATMSGPACKET {
uint8_t id[6]; //id of the remote device typical its MAC address
uint8_t packets; //number of packets in the message,
uint16_t device bits; //bits to control the device capabilities
};

, The Header of a message has 9 Bytes. The first six Bytes contain the Id followed by a Byte with the number of channels (maximum of eight). Thereafter, a 16-bit Unsigned Integer follows. Each of these 16 Bits has a different meaning and indicates capabilities of the station or specifics of the data packets. Bit 0 determines whether the device is passive, that is, from the Central queried needs to be. Bit 1 specifies whether the transmission interval of an active device can be changed from the control panel. Bit 2 indicates that a checksum is formed over the entire message, is appended at the end of the message. The Bit 3 shows that data packets are encrypted (in preparation for later versions). Other Bits are currently not defined. According to the Header of data packets for each channel.

struct ATDATAPACKET {
uint8_t channel; //channel as an identification
uint8_t type; //type of the packet
uint8_t unit; //unit of the packet
uint8_t value[4];//four data bytes to hold a long integer or a float
};

, A data packet starts with a Byte for the Kanlanummer followed by a Byte with the type of the transport direction as well as Info to the data type contains. 0= Integer message from the device to the control center, 1= Float message from the device to the Central office 2= the Integer message from the Central unit to the device, 3= Float message from the Central unit to the device, 4 Boolean message from the device to the Central and 5 Boolean message from the Central unit to the device. Next, a Byte for the following unit ordered. Some units are already defined and more are to follow. And finally, four Bytes to record the value of consequences. These are interpreted according to the type as a Float or 32-Bit Integer. For the Boolean messages, only Byte 0 is used.

The end of the data exchange:

1. Active device

Active devices are typical Sensors used. Send in fixed or variable intervals, data to the Central unit. Or, for example, a doorbell button, or wireless switch, whenever someone presses the button.

If the device is still no Central is known, it searches the WLan to an Access Point with the SSID "ATSmartHome". This was found he remains of the device as long as the power supply was not interrupted. At this access point, messages to be sent with the Id of the device.

If the Central (Access Point) receives a message, it is first checked whether a device is registered with the received Id already. If not, the data will be ignored and displayed in the control unit that a new device was found. In the Central unit must then be this device registered to receive data.

The device is if it is registered, the checksum specified tested. This is Ok, the data will be stored. The active device remains ready after the Send for a short time. In this time, any existing data can be.to Send to the device or if the device capable of configuration changes are sent, such as, for example, a new interval of time from the Central to the device

2. Passive device

Passive devices are always ready to receive. But also, the passive device transmits at intervals messages to the Central. This serves on the one hand, to registration and on the other hand, to the Headquarters to inform of the channels to which the device can receive data.

If the device is still no Central is known, it searches the WLan to an Access Point with the SSID "ATSmartHome". This was found, the device starts as the active send data periodically to the Central office.

Is received in the Central office a message from a non-registered passive device, is displayed the Id of this device as a new device and can be manually registered. With the Information from the received data packet, the Central determine is the channels to which the device is ready to receive. A passive device can also simultaneously broadcast on other channels measured values to the Central. When the control panel detects a passive device, and a switch is actuated on one of the channels of this device, it sends the Change to the corresponding channel of the device. If the next receive data from the passive device, the channel is not the desired value, the Change is sent again. This is to prevent a lost message, a switching operation is not executed in the device.

Attention! If someone has already loaded the ATMessageBuffer library, he ought to get the latest Version and the sketches to compile this library using new. This is necessary because I have extended the data structure ATMESSAGEPKT the Variable device bits.

I hope to have the necessary information to develop new devices with this Central compatible. A first passive device, which can switch on a Relay will follow soon.

 

 

 

 

Projects for advancedSmart home

Leave a comment

All comments are moderated before being published

Recommended blog posts

  1. Install ESP32 now from the board manager
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP programming via WLAN