OpenHAB and home controller - make iron
Having successfully docked a simple Modbus device with the OpenHAB platform , I immediately wanted to do something useful for the home. In the nearest online store were purchased wiring, breadboard, modules and sensors for Arduino, and a roll of blue electrical tape.
That's how I secured myself an exciting lesson for the coming weekend. At first it was fun, but soon the confusion of wires began to strain, and the hope of experiencing this miracle in combat conditions was melting every minute. It seemed that the wires were trying to crawl on their own, and the design was scattered from every careless movement. And at that time new ingenious thoughts were already being born in my head ...
It was decided that we need to design a board, to which it will be easy to connect all these sensors and cram into it everything that is needed for automation. And if other devices are hung on OpenHAB on the same bus, we get an excellent smart home system:
So, what should be implemented first?
- pressure measurement; temperature and humidity;
- monitoring the condition of windows and doors, motion sensors, protection against fire and leaks;
- access control using IButton and RFID keys;
- contact monitoring and control of actuators through discrete inputs and outputs;
- control of several remote temperature sensors via the 1-Wire interface;
- control of additional sensors, contacts and control of actuators via a radio channel.
Ok, let's get down to hardware design.
Let's try to implement the functions we need, using the most popular sensors and modules from Arduino, adding everything together we get this structure:
We figured out the design, it's time to start developing the board.
Among fans there are so few good installers, so I did not create any difficulties for them, I chose a rather large size of resistors and capacitors - 0805, left a decent gap between the elements and made the components marking by silk-screen printing. All elements were placed on a 68.6x53.3mm board whose design corresponds to the Arduino UNO expansion module.
The prototype of the printed circuit board developed at PCAD was sent to Rezonit for the manufacture of prototypes in urgent production. After a few days, the boards and the pre-ordered equipment were already with me. Just a couple of days with a soldering iron and now the thought has acquired a real shape!
It remains to hang the module on the Arduino and here it is, the long-awaited controller!
Working with such a device is a real pleasure! It was easy to test individual nodes using standard libraries and examples for Arduino. Errors and inaccuracies in the design and layout were found and corrected, of which there were not so many.
But the problem, known in advance, manifested itself with particular clarity, its essence was the “single tasking” of Arduino. Reading one sensor interfered with the work of others, stopping the exchange with OpenHAB.
Looking ahead, I’ll say that I was able to solve this problem, for which I had to rewrite part of the libraries, arranging a kind of multitasking with timer interrupts. But more about that in the next publication, which will be devoted to software.
What happened as a result of the work:
A prototype of a reliable and compact output input controller for the Smart Home system has been created, which can be used not only for experiments, but also in real conditions, it can serve as a good basis for the development of other devices.
The modular design allows you to easily change the configuration of the controller, provides ease of testing of sensors and components included in its composition.
An important feature of the controller is ease of assembly and adequate cost even in pilot production, which can positively affect its popularity.
What remains to be done before manufacturing a full-fledged version of the controller:
1. Make corrections in the circuit and design, eliminating errors and shortcomings found during alpha testing.
2. Install a connector for connecting the WiFi module of the ESP8266 instead of the HM-11 module, while designing an adapter board for the HM-11 with the same pinout of the connector.
3. Provide a Grove or DFRobot standard connector for remote connection of a DHT11 humidity sensor.
That seems to be it, a diagram and additional information on the progress can be found on the vk.com/myremoter project page.
Previous publications on docking Arduino with OpenHAB system via Modbus protocol can be viewed here :
How to make friends OpenHAB and Arduino habrahabr.ru/post/248569
Arduino & Modbus habrahabr.ru/post/249043
Arduino & OpenHAB habrahabr.ru/post/252555
That's how I secured myself an exciting lesson for the coming weekend. At first it was fun, but soon the confusion of wires began to strain, and the hope of experiencing this miracle in combat conditions was melting every minute. It seemed that the wires were trying to crawl on their own, and the design was scattered from every careless movement. And at that time new ingenious thoughts were already being born in my head ...
It was decided that we need to design a board, to which it will be easy to connect all these sensors and cram into it everything that is needed for automation. And if other devices are hung on OpenHAB on the same bus, we get an excellent smart home system:
So, what should be implemented first?
- pressure measurement; temperature and humidity;
- monitoring the condition of windows and doors, motion sensors, protection against fire and leaks;
- access control using IButton and RFID keys;
- contact monitoring and control of actuators through discrete inputs and outputs;
- control of several remote temperature sensors via the 1-Wire interface;
- control of additional sensors, contacts and control of actuators via a radio channel.
Ok, let's get down to hardware design.
Let's try to implement the functions we need, using the most popular sensors and modules from Arduino, adding everything together we get this structure:
Hardware Brief
The BMP180 sensor is used to measure pressure, in addition, it monitors the temperature. Reading data from the BMP180 is via the I2C interface. An MCP23017 input / output port expander is connected to the same bus, providing control of eight external inputs / outputs and LED indication of the controller and security loops.
For humidity measurement, the DHT11 sensor has its own single-wire interface. In the future, it is necessary to provide for the possibility of installing this sensor outside the controller case.
To control the outdoor temperature, water temperature, heating radiators and indoor temperature, DS18B20 sensors connected to a common 1-Wire bus were used.
The second 1-Wire interface works with I-Button keys, it is used in the functions of arming and disarming, control of the electric lock. Next to it is the output of the security mode indicator, it can be connected to the LED located on the key reader's pocket.
Security sensors through matching circuits are connected to the inputs of the ADC of the controller, thus, four standard security loops are implemented that allow you to control the integrity of the line and detectors with normally closed and normally open contacts.
The radio channel is made on the most common and cheap radio module for Arduino made on the NRF24L01 chip. The transceiver operates at a frequency of 2.4 GHz, the main disadvantage of this is the small radius of action due to poor signal transmission through concrete walls. But this disadvantage can easily be turned into an advantage by placing several gateway controllers in the apartment, while some sensors will not interfere with others located in other rooms and apartments.
For direct communication with mobile devices designed BLE (Bluetooth Low Energy) transceiver HM-11. It will allow you to integrate Apple’s iBeacon functions as well as Google Nearby or physical-web into the device. Later, during the discussion, it was decided to provide for the possibility of replacing the HM-11 Bluetooth module with an inexpensive WiFi module based on the ESP8266, which should expand the application of the controller, for example, wireless connection to a host controller or router or connecting WiFi sensors and devices.
For humidity measurement, the DHT11 sensor has its own single-wire interface. In the future, it is necessary to provide for the possibility of installing this sensor outside the controller case.
To control the outdoor temperature, water temperature, heating radiators and indoor temperature, DS18B20 sensors connected to a common 1-Wire bus were used.
The second 1-Wire interface works with I-Button keys, it is used in the functions of arming and disarming, control of the electric lock. Next to it is the output of the security mode indicator, it can be connected to the LED located on the key reader's pocket.
Security sensors through matching circuits are connected to the inputs of the ADC of the controller, thus, four standard security loops are implemented that allow you to control the integrity of the line and detectors with normally closed and normally open contacts.
The radio channel is made on the most common and cheap radio module for Arduino made on the NRF24L01 chip. The transceiver operates at a frequency of 2.4 GHz, the main disadvantage of this is the small radius of action due to poor signal transmission through concrete walls. But this disadvantage can easily be turned into an advantage by placing several gateway controllers in the apartment, while some sensors will not interfere with others located in other rooms and apartments.
For direct communication with mobile devices designed BLE (Bluetooth Low Energy) transceiver HM-11. It will allow you to integrate Apple’s iBeacon functions as well as Google Nearby or physical-web into the device. Later, during the discussion, it was decided to provide for the possibility of replacing the HM-11 Bluetooth module with an inexpensive WiFi module based on the ESP8266, which should expand the application of the controller, for example, wireless connection to a host controller or router or connecting WiFi sensors and devices.
We figured out the design, it's time to start developing the board.
Among fans there are so few good installers, so I did not create any difficulties for them, I chose a rather large size of resistors and capacitors - 0805, left a decent gap between the elements and made the components marking by silk-screen printing. All elements were placed on a 68.6x53.3mm board whose design corresponds to the Arduino UNO expansion module.
The prototype of the printed circuit board developed at PCAD was sent to Rezonit for the manufacture of prototypes in urgent production. After a few days, the boards and the pre-ordered equipment were already with me. Just a couple of days with a soldering iron and now the thought has acquired a real shape!
It remains to hang the module on the Arduino and here it is, the long-awaited controller!
Working with such a device is a real pleasure! It was easy to test individual nodes using standard libraries and examples for Arduino. Errors and inaccuracies in the design and layout were found and corrected, of which there were not so many.
But the problem, known in advance, manifested itself with particular clarity, its essence was the “single tasking” of Arduino. Reading one sensor interfered with the work of others, stopping the exchange with OpenHAB.
Looking ahead, I’ll say that I was able to solve this problem, for which I had to rewrite part of the libraries, arranging a kind of multitasking with timer interrupts. But more about that in the next publication, which will be devoted to software.
What happened as a result of the work:
A prototype of a reliable and compact output input controller for the Smart Home system has been created, which can be used not only for experiments, but also in real conditions, it can serve as a good basis for the development of other devices.
The modular design allows you to easily change the configuration of the controller, provides ease of testing of sensors and components included in its composition.
An important feature of the controller is ease of assembly and adequate cost even in pilot production, which can positively affect its popularity.
What remains to be done before manufacturing a full-fledged version of the controller:
1. Make corrections in the circuit and design, eliminating errors and shortcomings found during alpha testing.
2. Install a connector for connecting the WiFi module of the ESP8266 instead of the HM-11 module, while designing an adapter board for the HM-11 with the same pinout of the connector.
3. Provide a Grove or DFRobot standard connector for remote connection of a DHT11 humidity sensor.
That seems to be it, a diagram and additional information on the progress can be found on the vk.com/myremoter project page.
Previous publications on docking Arduino with OpenHAB system via Modbus protocol can be viewed here :
How to make friends OpenHAB and Arduino habrahabr.ru/post/248569
Arduino & Modbus habrahabr.ru/post/249043
Arduino & OpenHAB habrahabr.ru/post/252555