Fiasco. The story of one homemade IoT

 3r33479. 3r3-31. Most articles are written according to the principle “I /we did it /and look how cool it is!”. The same publication is dedicated to a failed project. Welcome to the category
 3r33479. Development of smart devices on the example of a floor heating controller on ESP8266
 3r33479.

Start from a distance


 3r33479.
I live in a small house that is built according to my project. Layout - eurotreshka, corridor, kitchen-living room on the first floor, bathroom, children's room and bedroom on the second. From non-standard - walls arbolit, the foundation of UWB, heating only TP. At the same time, the floors are wooden, on the second floor there is a floating floor, TP - in the slab GVL. On the first floor there are 3 loops of TP pipes (actually one room), on the second one there are also three, but each loop is responsible for one room (bedroom, bathroom, children's room). A wall-mounted gas boiler of 14 kW is responsible for heat. Controls the boiler Chinese programmable weekly wireless thermostat. Every day of the week he has four periods, in each period you can set the desired temperature. Brains on the battery, the relay is hidden. Works great. But I often need more than I have. I wanted room temperature control. I looked at the proposed solutions, I did not like anything. And the word "Arduino" caught my eye. And by specialty I am a programmer. And it started
 3r33479.
 3r33479.

Iron 3r33460.
 3r33479.
In iron I am not strong. Soldering board is the height of my abilities. But Arduino is such a simple thing that I understood - even with my knowledge of electronics, I am able to make a temperature controller in a house that suits me.
 3r33479.
 3r33479. 3r3302. Temperature sensors 3r3303.
 3r33479.
I have no love for wires in the interior. I try to exclude or hide them, if it is impossible to exclude them. And in a somewhat tortuous way, I came to use wireless sensors from Chinese weather stations as room temperature sensors. The sensors operate on batteries for a long time and broadcast at 433 MHz. It is quite nice, you can choose a different color, with the screen and without the screen. Looking ahead, I will say that each weather station manufacturer invents its own data transfer protocol with a sensor. In the course of the experiments, I analyzed the protocols of 5 types of sensors - they all have different data transfer formats. I developed a library that accepts data from 4 types of sensors. I didn’t contact the fifth - its protocol is not similar to the others by the absence of packet boundaries. The main tool for data analysis has become the Chinese logic analyzer. Without such a tool, it is practically impossible to perform protocol analysis. It is worth quite a bit, it's easy to use - I recommend buying it to all the Arduinschik.
 3r33479. I implemented the library on the principle of sampling, frequency 10kHz. This approach allowed to level the noise in the air and reduce the load on the processor, compared with the approach with interruptions when changing the level at the receiver pin. A logic analyzer was used for debugging:
 3r33479.
3r33356. 3r33357. Signal with debug data [/b]
Fiasco. The story of one homemade IoT  3r33479. 3 6 channels - data for debugging
 3r33479. 3r33475. 3r33475.
 3r33479.
 3r33479. I will give examples of sensors and their features.
 3r33479. 3r33427.  3r33479.
Type 1: Data transfer every 35 seconds. The period does not change and this is a problem when using 3 or more sensors - the clock in the sensors go a little differently, the signals can sometimes overlap, and one or two sensors fall for an hour or two or three times a week or two. 6 data packets in 0.8 seconds. Sensor ID changes each time it is turned on. No data on battery status.
 3r33479. 3r33356. 3r33357. Appearance [/b]
 3r33479. 3r33475. 3r33475.
 3r33479. 3r33356. 3r33357. Data 3r33358.
 3r33479. Above - the receiver data, the arrows indicate interference
 3r33479. Below is the transmitter data.
 3r33479. 3r33475. 3r33475. 3r3442.  3r33479.
Type 2: Data transmission period - 40 80 seconds, depending on the channel. The best protocol in my opinion is 15 data packets for 0.6 seconds, there is a checksum. Sensor ID changes when turned on, there is a transfer of battery status data. The weakest transmitter - when I placed the receiver in the box, the reception quality deteriorated markedly. Probably being treated with an external antenna for the receiver.
 3r33479. 3r33356. 3r33357. Appearance [/b]
