Saturday, April 4, 2020

Building a kiosk for Home Assistant from scrap parts

It is great to have automation in the house providing increments of comfort such as eliminating manual tasks like cleaning the floor, or to aid in managing the energy consumption by turning off lights and appliances which are not in use, or in the safety side, by providing intrusion detection or monitoring the presence of gas leaks or other hazards, and executing the adequate actions.

Today this is possible not only because it constitutes the realization of several technological concepts that, albeit not new, would traditionally live in larger and more expensive systems, but also because of the evolution of the Internet and the frameworks, and the democratization in the access to cloud resources and building solutions on top of these.

With the high level of miniaturization allied to cheap manufacturing, the consumer is finally able to enjoy the value of delegating some of the time consuming and tedious tasks to machines that are inspired by robotic concepts that once belonged to the industry and other niche domains.

After having started to "rig" my house with more and more IoT devices, each with a specific role in the house, I came to realize that rapidly some of the patterns and nuances of managing a systems infrastructure began to emerge: from the primordial aspects such as energy availability and WiFi coverage, passing by intermediate aspects such as having to manage, store and represent the data that these devices produce continuously, and ultimately, to keep the software stack that is responsible for the automation as a whole operational.

Given the dimension of integration that is reached, one of the nuances that I found was that the interaction with the house and its devices is not entire functional. Except if the user carries his smartphone everywhere, or is always sitting at the computer, or (to a limited extent) is able to interact via a smart speaker using voice commands (e.g. Alexa or Google Home), it is otherwise impractical to invoke certain actions that in spite of being provided by the house (in this digital home automation context), require a type of interaction which may not be available or safe to perform in the same way as other actions. 

One such example is the intrusion alarm: when the user exits the house, he will typically arm this feature. Once he returns, he needs to somehow prove the house that his access is legitimate. Assuming that the door lock could have been compromised by the intruder, the home automation platform cannot assume that a successful unlocking of the door will necessarily be performed by the legitimate user. As such a separate authentication mechanism should exist, in order to ensure that the alarm system is minimally robust. One option could be to rely on the user smartphone and having to type a unlock code through it to disarm the alarm. While this is a valid solution, it may be impractical and annoying for some users to have it as part of the routines of entering the house.

With this in mind, I had the motivation to build a permanent interface always close to the entry door, so that it could be as practical as with a traditional alarm, to input the disarm code when entering the house.

While an off the shelf solution for this purpose could have been purchased, I considered it a much more interesting, instructive and environmentally friendly approach, to build one myself, while reusing as many scrap parts as possible.

I was lucky enough that recently a familiar of mine had given me a broken laptop computer. It was an old Toshiba Satellite P200-1IE. It had been damaged by water ingress while being used. The motherboard was toasted, so an integral recovery of the unit would not be possible.

This is an example of what for some can turn into a useless object, but for others, upon disassembly can turn into a treasure of useful parts.

A laptop computer is a composite of complex electronics, elaborate mechanical designs (a lot of complex individual parts need to fit into a tight space, while at the same time, weight needs to be minimized), several moving parts, and also the need for respecting the thermodynamic constraints (many of the electronic components dissipate a significant amount of heat that needs to be quicly moved to the exterior of the unit to avoid malfunction and damage).

While at a first glance many parts may seem useless for other purposes due to the custom designs that are present, the fact is that under the "skin" many of the components are quite standard:

For example, the camera (as with most laptop computers) is actually a USB device. By soldering the wires to a standard USB connector, one can connect it to a computer without in many cases having to install any drivers:

And there are many more useful parts. Another example is the battery: as with a broad variety of battery powered devices, this laptop battery pack is made of 6 individual Lithium Ion cells of the very popular 18650 format (the same format that was adopted by Tesla in its cars prior to the Model 3 - in which case it introduced the 2170 format). In this pack, the batteries were arranged in a 3S2P configuration (2 parallel groups of 3 series-connected cells), in order to provide the nominal 10.8 Volts and a capacity of 4000mAh:

A BMS (Battery Management System) is also housed in the battery pack itself:

This ensures that independent control and monitoring of the battery charge and discharge cycles is performed. It also protects against overcharging and overdischarging of each cell, and keeps track of the temperature of these. In case the normal operation envelope of the cells is compromised (cell voltage or temperature), the MOSFETs that are present in this board are able to cut the current to/from the cells:

While it is a used battery with some wear on it, after disassembly and testing of the individual cells, it may be possible to cherry pick the least degraded cells and use these for other purposes. Many people do such exercise with a large number of thrown away laptop batteries, in order to produce large packs capable of powering a house with the energy stored from solar panels.

