The basic requirement for this project was to develop a solution based around an ESP8266 module which would allow for the AC units at work to be individually controlled. This to replace the existing and highly inadequate 'solution'.
What this new controller offers is room for a NodeMCU board. Four pins of the ESP8266 are used for PWM output, which are each passed through two RC filter stages to smooth it to a DC signal. This signal is then amplified by an LM324D quad opamp.
The board also provides room for an MH-Z19 CO2 sensor, a BME280 temperature sensor breakout board onboard and a further I2C connector to allow for a second, external BME280 sensor.
A 12VDC input is used to power the board. A 5VDC DC-DC converter module down-converts to the input voltage required for the NodeMCU board and the MH-Z19.
The system in its glorious v1.0 version is currently being installed at the office building, with a v1.1 revision being created.
Basic feature list:
12 VDC powered.
Based around NodeMCU module.
MH-Z19 CO2 sensor option.
Internal BME280 sensor option.
External BME280 sensor option.
Internal HC-SR501 motion sensor option.
Four 0 - 10 VDC output channels for AC units.
Breakouts for other GPIO pins.
Shaped to fit into CamdenBoss CBRS01VWH sensor enclosure (wall/ceiling mount).
Dimensions (roughly) 80x80 cm.
The NodeMCU (ESP8266) is an integral part of the board. It handles the WiFi (obviously), and reads out the CO2 and temperature sensors. It also controls the PWM output which drive the four output channels for the AC units.
For our purposes, the ESP8266's firmware uses an MQTT-based solution (based around the Sming framework), which communicates over a TLS-secured connection with a backend which provides the actual intelligence. An active loop is maintained to ensure that each controller unit is performing as intended.
The temperature readings are integrated into the backend logic which controls the AC units, to allow for the optimal temperature to be maintained by careful manipulation of the 1 - 4 AC units connected to a single controller.
There is also an option to add a motion sensor (HC-SR501) to this setup, using the +5 VDC and GPIO pins on the PCB, slotting the motion sensor board into the cut-out in the PCB after cutting an appropriate hole in the enclosure.
Some of those who have been following this project may have noticed that there haven't been updates for a while. There are two reasons for this.
The first reason being that this was a project that was being worked on during 'spare' time at the office and hence mostly shifted into my own spare time. The second reason involves me getting laid off due to changes in the focus of the company, making a primarily low-level, system developer - like yours truly - redundant.
At this point the three AC units (technically Fan Coil Units, or FCUs) have been hooked up to the system for a while, with a simple control service (written in C++ & POCO) controlling the fan speed. This has been working like a charm so far, but has also revealed the glaring weakness in this setup, namely the lack of control over the valves that regulate the water flow into the coils.
These FCUs being the two-pipe type (hot/cold intake and outlet) means that each FCU has a single valve controlled by a thermoelectric actuator (24 VAC), along with a set of valves elsewhere which control the water temperature in an entire section of the building. In order to effectively control this system the control service also needs to be able to:
Read out the status of the system (are we cooling? heating?).
Set the status of the system (cooling or heating).
Open and close individual FCU valves.
To this end two more devices were assembled, in prototype form:
An MCP23008 i2c-based GPIO expander along with an ULN2003 are used to control up to 3 relays (limited by the number of physical connectors, the ULN2003 can do up to 7 outputs). These relays (one pictured here as well) then control the 24 VAC to each thermoelectric actuator.
With this little device hooked up to the i2c bus on the existing PCB (as pictured) three FCUs can have both their fans and valves controlled directly by the backend service.
In order to read out and control the water temperature in the entire section, the existing manual switch will be replaced with this little device:
This particular device was a bit of a doozy. Since the electrical box which it will be installed in does not have any wiring going into it other than the four signal wires (center, cooling/auto/heating), it was necessary to add a mains voltage SMPS module, for which a 230 VAC connection will be installed into the electrical box. Bit messy, but there you go.
For this circuit another ULN2003 along with a latching relay (2-coil) was used. The NodeMCU (dead one used for test-fitting pictured) ESP8266 device controls two inputs (1B, 2B) on the ULN2003, which switches the relay between its two positions on both sides.
One side of the relay performs the switching between heating/cooling, with the other side being used by the ESP8266 to read out the current state of the system (active low, with pull-ups enabled on the input pins).
The relay controller has been tested already and will be installed next week. The 'IoT switch', as I have come to call it, will be tested and hopefully installed next week as well. Theoretically that means that along with the updates to the control service the prototype system as a whole will be done: controlling every aspect of these three FCUs in one room.
As I will be leaving the company at the end of this month, I will only have time to complete things that far. The goal is however to also open source the (unified) firmware and related services, along with full documentation. I will endeavor to get all of this together as a complete package.
This includes the PCB design, software and documentation. Here the v1.1 board design is almost done, but untested. There is also the idea to make a more integrated version, with the relay controller on the PCB instead of having it as a separate device.
I would very much like to spend as much time on this project as I have over the past months, but until my life has stabilised itself somewhat, it is unlikely that I will have the opportunity to do so, barring me landing a paid job courtesy of this project...
That's the first WiFi AC controller node (of 5 total) installed in an open plan office room. Initial tests show that the installed sensors (CO2, temperature, etc.) are functioning as expected, with the three connected AC units being supplied with an analogue signal.
Outstanding issues at this point with the controller itself are some remaining (software) issues with the PWM routine (causing too much noise and a 1.5VDC lowest output on the controller), and a regression with the TLS handshake, causing an out of memory situation.
As a result of this the connected AC units are supplied with at least 1.5VDC at the moment, causing their fan to keep spinning, albeit at a slow speed. It's expected that fixes to the firmware to get the PWM frequency at the target 1 KHz will fix this. Ideally an OTA update to the installed unit will suffice to fix this.
Similarly for the TLS issue. This issue has been reported to the Sming project and I'm looking into it myself as well. Maybe it's going to be as simple to solve as the i2c bus issue which I was dealing with a few days ago, which turned out to be just swapped pin parameters in the i2c initialisation function.
Another big remaining TODO is the lack of any kind of backend to control and drive the WiFi AC nodes with. This will be rectified over the coming days, so that one no longer has to manually send binary messages via MQTT to the target node :)
Once this has been completed, and things are more or less working, I'll start working on open sourcing the board design (the v1.1 redesign) and the accompanying software. Stay tuned.
After a few months of work, planning, learning to love KiCad and the intensely joyful experience of logistics concerning infrastructure in an office building, the first controller nodes will be installed soon. So far one signal wire has been connected to an AC unit (Sabiana SkyStar-ECM), with the following exciting result:
Thrilling, right? :)
Also interesting is a comparison with the old (wall-mounted) units that these new units are replacing:
Old unit is on the left. Obviously.
In this image the WiFi AC controller unit is controlling the AC unit in the same room, using the wiring the old unit normally connects to. Of note is that the old unit has two outputs (switchable between PWM/analogue) for driving a maximum of two AC units (or multiple chained, as happens in the main room of the office). The new unit can drive four AC units directly.
During this and next week the last wiring will be installed and the six boards that were assembled so far tested and validated before being put up into their position on the ceiling. Fingers crossed :)