3r399.
 3r33479. 3r33475. 3r33475.
 3r33479. 3r33356. 3r33357. Data 3r33358.
3r31-10.
 3r33479. no interference
 3r33479. 3r33475. 3r33475. 3r3442.  3r33479.
Type 3: The data transfer period is 5055 seconds, depending on the channel. 7 packs for 0.6s. ID changes when turned on, there is a transfer of battery status data. Not a bad choice.
 3r33479. 3r33356. 3r33357. Appearance [/b]
 3r33479. 3r33475. 3r33475.
 3r33479. 3r33356. 3r33357. Data 3r33358.
Almost identical to type 1
 3r33479. 3r33475. 3r33475. 3r3442.  3r33479.
Type 4: The data transfer period is 56 76 seconds, depending on the channel. There is no screen. Changeable when enabled ID is not detected. Whether there are differences in the ID of different instances - I do not know, I have one such sensor. Data on the status of the battery - is. A powerful signal, the transmission pass was hardly observed.
 3r33479. 3r33356. 3r33357. Appearance [/b]
3r33150.
 3r33479. 3r33475. 3r33475.
 3r33479. 3r33356. 3r33357. Data 3r33358.
not preserved
 3r33479. 3r33475. 3r33475. 3r3442.  3r33479.
Type 5: I did not measure the transmission period, there is no channel switch, I did not analyze the protocol in depth.
 3r33479. 3r33356. 3r33357. Appearance [/b]
3r3174.
 3r33479. 3r33475. 3r33475.
 3r33479. 3r33356. 3r33357. Data 3r33358.
3r3185.
 3r33479. 3r33475. 3r33475. 3r3442.  3r33479. 3r3444.
 3r33479.
As a result, the receiver unit is implemented on the Arduino Pro Mini c output data on the i2c slave.
 3r33479.
 3r33479. 3r3302. Arduino Mega
 3r33479.
This is the first platform on which I made the controller. My controller had a command interface, was controlled by commands entered via UART. At that stage, I planned to make the WEB-interface on the ESP8266 and its communication with Mega on the UART. I have a Mega board from Robotdyn, combined with ESP826? and on this board I was planning to build my own development. A special advantage of the board is a large number of external ports. But in the process of exploring the ESP826? I realized that this small chip is quite capable of combining the functions of a controller and interface.
 3r33479.
 3r33479. 3r3302. ESP8266 3r3303.
 3r33479.
I used a variant of the WeMos D1 mini board, it has a small size and a sufficient number of conclusions for me - taking into account the use of a port expander. There are a huge number of libraries for this board. For example, me-no-dev /ESPAsyncWebServer is an excellent web server library with web socket support. I gathered the controller on this board. Developed a web interface. Everything works beautifully. But for some unknown reason - uptime is not more than a day. Either I did something crooked, or some of the libraries used is a curve. In addition, there is a limit on 5 simultaneous connections. When exceeded - restart or even freeze (despite the existing watchdog. I struggled with hangs using an external watchdog). Taking into account the fact that my web interface consists of almost a dozen files, and browsers load pages in 5 parallel threads - it is elementary to achieve a restart. For myself, I decided - this board can only be used as a client. Began to look for other solutions.
 3r33479.
3r33356. 3r33357. Interface screens [/b]
 3r33479.
 3r33479.  3r33479.
 3r33479.  3r33479.
 3r33479.  3r33479.
 3r33479.  3r33479. 3r33475. 3r33475.
 3r33479.
 3r33479. 3r3302. ESP32 3r3303.
 3r33479.
This is sort of like the heir to ESP8266. In ESP3? most of all - frequencies, memory, legs, But the trouble is that the me-no-dev /ESPAsyncWebServer library does not work on it in terms of web sockets. Totally. Flies out. Something related to multithreading. I did not find another web server library with web socket support.
 3r33479.
 3r33479.
SOC 3r33460.
 3r33479.
At this stage, I decided to use a board with linux - I did not come up with anything more appropriate.
 3r33479.
 3r33479.