Other parts such as the DVD writer, the WiFi antennas and the high voltage DC/DC converter used for the cold cathode backlight can also be of use for other applications:

But the part that captured my immediate interest (and more in line with the scope of this post) was the LCD screen. While I knew that this would not be a particularly fancy high resolution display, at least for the purpose I had in mind it would be more than enough. It was a 17.1 inch LG panel, featuring 1440x900 pixels resolution (model LP171WP4 (TL)(B4)):

Of course this is all great, but without a way of interfacing the panel with a computer or another device, it would be quite useless.

As such I looked up, and without having to dig too much, I found that adaptor boards could be purchased, and these would allow a laptop panel such as this one to be interfaced with anything featuring an HDMI or VGA output. This was ideal for what I had in mind, and as such went ahead and ordered the board:

The kit had pretty much everything needed to operate this panel: the high voltage DC/DC converter for the backlight, a button panel to control the module (i.e. access the settings menu and control the sound volume), and all the necessary cables including the LVDS connector to the LCD panel:

My first part of the construction plan was to create the enclosure to house all the required components, in a minimally robust setup.

I started by building an aluminium frame:

The LCD panel would be fixed to a 1.5 mm aluminium sheet. This would be the backplane for all the needed components:

For the fixing with the larger screws with the standoffs, two aluminium parts were cut in order to adapt between the LCD panel and the backplane:

For the power supply, I needed something capable of providing +5 Volts and +12 Volts DC. Luckily I had an old external CD-ROM drive power supply, which would suit my power requirements just fine:

Removed the original plastic case from the power supply, and adapted it, so that it could be fixed to the aluminium backplane while retaining all the required insulation and mains protection. For that effect the lower part of the plastic cover was reused. Also added a connector for the dual DC output:

At this point this project would be missing a very important part. Better said, the Kiosk would not be of much use without the computational part of system. For this effect (again trying to minimize purchasing new materials) I found a nearly perfect solution: I happened to have a device which I would not use for some time, sitting in a shelf. It was an old Rikomagic Android dongle:

While it was old (bought in 2014) and kind of obsolete (its last update was to Android 4.4.2 - Kitkat), for basic web navigation and running Chrome it should still be sufficient. For some time I still managed to watch downloaded movies and Netflix (while the app would support it), so it was not entirely bad.

As such in order to provide for a more robust fixing to the Kiosk backplane, and given that the PCB of this dongle did not have any holes where screws and standoffs could be places, I adapted some pin headers and soldered these to some points in the board, including holes from unpopulated components:

The board itself would then attach to perfboard which in turn would be fixed to the backplane with nylon standoffs.

Some initial planning of where each component would be placed in the backplane:

Given that potentially I would want to connect multiple USB peripherals, I had to add a USB hub in order to have more ports. I went for a cheap small sized hub which I stripped from the original case, and added the pin headers for connecting to the sockets and internal devices:

The LCD panel adapter board also featured an audio amplifier, so I could have audio in this device. Searched again in my scrap parts repository, and found some old PC speakers which had satisfactory audio performance:

Extracted these from the original case, and drilled the holes with the appropriate size in the backplane, so that the speaker cones could be exposed:

Finished the drilling of all the required holes and slots in the backplane, and attached all the necessary boards and components. Also added a protection around the mains socket, in order to prevent a person from touching live terminals from the power supply:

Finished all the assembly, and added the WiFi antenna to the rear:

The buttons from the LCD adaptor were made accessible from the backplane as well, through some orifices:

With the help of the USB hub, 3 external ports were made available, while the 4th port was reserved for an extra internal device.

And finally the fully operational device. In order to have the interface showing up on startup a few steps were needed, but that is a topic which deserves a dedicated blog post, which will follow:

I hope this project can be inspiring for the users, especially for the fact that we can and should look forward to make a better use of the resources that the planet provides us. Whenever we fail to resist the temptation of buying every shiny new product that appears in the market just shiny and new, we are contributing to the accumulation of waste in the planet. And this unfolds into more plastics in the oceans, toxic chemicals in the acquifers, increased levels of CO2 in the atmosphere, and so on and so forth. Another benefit of exercising the reuse and repurposing of scrap materials is for the fact that we are improving ourselves in becoming more creative when situations that require it arrive. It is one such example, the pandemic which we are currently experiencing. The need for ventilators to treat patients in the more acute manifestation of the disease is as you all know, causing a shortage of these equipments. If there are people technically prepared and creative to grab available materials (eventually from scrap parts) and build working solutions that satisfy the problems, then we can have a society better prepared to handle the situations without depending on a largely overwhelmed, insufficient or uncooperative industry.

No comments: