System
Home automation system. Application consists of tornado server and jquery/bootstrap frontend. Backend logic is pure python and consists of 3 main paralel threads. One for communication with server. One for communication with modbus network. Last one for calculation of system logic behaviour.
Install / Use
/learn @dzon4xx/SystemREADME
Intelligent home system
List of content
- Preview
- Purpose
- Hardware
- Software
- System in action
- Installation
- Conclusion
Preview
In this manual I will describe intelligent home system which I have to developed. It is based on Raspberry Pi which serves as web server and logic master. All system functions are provided by Atmega slave boards. I will briefly explain how the hardware works. Later on main software concepts will be shown. At the beginning I would like to emphasis that I will be extremely happy if somebody would like to cooperate with me on the project. I can supply you with the hardware needed :)
| System hardware | House maquette |
| :-------: | :-------: |
|
|
|
Purpose
Purpose of project is to build intelligent home system which is reliable, scalable, modifiable and cheap. In my opinion reliability can by only achieved by using wired network between system nodes. Modular topology gives scalability as you can easily extend system by adding extra modules. I did my best to write simple understandable and modular Pythonic code so it would be easy to modify operation of the system. Talking about cost it is widely known that RPi is a cheap computer (about 20$). Same goes with slave boards for which production price oscilates between 30-50$ depending on the board.
Hardware
Core of the system is widely known Raspberry Pi computer (it basically may be any other linux or windows computer). It is connected with Atmega based boards (which I have developed) by RS485 twisted pair cable. RPI serves as web server and logic master. It is connected with the internet to handle traffic from clients to system and vice versa. It also sends and reads modbus messeges to and from slaves.
For the present time i have developed 5 different slaves boards. All are based on Atmega328 micro controller which can be found in Arduino. They can be powered from 10V-24V AC/DC. All of the communicate via RS485 physical interface. All boards have top board with TX and RX leds indicating communication and pulsating RGB led indicating board status.
These are:
- Output board
Purpose of output board is to turn on and off electric appliances. It is equipped with 10 relays so it can control 10 devices. In addition, the board has special top with 10 leds each indicating state of corresponding relay.
| Output board | Output board top |
| :-------: | :-------: |
|
|
|
- Input board
Purpose of input board is to get states of on/off devices such as Reed switches, switches, PIR sensors, smoke sensors. This board is in prototype state and was made as RPI shield - Led light board
Purpose of led light board is to dim DC appliances. Most often it would be LED stripes. It has got 3 channels controlled by mosfet transistors. Voltage can be regulated from 0 to 100% by the PWM.
| Led light board |
| :-------: |
|
|
- Ambient board
Purpose of ambient board is to gather information from sensors. Currently the board supports ds18b20 temperature sensors DHT22 humidity and temperature sensors, BMP180 pressure and temperature sensor, and analog sensors such as fotoresistors for light level measure.
| Ambient board |
| :-------: |
|
|
- Glow light board - (Not used in project)
The board is very similar to Led light. Rather than DC it controls AC voltage by firing Triacs. It has got 3 channels so for example 3 glow bulbs can be dimmed.
| Glow light board |
| :-------: |
|
|
Software
Code consists of 3 main modules. These are backend, server and client. This graph explains relations between software modules and system.

There is also configuration script which populate database with all necessary data
Language
I have chosen Python language to implement system logic and server. Client code is implemented in javascript/html/css.
Terminology.
I will now explain terminology used in system. It will give you a basic glance at system operation principal.
System is made from components. These are:
- Elements - all input and output devices connected to system. For example, sensors, switches, lights, heaters etc.
- Modules - Boards that are connected to RS485 net.
- Relations - Relations between elements. I have implemented two types of relations:
- Regulations. They control output element based on feed element value to maintain set value.
Turning on and off heater to maintain desired temperature - Dependencies. They consist of cause and effects. If the cause is evaluated to true, then effects happen in desired time after cause.
When light level is less than 20% and soil humidity less than 30% then turn on soil irrigation (Evening irrigation)
- Regulations. They control output element based on feed element value to maintain set value.
- Rooms - House rooms. For now, purpose of room is only visual. They store reference to elements that are in the room. It allows to display system topology in client application.
- Groups Also visual purpose. They aggregate elements with similar functions. For example, heating group aggregates temperature sensor, heater and temperature regulation set.
Client application

For the present moment client view is very simple. Its purpose is to display all elements organized in groups and rooms. Client layout is generated by server. Js code is responsible for authorization, communication and system values update. In future I would like to improve client side in such way that server will send only representation of system - (elements id's, types and relations between elements). Client would then generate view by itself.
Server application
As a server i have used Tornado webserver. It is lightweight fast and easy to use server. It supports websockets which are the way to exchange information between clients and system in the real time. Server's responsibilities are:
- Authorization of users
- Generation of visual system structure (In the future i plan to pass this task to client code)
- Exchanging information between clients and logic.
Backend application
Backend consist of three main threads. These are:
- Communication thread - Holds websocket connection. It listens to server incoming transmission and sends messages to server which are generated by logic thread.
- Logic thread - Takes care of evaluation of relations in system and checks messages from communication process. If any relations evaluate to true or there are commands to be done from clients it creates task list which is passed to modbus thread. It also checks element's "new_value_flag" which are set by modbus thread whenever any element has new value. If so then appropriate message is passed to communication thread buffer.
- Modbus thread - It is responsible for communication with slave boards. It polls all input boards as fast as it can. It is important to achieve low response latency. If there are any tasks to be done appropriate message is sent to output boards.
Configuration script
In the script you can define system. First you should add all the modules connected to network and rooms in your apartment. Then you can add as many input and output elements as you want, specifying to which module are they connected and in which room are they placed. At the end you define regulations and dependencies between elements.
System in action!
Video presents operation of system: https://www.youtube.com/watch?v=Z7VvjViKQB0&feature=youtu.be
Installation
System can be installed on linux and windows machines. Server and client application can be run without any additional hardware. If you would like to run backend you are going to need Arduino to emulate system board. I will now write down all steps starting with Server. If you have any problems, please let me know.
Common steps:
- First of all you need to install python 3.5
- Then install pip for easy packages installation. On Linux just type
sudo apt-get install pip3.5On windows: tut - Install packages used in project:
sudo pip3.5 install pyserial websocket-client coloredlogs tornado dominate - All imports statements in the code are relative to system directory. To make python see this directory as environment directory you should add
system.pthfile in site-packages directory. you can find the directory by typing in python shell:
import site site.getsitepackages()
Config steps:
- In your favorite code editor open system/backend/config/config.py. The file contains factory class for creating system. At the bottom you can see example configuration and explanation on how to configure system
- Run config and create database located at system/backend/sys_database/sys_database.db . Of course you can use default configuration which is already in database supplied.
Server steps:
- With the console open navigate to system/server_client and type python3 start.py (insure that you have python3 in your system path)
- Script should run and it is going to show that rooms were loaded
- Go to your browser and type: localhost:8888. You should see client view.
Backend steps:
- First of all you are going to need Arduino with modbus slave code. You can find slave modbus library here.
- Example code for inpu
Related Skills
node-connect
350.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