My requirements for the board. It seems there are not many of them:
 3r33479.
 3r33479. 3r33427.  3r33479.
I don't need a screen. 3r3442.  3r33479.
Due to the lack of a screen for initial setup, the board should be able to work in the access point mode. 3r3442.  3r33479.
I need a minimum of operating system functionality. 3r3442.  3r33479. 3r3444.
 3r33479. 3r3302. Orange Pi i96 3r3303.
 3r33479.
This board was suitable in all respects - no video output, WiFi, built-in flash memory, SD card slot. You can put Ubuntu or DietPi on the built-in memory. But the trouble of this board is its software. You can not make an access point. Well, the biggest problem is that when restarting, the MAC address changes and nothing can be done about it. In the furnace. (At the time of writing, on w3bsit3-dns.com, in the branch dedicated to the analogue of this board (2g IOT), a message appeared that it is possible to defeat the MAC shift)
 3r33479.
 3r33479. 3r3302. Onion Omega 2+
 3r33479.
Chic documentation. With the firmware out of the box, everything started up, the screen is not needed, the UART is optional. SSH is enabled by default. Node.js was installed (version 4.x, but it doesn't matter to me). The sqlite and i2c libraries for Node.js were installed (using a tambourine).
 3r33479. Besides i2c, I no longer need any hardware interfaces. Compared to the version of my development on the ESP826? a separate controller, the Arduino Pro Mini, was added to analyze the data of the temperature sensor receiver. The receiver controller is connected to the Omega as an i2c slave. Wired sensors with 1wire interface are connected via a 1wire <-> bridge. i2c (DS2482-100). For this bridge there is a library for node.js, but it did not work for me in the part of the search for sensors. I did not understand, ported to js the DS2482 library that worked on ESP8266.
 3r33479. But the trouble is that WiFi on Omega-2 does not work stably, after rebooting the router it does not reconnect. This problem is solved by firmware version ? it is not in the release status, but it works. It became much better. But the problem was clarified - sometimes the board falls off the Zyxel router and connects again after rebooting the router or after an hour or two or three by itself without rebooting the router. Or it starts terribly stupid - this problem went away after changing the power supply circuit (the board loves 3.3V or slightly higher) and adding an external antenna - the omega was very happy about it. Thus, in principle I am satisfied with the board - something that is not there sometimes doesn’t worry me much about access - as the main interface I used an old smartphone in the dock connected to the Omega access point. But remote access will be much needed - I can remotely restart the router. It causes misunderstanding - Omega-2 has two RST pins - one must be + to one, as I understand it, this is handled programmatically. What to submit to the second and how to connect an external watchdog, which gives - I do not know yet.
 3r33479.
3r33356. 3r33357. Interface in the interior of [/b]
3r33333.
 3r33479. 3r33475. 3r33475.
 3r33479.
 3r33479.
The logic of the controller


 3r33479.
I have already described the software architecture of the controller — it has not changed (i.e., control of text commands transmitted via a web socket). Web-interface migrated from ESP8266 with cosmetic changes. Many procedures /functions of the controller code were simply translated from C ++ to JS. Another thing is that the presence of linux (OpenWRT) gave me the opportunity to use a SQL database - sqlite. Thus, I organized all the logic on SQL queries. This is actually my first experience with sqlite. I especially liked the possibility of using in-memory databases - I arranged all temporary and current data in this database (for example, sensor data, data on the current required temperature, ).
 3r33479.
3r33356. 3r33357. Sources 3r3r58b.
I usually share ideas, not source. I think it stimulates mental activity, mine and readers. Want to get the source - write in a personal.
 3r33479. 3r33475. 3r33475.
 3r33479.
 3r33479.

Build 3r33460.
 3r33479.
I collected everything in the gland, placed it in a box. Next - life tests. After a week of uptime - I decided that the test was passed. You can install.
 3r33479.
3r33356. 3r33357. Boll [/b]
 3r33479. 3r33475. 3r33475.
 3r33479.
 3r33479.
Installation 3r33460.
 3r33479.
This stage was very successful. Hung a box next to the collector, installed and connected the thermal heads. I was very happy with my idea of ​​storing all data, settings and parameters in the database - on the fly I was able to configure the correspondence of relays and zones in a way that was not planned, namely, three relays per zone, and all other relays to move (the original the idea was one zone - one relay). The project included the use of a set of DS18B20 service sensors, to monitor the coolant temperature at the inlet, in the return pipe of each loop of a warm floor, and the total return temperature — these sensors were also successfully connected and configured (all settings - to indicate the clear name of the sensor).
 3r33479.
 3r33479.
Connected the boiler relay.
 3r33479.
 3r33479.
Run 3r33460.
 3r33479.
The controller earned as planned.
 3r33479.
 
3r3449. For the test, I decided to slightly raise the temperature in one of the rooms on the second floor.
 3r33479.
 3r33479.
The boiler began to overheat and shut down.
 3r33479.
 3r33479.
And here the service sensors came in handy. It turned out that the water temperature at the exit from the loop of this room is only a couple of tenths of a degree less than at the entrance! The water does not cool! This means that it does not give off heat. And in the whole house it is warm at any temperature overboard (the goal was to slightly lower the temperature on the second floor). So everything gives warmth to the first floor, and the TP on the second floor barely heats the floor. As a result, room-based regulation of heating in such conditions is not possible.
 3r33479.
 3r33479.
Conclusion 3r33460.
 3r33479.
Thus, the influence of physics and the design features of my house put an end to my design. Despite the fact that the controller itself works fine, I cannot use it in the heating system of my house. Maybe I will make him a downgrade so that he can control the climate in the house like a Chinese thermostat - according to a single sensor, but for now I see no reason.
 3r33479.
 3r33479.
At the same time, that the project as a whole is not successful, in the process of development I became acquainted with many technologies with which I was practically unfamiliar:
 3r33479.
3r33427.  3r33479.
Programming Controllers
 3r33479.
I learned about the data bus 1wire, i2c, uart,
 3r33479.
I gained some knowledge of the device web server 3r3442.  3r33479.
It seems not bad understood in Web-frontend development: html, jаvascript, vue.js
 3r33479.
I mastered the Web-backend development: node.js
 3r33479. 3r3444.
 3r33479.
 3r33479.
Thus, I got a great experience on a failed project, which might be useful on other projects.
 3r33479. Those who read up to this place can look at what happened: http://tco.vehs.ru/
 3r33479.
 3r33479.
P.S. Ideal board for DIY


 3r33479. In the process of writing the article, another trouble with Omega-2 was discovered - the module began to hang. Hard, reset does not help, just power off. What is the problem - I do not know yet. Maybe he doesn’t like high power - now he is served 3.8V. I'll try to replace the power module. Despite the fact that the project does not fulfill its functions, for the time being I will leave it in thermometer mode (as they say, do not do it on Arduino - you will get a weather station). But in any case, the topic is interesting to me, I want to achieve 100% availability of the system 24/7. If replacing the power supply doesn't help, I'll try the LinkIt Smart 7688 system. It seems to be hardware identical to Omega. It may be more stable.
 3r33479. Based on this - I have not yet found the ideal board for homemade products: (
 3r33479. Probably, as the next project’s brain, I’ll try to use a smartphone on android - the sensors will have to be connected to it via wifi, but there are practically no problems with the stability of branded phones. And node.js can be put on the phone.
 3r33479. I would be grateful if you share your vision on choosing a board for DIY. 3r33475. 3r33479. 3r33479.
! function (e) {function t (t, n) {if (! (n in e)) {for (var r, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e.parentNode.insertBefore (r, e)}; "[object Opera]" == e.opera? a.addEventListener? a.addEventListener ("DOMContentLoaded", d! ): d ()}}} t ("//mediator.mail.ru/script/2820404/"""_mediator") () (); 3r33473. 3r33479. 3r33475. 3r33479. 3r33479. 3r33479. 3r33479.
+ 0 -

Add comment