eHouse 1 Home Automation, Building Managerment System C++ open source programming Linux

eHouse Home Automation & Building Management Open Source C, C++, Object C software for different Linux distributions and hardware.

Control and management of eHouse4Ethernet and eHouse1 building automation.

This article is an extension for c++ programming for linux.
Connecting eHouse Building Automation to “PC” has been described for various Linux distributions in earlier post.
Description of the eHouse1 transmission frame RS-485 and the status of the data structure are discussed in earlier articles .

This artice describes the source code, written in C++, to support, manage and control eHouse home automation system from any device containing the Linux operating system in any version.

At the time of writing this article C++ server has the following features:

  • eHouse1 home automation RS-485 / RS-232 / USB connected to PC board
  • Time synchronization for controllers
  • sequential query sending for status of the controllers
  • Send general temperature measurement (internal temperature, outside temperatures: southern, nortern, western, eastern, light level from programmed sensors) to be processed by controllers
  • Receiving logs from controllers
  • Receiving confirmation of IR Transmit events (for external devices) and receiving (remotecontroller sony) for processing by the server
  • transfer events and confirmations between eHouse1 smart home controllers (as a gateway)
  • Posting events to control eHouse1 home automation controllers
  • Loading status to the matrix as a structure for direct decoding of binary status
  • Can create your own control algorithms based on the received status of the drivers and send events to eHouse1 home automation system

    Software in the form below does not include only

    • impossible to change the configuration of home automation controllers eHouse1
    • impossible to upgrade firmware of eHouse1 smart home controllers

      what is achievable only by eHouse.exe application for Windows.

      The configuration must be set in definition file eHouse Home Automation – open source Linux configuration c globals.h:

      ETHERNET_EHOUSE = 0 (default, Ethernet eHouse and eHouse1 managed by CommManager ) – enable support for RS-485 / eHouse1

      EHOUSE1_DEVS_COUNT = x (where x is the highest AdresL of RoomManager – default 15) in the case of a too low number of controllers, devices with a higher number AddressL does not manage to send their status to the software, because another request will be initiated (Query). This parameter affects the time between successive submissions of queries about the status, time synchronization, etc.

      COM_PORT – This definition contains the path of the serial port (default: / dev/ttyUSB0 – for the USB / RS-232 dongle) because especially for microcomputers it is difficult to find a RS-232 serial port). It is not recommended to edit this setting manually , but uncomment lines with the appropriate serial port name (ttyUSB0..2 for usb dongles or ttyS0..2 for RS-232 without USB adapters).

      STATUS_ARRAYS_SIZE – the size of status matrix for eHouse1 controllers must be greater then top AdresL of RM. Do not change this number by hand but uncomment required amount due to the fact that this value is used as a mask for the index table status. Otherwise, the indexes of some drivers will be overlapped, and will be sequentially overwritten. (Default is 15 RM and if we do not have more than 15 RMs should not change anything).
      Further are definitions for RoomManager and their sensors perform measurements of the external temperature and lighting – specify index eH [ADRL] where ADRL – component of the lowest address – must be less than the size of the matrix status eH[]

      • T_NORTH_RM – eH [ADRL] RM measures the outside temperature – north
      • T_NORTH_ADC – Number of ADC input [1 .7] – is connected to the outdoor temperature sensor – north
      • T_SOUTH_RM – eH [ADRL] RM measures the outside temperature – South
      • T_SOUTH_ADC – Number of ADC input [1 .7] – is connected to the outdoor temperature sensor – South
      • T_WEST_RM – eH [ADRL] RM measures the outside temperature – West
      • T_WEST_ADC – Number of ADC input [1 .7] – is connected to the outdoor temperature sensor – West
      • T_EAST_RM – eH [ADRL] RM measures the outside temperature – east
      • T_EAST_ADC – Number of ADC input [1 .7] – is connected to the outdoor temperature sensor – east
      • T_ROOM_RM – eH [ADRL] RM measuring the internal temperature – for HeatManger for Central Heating System
      • T_ROOM_ADC – Number of ADC input [1 .7] – is connected to temperature sensor – for HeatManager for Central Heating System
      • LIGHT_LEVEL_RM – eH [ADRL] RM measures the light levels outside
      • LIGHT_LEVEL_ADC – Number of ADC input [0] – to which the sensor is connected, the external light level

      All eHouse1 controllers building automation must be configured in extended address mode for the software to work properly (status, sending events, communication events between controllers via software).
      Please use the following address AdresL from 1 because the software for the convenience of the status of the controller stores the status to eH [AdresL] matrix with the index equal to the low byte of address. The cell 0 is occupied by HeatManager status if it is installed in the system.

      After proper setting these parameters and configuring the application is ready to work.
      The source code is located under the following links:
      eHouse1 Home Automation Linux open source C++ support RS-485
      eHouse1 Building Managerment Server Linux open source C++ whole server

      The entire eHouse1 server is started by one function ‘int uart(void)” which is in an infinite loop.
      That loop can be interrupted only by exiting the application or launch the “TerminateUart()”.
      This application is a software template mostly for educational purpose, and there is no support for multi-threading communication processes.
      It is characterized by minimal to allow the understanding, learning, teaching, and support eHouse1 home automation system, and not to create advanced Server in binary form that meets the requirements of all.

      To enhance its functionality “uart()” function should be put to individual thread with a low or lowest priority limited by equipment (microcomputer board) performance and sufficient computing power. Very beneficial it would also load a configuration from a text files which does not require to continuously compile source code in case of the simplest change the settings.

      The sending system events eHouse in “DirectEvent” mode function is used:
      “void SendDirectEventeHouse1(const unsigned char *evt)” – it allows direct sending the event to the control smart home EHouse one working on the RS-485 interface. The parameter here is a string variable long 10B, written in binary code containing a system event in the following form
      evt[0] – Adrha
      evt[1] – ADRL
      evt[2] – command
      evt[3] – arg1 (arguments appropriate for the command)
      evt[4] – arg2 (arguments appropriate for the command)
      evt[5] – arg3 (arguments appropriate for the command)
      evt[6] – arg4 (arguments appropriate for the command)
      evt[7] – Arg5 (arguments appropriate for the command)
      evt[8] – arg6 (arguments appropriate for the command)
      evt[9] – arg7 (arguments appropriate for the command)

      Noteworthy is the “void RS485PerformData(void)” that runs periodically on receipt of all status and performs data processing and sending events.
      for example,
      RS485PerformData void (void)
      if ((eH[0].HM.OUT.o1) && // output 1 is switched on HM AND
      ((EH[1].RM.OUT.o7) || (eH[2].RM.OUT.o11)) & / / Any of outputs 7 of RM (55.1) or 11 of RM (55.2) is turned on and
      (((EH[1].RM.ADC[1].MSB < < 8) + eH[1].RM.ADC[1].LSB)> 0x230)) // ADC measurement sensor [1] from RM (55.1) is greater than 0x230 (absolute value)
      {// Start event for RM (55.3) output setting 9 to 32 seconds
      SendDirectEventeHouse1 ((unsigned char *) “\x37\x03\x01\x09\x01\x1f\x0\x0\x0\x0”);
      { // Start event for RM (55.3) Output ( turn off
      SendDirectEventeHouse1 ((unsigned char *) “\x37\x03\x01\x09\x00\x0\x0\x0\x0\x0”);

      You can enter any of control algorithms for eHouse intelligent system greatly expanding the functionality of the system in relation to standard version.

      eHouse Home Automation – server software C++ source codes/open source

      eHouse Building Management – Open Source C++ software source code for listener of UDP datagrams – eHouse for Ethernet controllers.

      For more information about the software open source C++ for eHouse.

      Inteligentny Dom eHouse – Programowanie C++